我正在使用方便的控件,这是第一次使用它,所以我面临着一些困难
在测试应用程序中,我正在使用hc:SideMenu
我可以从hc:SideMenu中取出选定的项目标题
<hc:SideMenu
x:Name="MySideMenu"
Grid.Column="0"
Width="200"
Margin="5"
BorderThickness="1"
SelectionChanged="MySideMenu_SelectionChanged">
<hc:Interaction.Triggers>
<hc:EventTrigger EventName="SelectionChanged">
<hc:EventToCommand Command="{Binding SwitchItemCmd}" PassEventArgsToCommand="True" />
</hc:EventTrigger>
</hc:Interaction.Triggers>
<hc:SideMenuItem Header="Overview" IsSelected="True">
<hc:SideMenuItem.Icon>
<Image
Width="24"
Height="24"
Source="/Folder/01.png" />
</hc:SideMenuItem.Icon>
<hc:SideMenuItem
x:Name="MySummary"
Command="{Binding SelectCmd}"
CommandParameter="{Binding Header, RelativeSource={RelativeSource Self}}"
Header="Summary"
IsSelected="False">
<hc:SideMenuItem.Icon>
<TextBlock Text="" />
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem
Command="{Binding SelectCmd}"
CommandParameter="{Binding Header, RelativeSource={RelativeSource Self}}"
Header="Dashboards">
<hc:SideMenuItem.Icon>
<TextBlock Text="" />
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
<hc:SideMenuItem
Command="{Binding SelectCmd}"
CommandParameter="{Binding Header, RelativeSource={RelativeSource Self}}"
Header="Wiki">
<hc:SideMenuItem.Icon>
<TextBlock Text="" />
</hc:SideMenuItem.Icon>
</hc:SideMenuItem>
</hc:SideMenuItem>
</hc:SideMenu>
C#代码是
私有void MySideMenu_SelectionChanged(对象发送方、HandyControl、数据、函数事件参数){
string SelectedItemHeader = ((HeaderedSimpleItemsControl)MySideMenu.Header).ToString();
textBox.Text = SelectedItemHeader;
}
1条答案
按热度按时间juzqafwq1#
试试这个: