Hi,
I have a XamDataGrid with a ComboBoxField that is editable. I would like to force all characters to be upper case when the user is typing.
I managed it for TextField using a style with 'CharacterCasing'.
Here is my XamDataGrid XAML:
<igDP:XamDataGrid x:Name="myGrid" DataSource="{Binding Path=MyGridDataSource}" RecordLoadMode="LoadOnDemand" ScrollingMode="Immediate" ScrollViewer.CanContentScroll="True" VirtualizingPanel.IsVirtualizing="True" VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.CacheLength="10" VirtualizingPanel.CacheLengthUnit="Item" GroupByAreaLocation="None" > <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type TextBox}"> <Setter Property="CharacterCasing" Value="Upper"/> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings HighlightAlternateRecords="True" FilterUIType="LabelIcons" ExpansionIndicatorDisplayMode="CheckOnDisplay" AllowClipboardOperations="Copy" AllowAddNew="True" AddNewRecordLocation="OnBottom" AutoGenerateFields="False" HeaderPlacement="OnRecordBreak" AutoFitMode="ExtendLastField" > </igDP:FieldLayoutSettings> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings FilterLabelIconDropDownType="MultiSelectExcelStyle" AllowSorting="True" LabelClickAction="SortByMultipleFields" AllowEdit="True" ScrollViewer.CanContentScroll="True" VirtualizingPanel.IsVirtualizing="False" VirtualizingPanel.VirtualizationMode="Standard" VirtualizingPanel.CacheLength="10000" VirtualizingPanel.CacheLengthUnit="Item" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:ComboBoxField Name="MyComboBox" Label="MyComboBox" IsEditable="True"> <igDP:ComboBoxField.EditorStyle> <Style TargetType="igWpf:XamComboEditor"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.MyInitialValues, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}"/> </Style> </igDP:ComboBoxField.EditorStyle> </igDP:ComboBoxField> <igDP:TextField Name="MyText" Label="MyText" VerticalContentAlignment="Stretch"/> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
How can I achive this for the ComboBoxField?
I managed to find it myself.First add an event handler:
<Style TargetType="igWpf:XamComboEditor"> <Setter Property="ItemsSource" Value="{Binding Path=DataContext.ReferenceTypes, RelativeSource={RelativeSource AncestorType={x:Type igDP:XamDataGrid}}}" /> <EventSetter Event="EditModeStarted" Handler="XamComboEditor_EditModeStarted"/> </Style>
In the handler use this:
private void refType_EditModeStarted( object sender, Infragistics.Windows.Editors.Events.EditModeStartedEventArgs e ) { var xce = (XamComboEditor)sender; var textbox = XamlUtilities.FindChild<TextBox>(xce, "PART_EditableTextBox"); // name can also be NULL as the first TextBox shall be returned. if ( textbox == null ) return; textbox.CharacterCasing = CharacterCasing.Upper; } // XamlUtilities is a custom class and source of "FindChild" is available at stackoverflow.com // https://stackoverflow.com/questions/636383/how-can-i-find-wpf-controls-by-name-or-type