Hi!
I've a tree(representing a folder/file tree). I want to add a contextMenu only on "Folder" element
On all my "INodeElement", I've a property "IsFolder".
How to do that the contextMenu is only displayed when this property is true?
OR
How to have a different contextMenu depending of this property?
Thank you!
I've a tree(representing a folder/file tree). I want to add a contextMenu only on "Folder" element
On all my "INodeElement", I've a property "IsFolder".
How to do that the contextMenu is only displayed when this property is true?
OR
How to have a different contextMenu depending of this property?
Thank you!
9 Answers, 1 is accepted
0
Hello Julien,
With our next minor release we will upload such an example on our QSF, but you can see it now from the attached sample project. It is not exactly the same scenario, but the same idea. If you have further questions feel free to ask.
All the best,
Viktor Tsvetkov
the Telerik team
With our next minor release we will upload such an example on our QSF, but you can see it now from the attached sample project. It is not exactly the same scenario, but the same idea. If you have further questions feel free to ask.
All the best,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Julien
Top achievements
Rank 1
answered on 26 Aug 2010, 02:29 PM
It seems I cannot open it because it's a silverlight project and not wpf. I get errors about silverlight on load
0
Hi Julien,
Attached is the example in WPF. Examine it and tell me if it works for you.
Kind regards,
Viktor Tsvetkov
the Telerik team
Attached is the example in WPF. Examine it and tell me if it works for you.
Kind regards,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Julien
Top achievements
Rank 1
answered on 26 Aug 2010, 02:59 PM
Very interessant:
But:
-How the template selector choose the correct template?
-We are trying to avoid all graphic code in the code behind, how can we create different menus like you do but in xaml side?
But:
-How the template selector choose the correct template?
-We are trying to avoid all graphic code in the code behind, how can we create different menus like you do but in xaml side?
0
Hi Julien,
- In the example that I sent to you the template selector chooses the template based on the type of the file. You can find more info about ItemTemplateSelector here.
- In this case you can define the ItemContainerStyle property of the RadTreeView this way:
If you need more help I will be glad to further assist you.
Best wishes,
Viktor Tsvetkov
the Telerik team
- In the example that I sent to you the template selector chooses the template based on the type of the file. You can find more info about ItemTemplateSelector here.
- In this case you can define the ItemContainerStyle property of the RadTreeView this way:
<
Style
x:Key
=
"treeViewStyle"
TargetType
=
"telerik:RadTreeViewItem"
>
<
Style.Triggers
>
<
DataTrigger
Binding
=
"{Binding Path=IsFolder}"
Value
=
"True"
>
<
Setter
Property
=
"telerik:RadContextMenu.ContextMenu"
>
<
Setter.Value
>
<!--Your custom context menu-->
<
telerik:RadContextMenu
/>
</
Setter.Value
>
</
Setter
>
</
DataTrigger
>
</
Style.Triggers
>
</
Style
>
Best wishes,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Julien
Top achievements
Rank 1
answered on 27 Aug 2010, 10:22 AM
It seems great,
But I've some event, and I have to create EventSetter. For my "Opened" on RadContextMenu, there is no problem, but I've "Click" event on each RadMenuItem. How to set a different handler for each RadMenuItem with an EventSetter?
And it seems I cannot reach anymore my menu from the code behind by its name:
But I've some event, and I have to create EventSetter. For my "Opened" on RadContextMenu, there is no problem, but I've "Click" event on each RadMenuItem. How to set a different handler for each RadMenuItem with an EventSetter?
And it seems I cannot reach anymore my menu from the code behind by its name:
RadTreeViewItem radItem = uxContextualMenu.GetClickedElement<RadTreeViewItem>();
0
Hello Julien,
Instead of setting a different event handler you can set a different command on each RadMenuItem. Could you please examine the modified project and tell me if it works for you?
Best wishes,
Viktor Tsvetkov
the Telerik team
Instead of setting a different event handler you can set a different command on each RadMenuItem. Could you please examine the modified project and tell me if it works for you?
Best wishes,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Julien
Top achievements
Rank 1
answered on 01 Sep 2010, 06:34 AM
it seems this is what I need.
But why it doesn't show the menu on any node this isn't a leaf? in my case, it's a recursive tree, so I need to have this menu on every node
But why it doesn't show the menu on any node this isn't a leaf? in my case, it's a recursive tree, so I need to have this menu on every node
0
Hi Julien,
In this sample project the context menu is shown only if the item has a property IsCodeBehindFile. In your case you will set the trigger on the IsFolder property and every item will have such property, so you will have your custom context menu on every item.
All the best,
Viktor Tsvetkov
the Telerik team
In this sample project the context menu is shown only if the item has a property IsCodeBehindFile. In your case you will set the trigger on the IsFolder property and every item will have such property, so you will have your custom context menu on every item.
All the best,
Viktor Tsvetkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items