hi,
1) I've created WPF UserControl that contains three RadAutoCompleteBox's.
I want to drag and drop items from one searchbox to another within the wpf control.
I've tried setting AllowDrop="true", DragEnter="autocompletebox_DragEnter", DragLeave="autocompletebox_DragLeave"
and nothing happens.., (it's doesn't enter the events methods). what do i missing?
2) And another question, The DropDown ItemsSource is binded to a list: List<INameWithIcon> EntityList.
I want to show both icon and name in the DropDown AND in the searchbox.
that is part of what i've defined-
TextSearchPath="Name"
DropDownItemTemplate="{StaticResource EntitySearchTemplate}"
<DataTemplate x:Key="EntitySearchTemplate">
<StackPanel Orientation="Horizontal">
<Border>
<Image Source="{Binding Path=IconPath}" />
</Border>
<TextBlock Text="{Binding Path=Name}" Style="{StaticResource AutoCompleteStyle}" Margin="10 0 0 0"/>
</StackPanel>
</DataTemplate>
1) I've created WPF UserControl that contains three RadAutoCompleteBox's.
I want to drag and drop items from one searchbox to another within the wpf control.
I've tried setting AllowDrop="true", DragEnter="autocompletebox_DragEnter", DragLeave="autocompletebox_DragLeave"
and nothing happens.., (it's doesn't enter the events methods). what do i missing?
2) And another question, The DropDown ItemsSource is binded to a list: List<INameWithIcon> EntityList.
I want to show both icon and name in the DropDown AND in the searchbox.
that is part of what i've defined-
TextSearchPath="Name"
DropDownItemTemplate="{StaticResource EntitySearchTemplate}"
<DataTemplate x:Key="EntitySearchTemplate">
<StackPanel Orientation="Horizontal">
<Border>
<Image Source="{Binding Path=IconPath}" />
</Border>
<TextBlock Text="{Binding Path=Name}" Style="{StaticResource AutoCompleteStyle}" Margin="10 0 0 0"/>
</StackPanel>
</DataTemplate>
4 Answers, 1 is accepted
0
Hello Itsik,
You will be able to achieve the desired behavior with our DragDropManager. Firstly you will need to set the telerik:DragDropManager.AllowCapturedDrag of the StackPanel in the DataTemplate to true in order to be able to drag the items and after that you will have to attach DragInitialize, Drop and DragDropCompleted events to the AutoCompleteBoxes in order to implement the functionality. I'm attaching a sample project which demonstrates the exact approach. You could also check the DragDropManager section from our online help documentation. As for the template of the items in the search box you need set the BoxesItemTemplate of the AutoCompleteBox (I also have done that in the example project).
Hope this helps.
Regards,
Kalin
Telerik
You will be able to achieve the desired behavior with our DragDropManager. Firstly you will need to set the telerik:DragDropManager.AllowCapturedDrag of the StackPanel in the DataTemplate to true in order to be able to drag the items and after that you will have to attach DragInitialize, Drop and DragDropCompleted events to the AutoCompleteBoxes in order to implement the functionality. I'm attaching a sample project which demonstrates the exact approach. You could also check the DragDropManager section from our online help documentation. As for the template of the items in the search box you need set the BoxesItemTemplate of the AutoCompleteBox (I also have done that in the example project).
Hope this helps.
Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Itsik
Top achievements
Rank 1
answered on 20 Jan 2014, 03:09 PM
Hi Kalin.
Your example was usefull, I have learned alot.
Two comments:
1) In my case, I have separete WPF User Control ("AutoControl") that hosts only the RadAutoCompleteBox.
In addition, I have "MainControl" that hosts three AutoControls. Do i need to implement the logic of the drag&drop in the AutoControl
Or in the MainControl? I have tried to add all the logic on the AutoControl, and it doesn't work well..
This is the xaml of the AutoControl
2) I see it's not a simple thing to achieve the Drag&Drop behavior on that control. did you considered (maybe in the future) to embed that behavior within the control? (instead of using the Drag&DropManager)
Thanks
Your example was usefull, I have learned alot.
Two comments:
1) In my case, I have separete WPF User Control ("AutoControl") that hosts only the RadAutoCompleteBox.
In addition, I have "MainControl" that hosts three AutoControls. Do i need to implement the logic of the drag&drop in the AutoControl
Or in the MainControl? I have tried to add all the logic on the AutoControl, and it doesn't work well..
This is the xaml of the AutoControl
<
UserControl
x:Class
=
"MyProject1.AutoControl"
mc:Ignorable
=
"d"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
d:DesignHeight
=
"22"
d:DesignWidth
=
"300"
DataContext
=
"{Binding RelativeSource={RelativeSource Self}}"
>
<
UserControl.Resources
>
<
ResourceDictionary
>
<
DataTemplate
x:Key
=
"EntitySearchTemplate"
>
<
StackPanel
Orientation
=
"Horizontal"
telerik:DragDropManager.AllowCapturedDrag
=
"True"
>
<
Border
>
<
Image
Source
=
"{Binding Path=IconPath}"
/>
</
Border
>
<
TextBlock
Text
=
"{Binding Path=Name}"
Style
=
"{StaticResource AutoCompleteStyle}"
Margin
=
"10 0 0 0"
/>
</
StackPanel
>
</
DataTemplate
>
<
ResourceDictionary.MergedDictionaries
>
<
ResourceDictionary
Source
=
"/MyProject1.Common;component/Resources/Styles.xaml"
/>
</
ResourceDictionary.MergedDictionaries
>
</
ResourceDictionary
>
</
UserControl.Resources
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"3*"
/>
<
ColumnDefinition
Width
=
"10*"
/>
</
Grid.ColumnDefinitions
>
<
Border
Grid.Column
=
"0"
>
<
Button
Grid.Row
=
"1"
VerticalAlignment
=
"Top"
Name
=
"buttonAdvancedSearch"
Background
=
"{StaticResource Purple}"
FontSize
=
"12"
Click
=
"ButtonAdvancedSearchClick"
Foreground
=
"{StaticResource WhiteSmoke}"
<Viewbox
StretchDirection
=
"Both"
Stretch
=
"None"
>
<
TextBlock
Text
=
"{Binding ButtonContent}"
TextWrapping
=
"Wrap"
/>
</
Viewbox
>
</
Button
>
</
Border
>
<
telerik:RadAutoCompleteBox
VerticalAlignment
=
"Top"
x:Name
=
"autocompletebox"
Grid.Column
=
"1"
SelectionChanged
=
"autocompletebox_SelectionChanged"
SelectedItems
=
"{Binding Path=SelectedEntites, Mode=TwoWay}"
Margin
=
"15 0 0 0"
SelectionMode
=
"{Binding Path=SelectionMode}"
WatermarkContent
=
"{Binding Path=WatermarkContent}"
TextSearchMode
=
"{Binding Path=TextSearchMode}"
TextSearchPath
=
"Name"
MaxHeight
=
"60"
IsHighlighted
=
"True"
FlowDirection
=
"LeftToRight"
AutoCompleteMode
=
"{Binding Path=AutoCompleteMode}"
ItemsSource
=
"{Binding Path=EntityList, Mode=TwoWay}"
ScrollViewer.VerticalScrollBarVisibility
=
"Auto"
ScrollViewer.CanContentScroll
=
"True"
DropDownItemTemplate
=
"{StaticResource EntitySearchTemplate}"
AllowDrop
=
"True"
BoxesItemTemplate
=
"{StaticResource EntitySearchTemplate}"
PreviewDragOver
=
"AutocompletePreviewDragOver"
>
</
telerik:RadAutoCompleteBox
>
</
Grid
>
</
UserControl
>
2) I see it's not a simple thing to achieve the Drag&Drop behavior on that control. did you considered (maybe in the future) to embed that behavior within the control? (instead of using the Drag&DropManager)
Thanks
0
Hi Itsik,
For the explained scenario you will need to implement the DragDrop logic only for the UserControl. Afterwards the whole logic will work for every instance of the UserControl. I have modified the project in order to demonstrate the exact approach for the scenario.
As for the second question I would like to thank you for your feedback. We haven't considered including such a behavior as it is really case specific and the desired functionally can be quickly implemented using the DragDropManager. For more information about the DragDropManager you can check this section from our online help documentation.
Hope this helps.
Regards,
Kalin
Telerik
For the explained scenario you will need to implement the DragDrop logic only for the UserControl. Afterwards the whole logic will work for every instance of the UserControl. I have modified the project in order to demonstrate the exact approach for the scenario.
As for the second question I would like to thank you for your feedback. We haven't considered including such a behavior as it is really case specific and the desired functionally can be quickly implemented using the DragDropManager. For more information about the DragDropManager you can check this section from our online help documentation.
Hope this helps.
Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0

Itsik
Top achievements
Rank 1
answered on 28 Jan 2014, 02:17 PM
Thanks :)
it's working
it's working