Hi ,
I want to Display XamMenu horizontally with HierarchicalData as datasource. It should support
navigation also. the following code works fine but it is not diaplying horizontally. Please help me in this.
<
>
=Children}">
="True"
}"
="True">
}"/>
="Horizontal">
Hi,
You shouldn't place a XamMenuItem in your ItemTemplate. A XamMenuItem will be created as a container for the DataTemplate you provide, which means you'll end up having XamMenuItem inside a XamMenuItem. So, you'll have a XamMenuItem with MenuOrientation set to "Horizontal" inside of another XamMenuItem, generated as a container to host the one you specified in your DataTemplate. And the Parent one will have it's MenuOrientation set to the default value (which is Vertical). Instead, you could specify a DefaultItemsContainer, which will be used when generating the container items.
So your code should look something like this:
<ig:XamMenu x:Name="igMenu" Height="30" Margin="10" ItemsSource="{StaticResource data}"> <ig:XamMenu.DefaultItemsContainer> <DataTemplate> <ig:XamMenuItem MenuOrientation="Horizontal" /> </DataTemplate> </ig:XamMenu.DefaultItemsContainer> <ig:XamMenu.HierarchicalItemTemplate> <ig:HierarchicalDataTemplate ItemsSource="{Binding Path=Children}"> <ig:HierarchicalDataTemplate.DefaultItemsContainer> <DataTemplate> <ig:XamMenuItem NavigationOnClick="True" MenuOrientation="Horizontal" NavigationUri="{Binding PageURL}" NavigationElement="{Binding ElementName=menuFrame}" StaysOpenOnClick="True"> </ig:XamMenuItem> </DataTemplate> </ig:HierarchicalDataTemplate.DefaultItemsContainer> <ig:HierarchicalDataTemplate.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" /> </DataTemplate> </ig:HierarchicalDataTemplate.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" /> </DataTemplate> </ig:HierarchicalDataTemplate> </ig:XamMenu.HierarchicalItemTemplate> </ig:XamMenu>
Hope this helps,
Hi Georgi Angelchov,
Thank you very much. Its working fine.