<Grid> <igDP:XamDataGrid x:Name="U_XamDataGrid" BorderBrush="{DynamicResource BorderColorBrush}" DataSource="{Binding GetData.MSInform}" GroupByAreaLocation="None" GroupByAreaMode="MultipleFieldLayoutsFull" InitializeRecord="U_XamDataGrid_InitializeRecord" IsGroupByAreaExpanded="True" ScrollViewer.VerticalScrollBarVisibility="Visible" Theme="Office2013"> <igDP:XamDataGrid.Resources> <SolidColorBrush x:Key="{ComponentResourceKey {x:Type igDP:XamDataGrid}, LabelBackground}" Color="{DynamicResource BackColorWhite}" /> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False" LabelClickAction="Nothing" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AllowClipboardOperations="All" AutoFitMode="ExtendLastField" AutoGenerateFields="False" CopyFieldLabelsToClipboard="True" HeaderPlacementInGroupBy="OnTopOnly" HeaderPrefixAreaDisplayMode="FieldChooserButton" RecordSelectorLocation="None" /> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout Key="MeasureSetInformationsSt"> <igDP:FieldLayout.SortedFields> <igDP:FieldSortDescription Direction="Ascending" FieldName="Title" IsGroupBy="True" /> </igDP:FieldLayout.SortedFields> <igDP:FieldLayout.Fields> <igDP:Field Name="Title" Width="Auto" AllowGroupBy="True" Visibility="Collapsed" /> <igDP:Field Name="Name" Width="Auto" Label="{x:Static lang:Lang.Name}" /> <!--<igDP:Field Name="Value" Width="Auto" Label="{x:Static lang:Lang.Value}" />--> <igDP:ComboBoxField Name="Value" DisplayMemberPath="{Binding SelectProbe}" ItemsSource="{Binding lstValue}" Label="{x:Static lang:Lang.Value}" ValuePath="{Binding SelectProbe}" /> <!--<igDP:Field Name="Name" Width="Auto" Label="Product" />--> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid> </Grid>
I would like to create only the items corresponding to the probe in the form of a combobox.
ViewModel Code
GetData.MSInform.Clear(); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.Mode, Value = probe.Mode.ToString(), }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.Project, Value = GetData.ProjectARC.Name, }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.Probe, //Value = probe.No.ToString(), }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.SpectrometerResolution, Value = CommonMethod.GetDescriptionFromEnum((SPCTROMETER_RESOLUTION)(int)probe.SingleModeMeasureSetting.Resolution), }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.BackgroundGainLevel, Value = CommonMethod.GetDescriptionFromEnum((GAIN_LEVEL)probe.SingleModeMeasureSetting.BackgroundGain), }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.SampleGainLevel, Value = CommonMethod.GetDescriptionFromEnum((GAIN_LEVEL)probe.SingleModeMeasureSetting.SampleGain), }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.Averaging, Value = probe.SingleModeMeasureSetting.Averaging.ToString(), }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.BoxcarWidthEnable, Value = probe.SingleModeMeasureSetting.BoxcarWidthEnable.ToString(), }); GetData.MSInform.Add(new MeasureSetInformationsSt() { Title = Lang.MeasurementCondition, Name = Lang.BoxcarWidth, Value = probe.SingleModeMeasureSetting.BoxcarWidth.ToString(), });
Hello,
I have created a small sample that demonstrates how the item source of a XamComboEditor could be set depending on the value of another field. To achieve this, a converter should be used and based on the value of the other field, different collection is returned that would become the new item source of the XamComboEditor. Please note that in order to not store wrong values from different categories/probes, the CellChanged evet should be used to clear the value of the cell that holds the XamComboEditor, so that it doesn’t contain values from different category/probe.
Attached you will find my sample for your reference. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve, please feel free to modify it and send it back to me along with steps to reproduce. Alternatively, if the behavior cannot be replicated, please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application and attach it in this case.
Please let me know if you need any further assistance.
Regards, Ivan Kitanov
1106.ComboBoxFieldBasedOnOtherComboBoxField.zip
I looked at the attached project and only the items in a specific row should be made into a Combo, but they are all Comboboxes. Did I explain it wrong?Or am I lacking in understanding?
I may have misunderstood you, if you would like to use different editor in the same field based on a value of another field, I recommend you reviewing the following forum post, where this is explained in detail:
https://www.infragistics.com/community/forums/f/ultimate-ui-for-wpf/60097/how-can-i-place-different-editors-in-one-field-based-on-the-data-in-the-particular-row-they-are-placed-in-xamdatagrid
I have modified the sample so that when the user changes the value of the second field, the value of the third field is cleared and also added a XamComboBox as another option for editor. For this, I have used the CellUpdated event to change the value, in order to address the changes once the user changes the cell or if the cell loses focus, the following property should be set:
xdg.UpdateMode = UpdateMode.OnCellChangeOrLostFocus;
DifrentEditorsInField.zip
One more thing I want to ask is that defining a template with a style is fine, but how can I bind the items of the ComboBox?
I’m glad that you found my suggestion helpful. In order to set default value, when changing to XamComboBox as editor of the field, you can use the CellUpdated event and check if the entered value meets your condition and then assign the value of the other cell based on it. The following coed could be used as a reference:
private void xdg_CellUpdated(object sender, Infragistics.Windows.DataPresenter.Events.CellUpdatedEventArgs e)
{
if (e.Cell.Field.Index == 1)
if (int.Parse(e.Cell.Value.ToString()) % 3 == 2)
e.Cell.Record.Cells[2].Value = false;
}
else e.Cell.Record.Cells[2].Value = 1;
I have also modified the sample so that the items source comes from binding, instead of declaring the ComboBoxDataItems.
Please test the sample on your side and let me know if you need any further assistance.
3223.DifrentEditorsInField.zip