This question is locked. New answers and comments are not allowed.
Hello Telerik,
MY treeview controlo is databound to colleciton of objects.
I would like to disable leaving the edit mode when some condition is fullfiled.
PreviewEdit
e.handled = true
is not working.
Do you have any tips?
When the edited item is losing focus and previewEdit handler is called but e.Handled = true does NOT working. The edit mode is terminated.
I have tried also this:
IsInEdit mode is databound to IsInEditMode property of RadTreeViewItem.
The purpose of the first method is to disable terminating of the edit mode.
The purpose of the second method is to disable unselect the selected and edited item.
The problem is that the PreviewEdit is never fired again. Only for the first time. So when my validation is ok, there is constantly EditItemTemplate and not normal ItemTemplate. Also when I am editing another items there is no PreviewEdit event too.
IsInEditMode is databound using this style (twoWay binding):
Thanks Tom
MY treeview controlo is databound to colleciton of objects.
I would like to disable leaving the edit mode when some condition is fullfiled.
PreviewEdit
e.handled = true
is not working.
Do you have any tips?
When the edited item is losing focus and previewEdit handler is called but e.Handled = true does NOT working. The edit mode is terminated.
I have tried also this:
IsInEdit mode is databound to IsInEditMode property of RadTreeViewItem.
private void contextorTreeView_Edited(object sender, RadTreeViewItemEditedEventArgs e)
{
VmContext tmpContext;
if ((sender as RadTreeView).SelectedItem is VmContext)
{
tmpContext = (sender as RadTreeView).SelectedItem as VmContext;
tmpContext.Validate();
if (tmpContext.HasErrors)
{
tmpContext.IsInEditMode = true;
}
}
}
private void contextorTreeView_PreviewSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
if (e.RemovedItems.Count > 0 && (e.RemovedItems[0] is VmContext) && (e.RemovedItems[0] as VmContext).IsInEditMode == true && (e.RemovedItems[0] as VmContext).Deleted == false)
{
(e.RemovedItems[0] as VmContext).Validate();
if ((e.RemovedItems[0] as VmContext).HasErrors)
{
e.Handled = true;
(sender as RadTreeView).SelectedItem = e.RemovedItems[0];
}
}
}
The purpose of the second method is to disable unselect the selected and edited item.
The problem is that the PreviewEdit is never fired again. Only for the first time. So when my validation is ok, there is constantly EditItemTemplate and not normal ItemTemplate. Also when I am editing another items there is no PreviewEdit event too.
IsInEditMode is databound using this style (twoWay binding):
<
Style
x:Key
=
"contextContainerStyle"
TargetType
=
"telerik:RadTreeViewItem"
>
<
Setter
Property
=
"IsInEditMode"
Value
=
"{Binding IsInEditMode,Mode=TwoWay}"
/>
<
Setter
Property
=
"IsExpanded"
Value
=
"True"
/>
</
Style
>
Thanks Tom