Hello,
I have application from yours(from last post).
and I want to transfer the radContextMenu definition from the XAML filt to the CS file:
in the XAML:
and I write in the CS file:
but the context menu don't show!!!
Can you help me???
Thanks.
I have application from yours(from last post).
and I want to transfer the radContextMenu definition from the XAML filt to the CS file:
in the XAML:
<telerikNav:RadContextMenu.ContextMenu> |
<telerikNav:RadContextMenu x:Name="ContextMenu" ItemClick="ContextMenu_ItemClick" |
ItemsSource="{Binding Items, Source={StaticResource MenuModel}}" |
ItemTemplateSelector="{StaticResource ItemTemplateSelector}" /> |
</telerikNav:RadContextMenu.ContextMenu> |
RadContextMenu ContextMenu = new RadContextMenu(); |
ContextMenu.ItemClick+=new RadRoutedEventHandler(ContextMenu_ItemClick); |
MenuModel menu = new MenuModel(); |
MenuItemCollection y= menu.Items; |
Binding bin = new Binding("Items"); |
bin.Source = y; |
ContextMenu.SetBinding(RadContextMenu.ItemsSourceProperty,bin); |
Can you help me???
Thanks.
7 Answers, 1 is accepted
0
Hi ruty,
You need to set the RadContextMenu.ContextMenu attached property:
DependencyObject elementWithContextMenu = ...;
...
RadContextMenu ContextMenu = new RadContextMenu();
ContextMenu.ItemClick+=new RadRoutedEventHandler(ContextMenu_ItemClick);
MenuModel menu = new MenuModel();
MenuItemCollection y= menu.Items;
Binding bin = new Binding("Items");
bin.Source = y;
ContextMenu.SetBinding(RadContextMenu.ItemsSourceProperty,bin);
elementWithContextMenu.SetValue(RadContextMenu.ContextMenu, ContextMenu);
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You need to set the RadContextMenu.ContextMenu attached property:
DependencyObject elementWithContextMenu = ...;
...
RadContextMenu ContextMenu = new RadContextMenu();
ContextMenu.ItemClick+=new RadRoutedEventHandler(ContextMenu_ItemClick);
MenuModel menu = new MenuModel();
MenuItemCollection y= menu.Items;
Binding bin = new Binding("Items");
bin.Source = y;
ContextMenu.SetBinding(RadContextMenu.ItemsSourceProperty,bin);
elementWithContextMenu.SetValue(RadContextMenu.ContextMenu, ContextMenu);
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ruty
Top achievements
Rank 1
answered on 11 Jun 2009, 08:21 AM
Thanks,
But I don't understand Why the intention in the line:
DependencyObject elementWithContextMenu = ...;
...
What needs to define there??
Can you give me a example???
Thanks.
But I don't understand Why the intention in the line:
DependencyObject elementWithContextMenu = ...;
...
What needs to define there??
Can you give me a example???
Thanks.
0
Hi ruty,
To use the context menu you need to assign it to an element. When this element is clicked, the context menu will open. For example the following code:
<Rectangle x:Name="rect1">
<telerikNavigation.RadContextMenu.ContextMenu>
<telerikNavigation.RadContextMenu ... >
</telerikNavigation.RadContextMenu.ContextMenu>
</Rectangle>
is equivalent to:
RadContextMenu contextMenu = new RadContextMenu();
...
rect1.SetValue(RadContextMenu.ContextMenu, contextMenu);
Kind regards,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
To use the context menu you need to assign it to an element. When this element is clicked, the context menu will open. For example the following code:
<Rectangle x:Name="rect1">
<telerikNavigation.RadContextMenu.ContextMenu>
<telerikNavigation.RadContextMenu ... >
</telerikNavigation.RadContextMenu.ContextMenu>
</Rectangle>
is equivalent to:
RadContextMenu contextMenu = new RadContextMenu();
...
rect1.SetValue(RadContextMenu.ContextMenu, contextMenu);
Kind regards,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ruty
Top achievements
Rank 1
answered on 11 Jun 2009, 08:48 AM
Thanks,
I assign the context menu to an element (button) thus :
The context menu open empty , ( the binding does not happen.) and in "menu" object have items.(I exam it in debug).
Why???
Thanks,
I assign the context menu to an element (button) thus :
ContextMenu = new RadContextMenu(); |
ContextMenu.ItemClick+=new RadRoutedEventHandler(ContextMenu_ItemClick); |
MenuModel menu = new MenuModel(); |
MenuItemCollection y= menu.Items; |
Binding bin = new Binding("Items"); |
bin.Source = y; |
ContextMenu.SetBinding(RadContextMenu.ItemsSourceProperty,bin); |
but.SetValue(RadContextMenu.ContextMenuProperty, ContextMenu); |
Why???
Thanks,
0
Hi ruty,
can you try with:
ContextMenu = new RadContextMenu();
ContextMenu.ItemClick+=new RadRoutedEventHandler(ContextMenu_ItemClick);
// MenuModel menu = new MenuModel();
// MenuItemCollection y= menu.Items;
// Binding bin = new Binding("Items");
// bin.Source = y;
// ContextMenu..SetBinding(RadContextMenu.ItemsSourceProperty,bin);
ContextMenu.ItemsSource = model.Items;
but.SetValue(RadContextMenu.ContextMenuProperty, ContextMenu);
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
can you try with:
ContextMenu = new RadContextMenu();
ContextMenu.ItemClick+=new RadRoutedEventHandler(ContextMenu_ItemClick);
// MenuModel menu = new MenuModel();
// MenuItemCollection y= menu.Items;
// Binding bin = new Binding("Items");
// bin.Source = y;
// ContextMenu..SetBinding(RadContextMenu.ItemsSourceProperty,bin);
ContextMenu.ItemsSource = model.Items;
but.SetValue(RadContextMenu.ContextMenuProperty, ContextMenu);
All the best,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ruty
Top achievements
Rank 1
answered on 11 Jun 2009, 09:21 AM
I try it,
This is not set binding to the context menu!!!!!!!!!!!
:(
you have more idea for me??
This is not set binding to the context menu!!!!!!!!!!!
:(
you have more idea for me??
0
Hello ruty,
Please, send me your project and I will try to fix it for you. To do that you will have to open a new support ticket and attach the file there.
Greetings,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please, send me your project and I will try to fix it for you. To do that you will have to open a new support ticket and attach the file there.
Greetings,
Valeri Hristov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.