1
我創建了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>
你有沒有試過使用'Panel.ZIndex'玩? – Hopeless
我從來沒有遇到過,至今 –
所以嘗試使用它,它應該在幾乎情況下工作(在某些情況下,它沒有預期的結果,但它很少)。 – Hopeless