I have a XamMaskedEditor for phone number. When there is no number entered, it leaves back literals(--) in the TextBlock. With options of DisplayMode to Raw or IncludePromtChars, there is no change in the behavior. How to empty the textblock, if no number is typed?
Thanks in advance.
Hello,
I am just checking if you require any further assistance on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Hello Gayathri,
Thank you for your reply. I have been looking into the xaml that you have provided and you have two TemplateColumns with different EditorTemplates, which needs to be handled differently in the event. Would you please provide me with the code for the CellExitingEditMode event of the XamGrid, so I can research what might be causing the issue?
Looking forward to hearing from you.
Thank you for the reply. Below is my usercontrol page structure.
I get nullreference again.
<UserControl x:Class="Debi.Sl.Rock.Views.Company.PhoneNumbersView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Controls="clr-namespace:Debi.Sl.Rock.Controls" xmlns:design="clr-namespace:Debi.Sl.Rock.DesignerViewModels.Company" xmlns:sdk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:Converters="clr-namespace:Debi.Sl.Rock.Converters" xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:Behaviors="clr-namespace:Debi.Sl.Rock.Behaviors" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <Controls:CollapsableContent HeaderText="Phone Numbers" IsExpanded="{Binding IsExpanded, Mode=TwoWay}" Style="{StaticResource CompanyCollapsableContentStyle}" d:DataContext="{d:DesignInstance design:PhoneNumbersDesignViewModel, IsDesignTimeCreatable=True}"> <Controls:CollapsableContent.Resources> <Controls:DataContextBinder x:Key="BindingContent" Content="{Binding}" /> <Converters:ComboEditorItemLookupConverter x:Key="LookupConverter" LookupList="{Binding Source={StaticResource BindingContent}, Path=Content.PhoneTypeSearcher}" /> <Converters:PhoneNumberConverter x:Key="PhoneConverter"/> </Controls:CollapsableContent.Resources> <Interactivity:Interaction.Behaviors> <Behaviors:ValidationBehavior HasBindingErrors="{Binding HasBindingErrors, Mode=TwoWay}" /> </Interactivity:Interaction.Behaviors> <ig:XamGrid AutoGenerateColumns="False" Height="200" ItemsSource="{Binding PhoneNumbers}" DeleteKeyAction="DeleteSelectedRows" RowSelectorClicked="XamGrid_RowSelectorClicked" CellExitingEditMode="XamGrid_CellExitingEditMode" RowHover="Row" VerticalAlignment="Top" ColumnWidth="*"> <ig:XamGrid.Columns> <ig:TemplateColumn Key="PhoneTypeId" HeaderText="Phone Type"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding PhoneTypeId, Converter={StaticResource LookupConverter}}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> <ig:TemplateColumn.EditorTemplate> <DataTemplate> <Controls:RockXamComboEditor AutoComplete="True" DisplayMemberPath="Name" SelectedValuePath="Id" SelectedValue="{Binding PhoneTypeId, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource BindingContent}, Path=Content.PhoneTypes}"> </Controls:RockXamComboEditor> </DataTemplate> </ig:TemplateColumn.EditorTemplate> </ig:TemplateColumn> <ig:TemplateColumn Key="PhoneNumber" HeaderText="Phone Number" Width="*"> <ig:TemplateColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding PhoneNumber, Converter={StaticResource PhoneConverter}}" /> </DataTemplate> </ig:TemplateColumn.ItemTemplate> <ig:TemplateColumn.EditorTemplate> <DataTemplate> <Grid> <ig:XamMaskedEditor Mask="999-999-9999CCCCCCCC" x:Name="xamMask" Value="{Binding PhoneNumber, Mode=Twoway}" ValueChanged="XamMaskEditor_ValueChanged" AcceptsReturn="True"> </ig:XamMaskedEditor> </Grid> </DataTemplate> </ig:TemplateColumn.EditorTemplate> </ig:TemplateColumn> </ig:XamGrid.Columns> <ig:XamGrid.AddNewRowSettings> <ig:AddNewRowSettings AllowAddNewRow="Bottom" IsEnterKeyEditingEnabled="False" IsF2EditingEnabled="True" IsMouseActionEditingEnabled="SingleClick" IsOnCellActiveEditingEnabled="False"/> </ig:XamGrid.AddNewRowSettings> <ig:XamGrid.EditingSettings> <ig:EditingSettings AllowEditing="Row" IsMouseActionEditingEnabled="SingleClick" /> </ig:XamGrid.EditingSettings> <ig:XamGrid.SelectionSettings> <ig:SelectionSettings RowSelection="Multiple" CellClickAction="SelectRow" /> </ig:XamGrid.SelectionSettings> <ig:XamGrid.RowSelectorSettings> <ig:RowSelectorSettings EnableRowNumbering="False" Visibility="Visible" /> </ig:XamGrid.RowSelectorSettings> </ig:XamGrid> </Controls:CollapsableContent></UserControl>
Thank you for your reply. I have been looking into it and I am not able to reproduce this behavior. I am attaching a screenshot that shows that the XamMaskedEditor is found in the event. I assume that you have some other structure in the EditorTemplate and the first child in the root grid is not the XamMaskedEditor. I can suggest double checking the structure of your EditorTempalte and find the right position of the XamMaskedEditor in it.
Please let me know if I can assist you with anything else.
Hi Krasimir, Thanks for the reply. I get a NullReferenceException on XamMaskedEditor. Following is my code.
private void XamGrid_CellExitingEditMode(object sender, Infragistics.Controls.Grids.ExitEditingCellEventArgs e)
{
CompanyPhoneNumbers newPhoneNumber = (CompanyPhoneNumbers)e.Cell.Row.Data;
if (newPhoneNumber.PhoneNumber == "--")
Grid grid = e.Editor as Grid;
//XamMaskedEditor input= e.Editor as XamMaskedEditor -- this is also throwing nullreference.
XamMaskedEditor input = grid.Children[0] as XamMaskedEditor;
input.ErrorMessage = "Please enter a valid phone Number";
input.Focus();
return;
}