I have in my screen a RadGridView and a MaskedNumericInput, there is an option to add new rows in the grid, when i add a new row/change cell which is required, you cannot take the focuse out of the grid while there are validation errors, BUT - if there is a MaskedNumericInput which value is zero - when i try clicking it in the prevous situation, all UI freezes!
please advise! it is URGENT!
I put bellow the code and xaml:
Thanks,
Rachel.
13 Answers, 1 is accepted
Unfortunately I am not able to find any code in your post. Please make sure the code is in your post before resending it.
Regards,
Pavel R. Pavlov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using Telerik.Windows.Controls.MaskedInput;
namespace WpfApplication6
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private Person _person;
public Person Person
{
get { return _person; }
set { _person = value; }
}
private List<Person> _myList;
public List<Person> MyList
{
get { return _myList; }
set { _myList = value; }
}
public MainWindow()
{
Person = new Person() {ID=0 };
MyList = new List<Person>() ;
MyList.Add(new Person() { ID = 9, Name = "Rachel" });
InitializeComponent();
This.DataContext = this;
}
}
public class Person
{
[Required]
[DisplayName("ID")]
public int ID { get; set; }
[DisplayName("Name")]
[Required]
public string Name { get; set; }
}
}
<Window x:Class="WpfApplication6.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maskedInput="clr-namespace:Telerik.Windows.Controls.MaskedInput;assembly=Telerik.Windows.Controls.Input"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Name="This"
xmlns:local="clr-namespace:WpfApplication6"
Title="MainWindow" >
<StackPanel Name="MyStack">
<telerik:RadGridView ItemsSource="{Binding MyList,Mode=TwoWay}" CanUserDeleteRows="True" CanUserInsertRows="True" ShowInsertRow="True" AutoGenerateColumns="True"/>
<telerik:RadMaskedNumericInput maskedInput:MaskedInputExtensions.Maximum="10" maskedInput:MaskedInputExtensions.Minimum="0" Value="{Binding Person.ID}" Margin="20" SelectionOnFocus="Default"/>
</StackPanel>
</Window>
Thank you for elaborating. I now understand your scenario. I guess you report the fact that the RadGridView does not allow you to switch the focus to another cell when there is an error in the currently edited one. Please note this behavior is the designed and expected one. It is due to the validation itself.
The behavior in such scenarios can be adjusted using the ValidatesOnDataErrors property. If you set it to InViewMode you will be able to move the focus. Please give it a try and let us know if you need any further assistance.
Regards,
Pavel R. Pavlov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I know that i cannot switch the focus, and i want it to behave like that.
but in the case above i described that when trying to move the focus to a numeric textbox with value 0, the whole UI freezes!
this is a bug! not a wanted behavior!
I could not reproduce the issue on our side. Please take a look at this screencast to see the performance on our side with our latest official release. Also, I am sending you the project that I tested the behavior with. Can you reproduce the reported issue in it? If you can I would like you to specify the steps that you take to reproduce the reported issue.
If however you are not able to break the code I will kindly ask you to change the code so that the issue can reproduced and send it over. This will allow us to reproduce and investigate the issue on our side.
Regards,
Pavel R. Pavlov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Thank you for this detail. We managed to reproduce the issue by setting ValidatesOnDataErrors ="IsInEditMode". We have currently worked on this issue but did not manage to resolve it. When the cell value is invalid and you try to unfocus the gridview with clicking in the MaskedInput, the focus constantly moves between the two controls because they both need the focus and they are both in a single focus scope.
As a workaround you can set FocusManager.IsFocusScope = True on the MaskedControl to split the controls in different focus scopes.
<
telerik:RadMaskedNumericInput
Margin
=
"20"
SelectionOnFocus
=
"Default"
maskedInput:MaskedInputExtensions.Maximum
=
"10"
maskedInput:MaskedInputExtensions.Minimum
=
"0"
Value
=
"{Binding Person.ID}"
FocusManager.IsFocusScope
=
"True"
/>
We hope this is applicable in your scenario.
Regards,
Petar Mladenov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
but when i set the FocusManager.IsFocusScope="True" the value doesn't update the binded property when changed! worse than before!
We tried to reproduce this issue on our side but we did not succeed.
Please find in the attached project the following configuration. The ID of the Person i bound both in the Mask and in the GridView's first cell (first column first row). When you type in the cell or in the Mask number between 1 and 10, the value is updated in both controls. Please let us know if we have missed something.
Regards,
Petar Mladenov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
We managed to reproduce this with UpdateValueEvent = LostFocus. Separating focus scopes won't do the job here - the lost focus of the MaskedInput won't be fired at all and the values won't be updated. Is the LostFocus updating a mandatory deisgn requirement for you. Is changing it to PropertyChanged an option for you ? Same for the ValidatesOnDataErrors mode - is this mandatory in your scenario ? Currently we are not aware of any elegant solution for this particular case. Going in the way with any workaround is also risky - we may miss a use case and this might require additional workarounds and so on.
Regards,
Petar Mladenov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Any update? it is very very Urgent!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
It also happens when navigating between 2 GridViews ( which have validations)
When GridView's cell is in invalid validation state and you try to move the focus out of the GridView, the control tries to get the focus again in order to finish the edit mode. We have made a decision to decline the bugs in which the ui hangs because of this focusing behavior.
In your particular scenario, you can try to cancel the editing of the GridView when you click on a control outside the GridView, for example you can use PreviewMouseLeftButtonDownEvent like so:
private
void
maskedInput_PreviewMouseLeftButtonDown_1(
object
sender, MouseButtonEventArgs e)
{
this
.gridView.CancelEdit();
}
This way when you move the focus out of invalid gridview cell in edit mode, canceling the edit mode will revert the last know valid value. We think this a good way to go in most scenarios.
Regards,
Petar Mladenov
Telerik