Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how can i get the selected item header in HandyControl hc:SideMenu WPF

i am using handy controls and this is first time to use it
so i am facing some difficulties

in test app i am using hc:SideMenu

and i can get out the selected item header from the hc:SideMenu

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<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="&#xf2cb;" />
            </hc:SideMenuItem.Icon>
        </hc:SideMenuItem>

        <hc:SideMenuItem
            Command="{Binding SelectCmd}"
            CommandParameter="{Binding Header, RelativeSource={RelativeSource Self}}"
            Header="Dashboards">
            <hc:SideMenuItem.Icon>
                <TextBlock Text="&#xf246;" />
            </hc:SideMenuItem.Icon>
        </hc:SideMenuItem>

        <hc:SideMenuItem
            Command="{Binding SelectCmd}"
            CommandParameter="{Binding Header, RelativeSource={RelativeSource Self}}"
            Header="Wiki">
            <hc:SideMenuItem.Icon>
                <TextBlock Text="&#xe82d;" />
            </hc:SideMenuItem.Icon>
        </hc:SideMenuItem>
    </hc:SideMenuItem>

</hc:SideMenu>

and C# code is

private void MySideMenu_SelectionChanged(object sender, HandyControl.Data.FunctionEventArgs e)
{

string SelectedItemHeader = ((HeaderedSimpleItemsControl)MySideMenu.Header).ToString();
textBox.Text = SelectedItemHeader;

}

>Solution :

Try this:

private void MySideMenu_SelectionChanged(object sender, 
    HandyControl.Data.FunctionEventArgs<object> e)
{
    SideMenuItem sideMenuItem = e.Info as SideMenuItem;
    textBox.Text = sideMenuItem?.Header?.ToString();
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading