Hi,
I have a RadTreeView *within* a UserControl which I am using from a regular XAML Page.
When I use "RadDragAndDropManager.SetAllowDrag(myUserControl, true);" I'm notified of the drag event successfully.
Obviously this is a bit silly as I don't want to detect dragging the UserControl, I really want to detect dragging tree nodes. So, the question is how do I use SetAllowDrag for each tree node?
I have exposed the node collection publicly and tried iterating through an using SetAllowDrag, but I'm not sure if this is an good method. Also, each node is an object which isn't currently derived from DependencyObject. When I DO derive from DependencyObject I get a XAML error at runtime.
Any ideas?
Paul.
I have a RadTreeView *within* a UserControl which I am using from a regular XAML Page.
When I use "RadDragAndDropManager.SetAllowDrag(myUserControl, true);" I'm notified of the drag event successfully.
Obviously this is a bit silly as I don't want to detect dragging the UserControl, I really want to detect dragging tree nodes. So, the question is how do I use SetAllowDrag for each tree node?
I have exposed the node collection publicly and tried iterating through an using SetAllowDrag, but I'm not sure if this is an good method. Also, each node is an object which isn't currently derived from DependencyObject. When I DO derive from DependencyObject I get a XAML error at runtime.
Any ideas?
Paul.
8 Answers, 1 is accepted
0
Hello Paul,
As I understand, you are binding the TreeView. Then there is no need to iterate over the items collection. You need to set the property to the item container wrappers over your objects, which is easy with the ItemContainerStyle property of the TreeView. The property is inherited, so you need to set it only once.
The interesting thing here is that you can set attached properties in styles:
Hopefully this will work in your scenario,
Regards,
Miroslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
As I understand, you are binding the TreeView. Then there is no need to iterate over the items collection. You need to set the property to the item container wrappers over your objects, which is easy with the ItemContainerStyle property of the TreeView. The property is inherited, so you need to set it only once.
The interesting thing here is that you can set attached properties in styles:
<nav:RadTreeView x:Name="treeView" |
ItemTemplate="{StaticResource myItemTemplate}"> |
<nav:RadTreeView.ItemContainerStyle> |
<Style TargetType="nav:RadTreeViewItem"> |
<Setter |
Property="dragDrop:RadDragAndDropManager.AllowDrag" |
Value="True" /> |
</Style> |
</nav:RadTreeView.ItemContainerStyle> |
</nav:RadTreeView> |
Hopefully this will work in your scenario,
Regards,
Miroslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Paul Cook
Top achievements
Rank 1
answered on 01 Apr 2009, 04:55 PM
But can this be done from Page.xaml when the RadTreeView is embedded within a user control within a different assembly?
0
Paul Cook
Top achievements
Rank 1
answered on 02 Apr 2009, 02:30 PM
Let me be a bit more descriptive:
I have a control called CategoryTree.xaml which is located in *another assembly*. This control is structured as:
<UserControl>
<Grid>
<telerik:RadTreeView>
I can reference this assembly and I can place this control on my page, but I now need to enable draganddrop from this control to another control on my page.
The question is how can I use RadDragAndDropManger to set CategoryTree (or, more precisley, the RadTreeView items) as the drag source? Can this even be done?
I'm guessing I need to somehow expose the RadTreeView as a property?!? Is it a dependency property?!?! I'm coming from an ASP.NET background so I'm not yet thinking the Silverlight way yet!
Paul.
I have a control called CategoryTree.xaml which is located in *another assembly*. This control is structured as:
<UserControl>
<Grid>
<telerik:RadTreeView>
I can reference this assembly and I can place this control on my page, but I now need to enable draganddrop from this control to another control on my page.
The question is how can I use RadDragAndDropManger to set CategoryTree (or, more precisley, the RadTreeView items) as the drag source? Can this even be done?
I'm guessing I need to somehow expose the RadTreeView as a property?!? Is it a dependency property?!?! I'm coming from an ASP.NET background so I'm not yet thinking the Silverlight way yet!
Paul.
0
Hello Paul,
Sorry for the delayed reply!
The appropriate Silverlight application model is a bit different than asp.net, but I am sure that you will quickly start feeling at home with it.
Some of the differences are attached properties and routed events. Generally it is best to have DataObjects which represent your data, ViewModels which are very much alike the DataItems, but have extra logic and properties that are not part of the DataModel.
Then the UI elements will wrap around and bind to the ViewModels.
You indeed do not need to inherit the DependencyObject, in fact it is best not to.
Since the RadTreeView is data bound, you can use the ItemContainerStyle to set properties to the container (the wrapping RadTreeViewItem). So could you try the suggested xaml addition for the tree view you want to make draggable:
This xaml sets the AllowDrag attached property to all the TreeViewItems of the TreeView.
It this will make sure that routed events start travelling from the TreeViewItems to the application root visual and you can handle them anywhere you like, even in its parent UserControl from another assembly.
If you need more help with this, please come back to us.
Sincerely yours,
Miroslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Sorry for the delayed reply!
The appropriate Silverlight application model is a bit different than asp.net, but I am sure that you will quickly start feeling at home with it.
Some of the differences are attached properties and routed events. Generally it is best to have DataObjects which represent your data, ViewModels which are very much alike the DataItems, but have extra logic and properties that are not part of the DataModel.
Then the UI elements will wrap around and bind to the ViewModels.
You indeed do not need to inherit the DependencyObject, in fact it is best not to.
Since the RadTreeView is data bound, you can use the ItemContainerStyle to set properties to the container (the wrapping RadTreeViewItem). So could you try the suggested xaml addition for the tree view you want to make draggable:
<nav:RadTreeView.ItemContainerStyle> |
<Style TargetType="nav:RadTreeViewItem"> |
<Setter |
Property="dragDrop:RadDragAndDropManager.AllowDrag" |
Value="True" /> |
</Style> |
</nav:RadTreeView.ItemContainerStyle> |
This xaml sets the AllowDrag attached property to all the TreeViewItems of the TreeView.
It this will make sure that routed events start travelling from the TreeViewItems to the application root visual and you can handle them anywhere you like, even in its parent UserControl from another assembly.
If you need more help with this, please come back to us.
Sincerely yours,
Miroslav
the Telerik team
Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Paul Cook
Top achievements
Rank 1
answered on 15 Apr 2009, 02:37 PM
Hi Miroslav,
I'm finally getting the hang of this. I have started out with two listboxes and can drag listitems between them having used attatched properties to hook the dragdrop functionality.
The thing is that my application the treeview is in a usercontrol. How can I use attached properties to attach to tree items externally, from the page?
eg. I need to drag items from RadTreeView below into DropTarget (another 3rd party control)
<Page>
<UserControl>
<Grid>
<telerik:RadTreeView>
</Grid>
</UserControl>
<DropTarget />
Paul.
0
Accepted
Hello Paul Cook,
Attached, you can find en example demonstrating the structure described in your post. Actually, this is a modification of the FirstLook example from our online demos - the left DraggableListBox is separated in a standalone UserControl which is finally placed at the list box's place. In-depth information is available in the RadControls for Silverlight 2 - Drag and Drop Basics article.
Please give it a try and let me know does it cover your needs.
Greetings,
Ivan
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.
Attached, you can find en example demonstrating the structure described in your post. Actually, this is a modification of the FirstLook example from our online demos - the left DraggableListBox is separated in a standalone UserControl which is finally placed at the list box's place. In-depth information is available in the RadControls for Silverlight 2 - Drag and Drop Basics article.
Please give it a try and let me know does it cover your needs.
Greetings,
Ivan
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
Sergey dsa
Top achievements
Rank 1
answered on 17 Sep 2010, 10:05 PM
Hi!
Is there possibility to disable drag and dropping inside (within) Silverlight RadScheduler, specifically within TimeLine Definition? I have tried that way:
<Style x:Key="TimelineTimeSlotStyle" TargetType="telerikScheduler:TimeSlotItem">
<Setter Property="telerikDragDrop:RadDragAndDropManager.AllowDrag" Value="False" />
But it does not work for me..
Thanks.
Is there possibility to disable drag and dropping inside (within) Silverlight RadScheduler, specifically within TimeLine Definition? I have tried that way:
<Style x:Key="TimelineTimeSlotStyle" TargetType="telerikScheduler:TimeSlotItem">
<Setter Property="telerikDragDrop:RadDragAndDropManager.AllowDrag" Value="False" />
But it does not work for me..
Thanks.
0
Hi Sergey dsa,
Please refer to the following article from our help section:
http://www.telerik.com/help/silverlight/schedulerdraganddrop.html
It describes how you can manipulate drag and drop of appointments within RadScheduler.
Hope this will be of use. Let us know if you need further assistance.
All the best,
Teodor
the Telerik team
Please refer to the following article from our help section:
http://www.telerik.com/help/silverlight/schedulerdraganddrop.html
It describes how you can manipulate drag and drop of appointments within RadScheduler.
Hope this will be of use. Let us know if you need further assistance.
All the best,
Teodor
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