I'm trying to bring an app that was written against 2012.3.1017.40 forward, and I've run up against the dropping of RadDragAndDropManager. So I'm trying to write our stuff to use the new DragDropManager. And I'm having a problem.
We have a grid on which we want drag-and-drop reordering only sometimes. So I've bound RowReorderBehavior.IsEnabled to a property on my viewmodel. And here's the odd thing - it only works to turn RowReorderBehavior on, not off.
I can trace, in the debugger, the property as its value is set, and I can see it raising INotifyPropertyChanged. And if I'm setting it to true, I then trace through RowReorderBehavior.OnIsEnabledPropertyChanged(). But if I set it to false, I'm still raising INotifyPropertyChanged, but RowReorderBehavior.OnIsEnabledPropertyChanged() is never called.
I can replicate this in the Q3 2012 Row Reorder demo.
To RowReorderBehavior.cs, I add the following class:
Then in Example.xaml, I add a static instance to Grid.Resources, create a couple of row definitions, set a checkbox in row 0, move the RadGridView to row 1, then bind Checkbox.IsChecked and RadGridView's RowReorderBehavior.IsEnabled to the static resource:
We have a grid on which we want drag-and-drop reordering only sometimes. So I've bound RowReorderBehavior.IsEnabled to a property on my viewmodel. And here's the odd thing - it only works to turn RowReorderBehavior on, not off.
I can trace, in the debugger, the property as its value is set, and I can see it raising INotifyPropertyChanged. And if I'm setting it to true, I then trace through RowReorderBehavior.OnIsEnabledPropertyChanged(). But if I set it to false, I'm still raising INotifyPropertyChanged, but RowReorderBehavior.OnIsEnabledPropertyChanged() is never called.
I can replicate this in the Q3 2012 Row Reorder demo.
To RowReorderBehavior.cs, I add the following class:
public
class
SortingAllowed : INotifyPropertyChanged
{
public
SortingAllowed()
{
this
.allowSorting =
false
;
}
private
bool
allowSorting_;
public
bool
allowSorting
{
get
{
return
this
.allowSorting_; }
set
{
this
.allowSorting_ = value;
OnPropertyChanged(
"allowSorting"
);
}
}
public
event
PropertyChangedEventHandler PropertyChanged;
private
void
OnPropertyChanged(
string
propertyName)
{
if
(PropertyChanged !=
null
)
PropertyChanged(
this
,
new
PropertyChangedEventArgs(propertyName));
}
}
Then in Example.xaml, I add a static instance to Grid.Resources, create a couple of row definitions, set a checkbox in row 0, move the RadGridView to row 1, then bind Checkbox.IsChecked and RadGridView's RowReorderBehavior.IsEnabled to the static resource:
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"auto"
/>
<
RowDefinition
Height
=
"*"
/>
</
Grid.RowDefinitions
>
<
Grid.Resources
>
<
local:SortingAllowed
x:Key
=
"sortingAllowed"
/>
<
Style
TargetType
=
"telerik:GridViewRow"
x:Key
=
"DraggedRowStyle"
BasedOn
=
"{StaticResource GridViewRowStyle}"
>
<
Setter
Property
=
"telerik:DragDropManager.AllowDrag"
Value
=
"True"
/>
</
Style
>
</
Grid.Resources
>
<
StackPanel
Grid.Row
=
"0"
Orientation
=
"Horizontal"
>
<
CheckBox
IsChecked
=
"{Binding Source={StaticResource sortingAllowed}, Path=allowSorting}"
>Allow sorting</
CheckBox
>
</
StackPanel
>
<
telerik:RadGridView
Grid.Row
=
"1"
x:Name
=
"RadGridView1"
GroupRenderMode
=
"Flat"
ShowGroupPanel
=
"False"
CanUserResizeRows
=
"True"
ItemsSource
=
"{Binding Customers}"
RowStyle
=
"{StaticResource DraggedRowStyle}"
AllowDrop
=
"True"
CanUserSortColumns
=
"False"
local:RowReorderBehavior.IsEnabled
=
"{Binding Source={StaticResource sortingAllowed}, Path=allowSorting}"
telerik:ScrollingSettingsBehavior.IsEnabled
=
"True"
telerik:ScrollingSettingsBehavior.ScrollAreaPadding
=
"30"
telerik:ScrollingSettingsBehavior.ScrollStep
=
"24"
telerik:ScrollingSettingsBehavior.ScrollStepTime
=
"00:00:00.05"
>