我在 WPF 中使用 Kendo Telerik RadTreeview 控件。我具有为每个 RadTreeViewItem 节点添加一个自定义按钮的功能,该按钮会在命令事件显示时弹出。
我添加了按钮并在HierarchicalDataTemplate
下面使用它
<HierarchicalDataTemplate x:Key="BuildingStructure"
ItemsSource="{Binding Levels, Mode=TwoWay}"
ItemContainerStyle="{StaticResource levelNodeStyle}">
<Grid HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Width="250"
Text="{Binding StructureName , Mode=TwoWay}"
HorizontalAlignment="Left"
Panel.ZIndex="2"/>
<Button
Canvas.Left="10"
Canvas.Bottom="20"
Panel.ZIndex="1"
BorderThickness="0"
BorderBrush="Transparent"
Background="Transparent"
Foreground="White"
HorizontalAlignment="Left"
Grid.Column="1"
VerticalAlignment="Stretch"
Command="{Binding DataContext.AddLevelRadTreeCommand, RelativeSource={RelativeSource AncestorType=telerik:RadTreeView}}"
CommandParameter="{Binding ElementName=radTreeView}"
Margin="0 2 0 5">
<Image
Width="20"
Height="20"
Source="/Project;component/Resources/Images/03-Add.png"/>
</Button>
</Grid>
</HierarchicalDataTemplate>
我想要的是在命令事件中我需要添加命令参数,该参数将传递RadTreeviewItem
分配给该节点的当前数据对象,如下所示
StructId:1,
StructName:'Building A'....and so on...