我创建了2个模板,我想知道是否可以将一个模板放在另一个模板之上,希望这些图像和更多描述可以帮助我描述我遇到的问题:
所以我想要的是第一张图片在前面,第二张图片在后面,有没有办法做到这一点,如果是这样,有人可以帮忙吗?
图片1模板XAML
<DataTemplate x:Key="PropertyNode1Template">
<Grid VerticalAlignment="Top" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border BorderBrush="Black" BorderThickness="1" VerticalAlignment="Center" Grid.Row="0">
<StackPanel Margin="2" Width="120" Orientation="Horizontal" Background="White"
Tag="{Binding RelativeSource={RelativeSource AncestorType={x:Type syncfusion:Node}}}">
<StackPanel.ContextMenu>
<ContextMenu DataContext="{Binding PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
<MenuItem Header="Remove" Click="RemoveProperty_OnClick">
<MenuItem.Icon>
<Image Source="Images/icon_remove.bmp"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Add Scenario" Click="CreateScenario_OnClick">
<MenuItem.Icon>
<Image/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</StackPanel.ContextMenu>
<Image Source="{Binding Icon, Converter={StaticResource ImageToSourceConverter}}" Width="16" Height="16" Margin="5"/>
<Label Content="{Binding Name}" x:Name="NodeLabel" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="10"/>
</StackPanel>
</Border>
<Button Name="AddScenario" Click="AddScenarioButton_OnClick" Grid.Row="2" BorderThickness="0">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border BorderThickness="0">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsHighlighted}" Value="True">
<Setter Property="Visibility" Value="Visible"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding IsHighlighted}" Value="False">
<Setter Property="Visibility" Value="Hidden"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Border BorderThickness="1,1,1,1" VerticalAlignment="Center" Background="LightGray">
<Border.BorderBrush>
<DrawingBrush Viewport="8,8,8,8" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="LightGray">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0,50,50" />
<RectangleGeometry Rect="50,50,50,50" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Border.BorderBrush>
<StackPanel Margin="2" Width="120" Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource AncestorType={x:Type syncfusion:Node}}}">
<Image Source="{StaticResource ImageBkgPlus}" Width="16" Height="16" Margin="5"/>
<Label Width="70" FontSize="10" VerticalAlignment="Center" Content="Add Scenario">
</Label>
</StackPanel>
</Border>
</Button>
</Grid>
</DataTemplate>
图片2 XAML tempalte
<DataTemplate x:Key="PropertyNodeTemplate">
<Grid VerticalAlignment="Top" Name="OuterButtonGrid">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border Name="InnerBorder" CornerRadius="8,8,8,8" BorderBrush="LightGray" BorderThickness="2" Grid.Row="0">
<Grid VerticalAlignment="Top" HorizontalAlignment="Center" Width="130" Name="InnerPropertyGrid">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Style>
<Style TargetType="Grid">
<Setter Property="Background" Value="LightGray"/>
<Style.Triggers>
<DataTrigger Binding="{Binding IsHighlighted}" Value="True">
<Setter Property="Background" Value="#FAE68E"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Image Source="{Binding Icon, Converter={StaticResource ImageToSourceConverter}}" Width="16" Height="16" Margin="8" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Label Name="PropertyTitle" Content="{Binding Name}" HorizontalAlignment="Center" Margin="5">
</Label>
</Grid>
</Border>
<Canvas HorizontalAlignment="Left" VerticalAlignment="Top" Grid.Row="1">
<Canvas.Style>
<Style TargetType="Canvas">
<Style.Triggers>
<DataTrigger Binding="{Binding IsHighlighted}" Value="True">
<Setter Property="Visibility" Value="Visible"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding IsHighlighted}" Value="False">
<Setter Property="Visibility" Value="Hidden"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Canvas.Style>
<Line Stroke="LightGray" StrokeDashArray="2 2" Y2="70"/>
</Canvas>
<Canvas HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Row="1">
<Canvas.Style>
<Style TargetType="Canvas">
<Style.Triggers>
<DataTrigger Binding="{Binding IsHighlighted}" Value="True">
<Setter Property="Visibility" Value="Visible"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding IsHighlighted}" Value="False">
<Setter Property="Visibility" Value="Hidden"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Canvas.Style>
<Line Stroke="LightGray" StrokeDashArray="2 2" Y2="70"/>
</Canvas>
<Button Name="AddScenario" Click="AddScenarioButton_OnClick" Grid.Row="2" BorderThickness="0">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border BorderThickness="0">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Binding="{Binding IsHighlighted}" Value="True">
<Setter Property="Visibility" Value="Visible"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding IsHighlighted}" Value="False">
<Setter Property="Visibility" Value="Hidden"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<Border BorderThickness="1,1,1,1" VerticalAlignment="Center" Background="LightGray" CornerRadius="3,3,3,3">
<Border.BorderBrush>
<DrawingBrush Viewport="8,8,8,8" ViewportUnits="Absolute" TileMode="Tile">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="LightGray">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0,0,50,50" />
<RectangleGeometry Rect="50,50,50,50" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Border.BorderBrush>
<StackPanel Margin="2" Width="120" Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource AncestorType={x:Type syncfusion:Node}}}">
<Image Source="{StaticResource ImageBkgPlus}" Width="16" Height="16" Margin="5"/>
<Label Width="70" FontSize="10" VerticalAlignment="Center" Content="Add Scenario">
</Label>
</StackPanel>
</Border>
</Button>
</Grid>
</DataTemplate>
答案 0 :(得分:1)