Hello,
I'm having trouble with the RadDragAndDropManager when the UserControl that is using it is being hosted inside of a Windows Form. I made a quick example.
seems to work fine inside of a wpf Window but not a Form.
Any ideas on what I'm doing wrong?
Thanks much,
~Boots
I'm having trouble with the RadDragAndDropManager when the UserControl that is using it is being hosted inside of a Windows Form. I made a quick example.
<UserControl x:Class="DragAndDropTest.simple" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:dragDrop="clr-namespace:Telerik.Windows.Controls.DragDrop;assembly=Telerik.Windows.Controls"> |
<UserControl.Resources> |
<Style TargetType="StackPanel"> |
<Setter Property="dragDrop:RadDragAndDropManager.AllowDrop" Value="True" /> |
</Style> |
<Style TargetType="Label"> |
<Setter Property="dragDrop:RadDragAndDropManager.AllowDrag" Value="True" /> |
</Style> |
</UserControl.Resources> |
<Grid> |
<Grid.ColumnDefinitions> |
<ColumnDefinition /> |
<ColumnDefinition /> |
</Grid.ColumnDefinitions> |
<StackPanel |
Name="Stack1" |
Grid.Column="0"> |
<Label Name="lbl1" Background="Green" /> |
</StackPanel> |
<StackPanel |
Name="Stack2" |
Grid.Column="1"> |
<Label Name="lbl2" Background="Red" /> |
</StackPanel> |
</Grid> |
</UserControl> |
using System; |
using System.Collections.Generic; |
using System.Linq; |
using System.Text; |
using System.Windows; |
using System.Windows.Controls; |
using System.Windows.Data; |
using System.Windows.Documents; |
using System.Windows.Input; |
using System.Windows.Media; |
using System.Windows.Media.Imaging; |
using System.Windows.Navigation; |
using System.Windows.Shapes; |
using Telerik.Windows.Controls.DragDrop; |
namespace DragAndDropTest |
{ |
/// <summary> |
/// Interaction logic for simple.xaml |
/// </summary> |
public partial class simple : UserControl |
{ |
public simple() |
{ |
InitializeComponent(); |
RadDragAndDropManager.AddDragInfoHandler(lbl1, OnDragInfo); |
RadDragAndDropManager.AddDragQueryHandler(lbl1, OnDragQuery); |
RadDragAndDropManager.AddDragInfoHandler(lbl2, OnDragInfo); |
RadDragAndDropManager.AddDragQueryHandler(lbl2, OnDragQuery); |
RadDragAndDropManager.AddDropInfoHandler(Stack1, OnDropInfo); |
RadDragAndDropManager.AddDropQueryHandler(Stack1, OnDropQuery); |
RadDragAndDropManager.AddDropInfoHandler(Stack2, OnDropInfo); |
RadDragAndDropManager.AddDropQueryHandler(Stack2, OnDropQuery); |
} |
private void OnDropQuery(object sender, DragDropQueryEventArgs e) |
{ |
e.QueryResult = true; |
e.Handled = true; |
} |
private void OnDropInfo(object sender, DragDropEventArgs e) |
{ |
if (e.Options.Status == DragStatus.DropComplete) |
{ |
((e.Options.Source as Label).Parent as StackPanel).Children.Remove(e.Options.Source); |
(sender as StackPanel).Children.Add(e.Options.Source); |
} |
} |
private void OnDragInfo(object sender, DragDropEventArgs e) |
{ |
Label item = sender as Label; |
if (e.Options.Status == DragStatus.DragInProgress) |
{ |
ContentControl cue = new ContentControl(); |
cue.Content = new Label() { Background = item.Background }; |
e.Options.DragCue = cue; |
e.Options.ArrowCue = RadDragAndDropManager.GenerateArrowCue(); |
} |
} |
private void OnDragQuery(object sender, DragDropQueryEventArgs e) |
{ |
e.Options.Payload = sender; |
e.QueryResult = true; |
e.Handled = true; |
} |
} |
} |
using System; |
using System.Collections.Generic; |
using System.ComponentModel; |
using System.Data; |
using System.Drawing; |
using System.Linq; |
using System.Text; |
using System.Windows.Forms; |
namespace DragAndDropTest |
{ |
public partial class Form1 : Form |
{ |
public Form1() |
{ |
InitializeComponent(); |
elementHost1.Child = new simple(); |
} |
} |
} |
seems to work fine inside of a wpf Window but not a Form.
Any ideas on what I'm doing wrong?
Thanks much,
~Boots