Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
XamMaskedEditor not binding when used inside a XamGrid with a CustomColumn
posted

We had a requirement to use xammaskededitor inside a xamgrid . For this I   added a customcolumn  which has a displaycontrol as a textblock and the editor control as the Xammaskededitor control.

For some reason in edit mode , when the user empties the values for eg : no value ,  which is equivalent to "__/__/__" according to my mask the  under lying View model is not getting updated properyly. If i change it a valid value I can see the view model getting updated and the cell gets updated to the new value.But the problem comes when  the user wants to have an empty date value, the cell is retaining the old value because the view model newver gets updated in those scenarios?

I followed the apporach here to add the custom column to the grid.

http://blogs.infragistics.com/blogs/devin_rader/archive/2010/07/08/creating-custom-columns-for-xamgrid.aspx

To Reproduce:

1.Create a xamgrid.bind it to a view model

2. Add a customcolumn to the grid which has TextBlock as the displaycontrol and the XamMaskEditor as the editor control.Bind it two way to the view model.

3. When the user empties the text, the view model is not updated and the cell retains the old value.When the value is set to a valid  value it behaves properly.

(I also noticed that when the XamEditor is used as regular control on the form it behaves properly)

 

 

Parents
  • 6759
    Offline posted

    Hi,

    if you want to display date it might be better to use DateColumn.

    If DateColumnis not an option for you and XamMaskedEditor has to be used you might want to use TemplateColumn. Here is sample xaml:

    <ig:TemplateColumn Key="DateProperty">
        <ig:TemplateColumn.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding DateProperty}" />
            </DataTemplate>
        </ig:TemplateColumn.ItemTemplate>				
    	<ig:TemplateColumn.EditorTemplate>
    		<DataTemplate>
                <ig:XamMaskedEditor Width="100"
                                    Height="20"
                                    Culture="en-US"
                                    Mask="##/##/####"
                                    Text="{Binding DateProperty, Mode=TwoWay}"/>
    		</DataTemplate>
        </ig:TemplateColumn.EditorTemplate>
    </ig:TemplateColumn>
    

    Note that the XamMaskedEditor setup from the snippet might not match your scenario exactly but the point is to illustrate the approach.

    Custom column is supposed to be used used in more complex scenarios that are not achievable through TemplateColumn or UnboundColumn or if you the column is going to be widely used.

    However if you need the custom column solution to work I will need a sample solution or at least some code snippets of the ResolveEditorElement of the custom column so I can look into the issue.

    HTH,

Reply Children