I was playing with the samples.
One of the basic requirements is to be able to support context menus.
I did not see any examples with context menus. So I tried modifying the following, in the datadrilldown.xaml sample:
<TextBlock Grid.Column="1" x:Name="TextBlockRevenue" FontWeight="Bold" TextWrapping="Wrap" DataContext="{TemplateBinding DataContext}" Text="{Binding Path=Revenue, StringFormat='{}{0:C}'}" > <TextBlock.ContextMenu> <ContextMenu> <MenuItem Header="My ConextMenu">Foo_0</MenuItem>
</ContextMenu> </TextBlock.ContextMenu> </TextBlock>
I also added the following
<ig:XamTreemap.NodeBinders> <ig:NodeBinder TargetTypeName="Manufacturer" ValuePath="Revenue" TextPath="Name" ItemsSourcePath="Products" NodeStyle="{StaticResource ManufacturerNodeStyle}" > <ig:NodeBinder.ContextMenu> <ContextMenu IsEnabled="True" AllowDrop="True"> <ContextMenu.Items> <MenuItem Header="My New ContextMenu">Foo_1</MenuItem> </ContextMenu.Items> </ContextMenu> </ig:NodeBinder.ContextMenu> </ig:NodeBinder>
When I run the application, right-mouse-button click will not display the context menu.The intellisense shows that the object.ContextMenu is understood and the xaml compiles. it just does not display at runtime.
It would have been great if the treeMap examples also included some context menu sample.Would it be possible to get a simple complete example, ideally using the MVVM pattern.
Thank
Thanks for the code sample.
Please verify that the WPF version does not support menus though xaml at this time.I have to make this statement to the team.We are trying to minimize the code (as per MVVM pattern).
Thanks
In wpf you could handle the mouse right button down event and do something like this
void treemap_NodeMouseRightButtonDown(object sender, TreemapNodeClickEventArgs e)
{
e.Node.ContextMenu = new ContextMenu();
e.Node.ContextMenu.Items.Add(new MenuItem() { Header = "Menu1" });
e.Node.ContextMenu.Items.Add(new MenuItem() { Header = "Menu2" });
e.Node.ContextMenu.Items.Add(new MenuItem() { Header = "Menu3" });
e.Node.ContextMenu.IsOpen = true;
}
thanks for your reply.
I am not using the silverlight version/.
I'm analyzing the viability of using the WPF version. Does this change the answer?Thanks
Currently silverlight does not support a standart way to show context menus. You may try using our xamContextMenu control.