I'm trying to add a column to my XamDataGrid that is a XamComboEditor but can't seem to quite get how to do it simply. My XamDataGrid code is:
<igDP:XamDataGrid Grid.Row="0" HorizontalAlignment="Stretch" Name="dgPDUsers" DataSource="{Binding}" IsSynchronizedWithCurrentItem="True" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout Key="Expanded"> <igDP:FieldLayout.Fields> <igDP:Field Name="PDUserID" Label="User ID" Width="80" IsPrimary="True" IsScrollTipField="True" /> <igDP:Field Name="Name" Label="Name" Width="180" /> <igDP:Field Name="Clinics" Label="Clinics"> <igDP:Field.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding}" /> <Setter Property="DisplayMemberPath" Value="Name" /> <Setter Property="ValuePath" Value="ClinicID" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="ActiveName" Label="Active" Width="80" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings CellClickAction="SelectRecord" LabelClickAction="SortByMultipleFields" AllowEdit="False" AllowRecordFiltering="True" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" HighlightAlternateRecords="True" AllowDelete="False" FilterClearButtonLocation="RecordSelector" FilterRecordLocation="OnTopFixed" FilterUIType="Default" /> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid>
My page behind is handling the UserControl_Loaded event thusly:
private void UserControl_Loaded( object sender, RoutedEventArgs e ) { PDUser p = new PDUser(); List<PDUser> Users = p.SelfListAll(); this.dgPDUsers.DataContext = Users; } the PDUser object has your garden variety properties; int, string and ect. It also has a List<Clinic> property that is a list of Clinic object with a int ClinicID and string Name properties. Given that I am just learning WPF and the Infragistics library, what would be the most simple way toget my list of clinics in a combo box? As it stands now, the rows in the data grid show up with plus marks on the left side, and when you click on them they expand but nothing is there. I don't want that to show, just the combo boxes. Thanks.
private void UserControl_Loaded( object sender, RoutedEventArgs e ) { PDUser p = new PDUser(); List<PDUser> Users = p.SelfListAll(); this.dgPDUsers.DataContext = Users; }
the PDUser object has your garden variety properties; int, string and ect. It also has a List<Clinic> property that is a list of Clinic object with a int ClinicID and string Name properties.
Given that I am just learning WPF and the Infragistics library, what would be the most simple way toget my list of clinics in a combo box?
As it stands now, the rows in the data grid show up with plus marks on the left side, and when you click on them they expand but nothing is there. I don't want that to show, just the combo boxes.
Thanks.
Hello
I tried last last presented project and this is exactly what I'm looking for, Great!
I tried to find somthing different with VS2012, VS2013, VS2015, but my problem remains the same.
When the combo has drop down clicked (or opened or any ... my point is on databinding), that combo binding has produced many lines of exception (such as below)
This occured obviously on runtime and I can see performance decreasing significantly (when I loading several records) and the output console is filling continously, and even if I use severals loading strategies such as (lazy loading or kind of) ... So I believe it's like this because the problem origin is based somewhere else.
How to fix : "PART_FocusSite", "PART_Popup", "PART_DropDownButton", so there is no object having those names in project.
Would you mind fixing/(or explaining how to) from last posted solution regarding binding exceptions? We have in general 3 exceptions found : System.Windows.Data Information: 41 System.Windows.Data Information: 20 System.Windows.Data Information: 21
Please take a look below, you have a sample trace after MainWindow has loaded.
Regards
Steve
System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=ItemsProvider.DisplayMemberPath; DataItem='XamComboEditor' (Name=''); target element is 'ComboBox' (Name='PART_FocusSite'); target property is 'DisplayMemberPath' (type 'String')System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=ItemsProvider.ValuePath; DataItem='XamComboEditor' (Name=''); target element is 'ComboBox' (Name='PART_FocusSite'); target property is 'SelectedValuePath' (type 'String')System.Windows.Data Information: 41 : BindingExpression path error: 'DropDownButtonStyle' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=(0).DropDownButtonStyle; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'ToggleButton' (Name='PART_DropDownButton'); target property is 'Style' (type 'Style')System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=(0).DropDownButtonStyle; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'ToggleButton' (Name='PART_DropDownButton'); target property is 'Style' (type 'Style')System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=(0).DropDownButtonStyle; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'ToggleButton' (Name='PART_DropDownButton'); target property is 'Style' (type 'Style')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=(0).DropDownButtonStyle; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'ToggleButton' (Name='PART_DropDownButton'); target property is 'Style' (type 'Style')System.Windows.Data Information: 41 : BindingExpression path error: 'MinDropDownWidthResolved' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=(0).MinDropDownWidthResolved; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MinWidth' (type 'Double')System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=(0).MinDropDownWidthResolved; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MinWidth' (type 'Double')System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=(0).MinDropDownWidthResolved; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MinWidth' (type 'Double')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=(0).MinDropDownWidthResolved; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MinWidth' (type 'Double')System.Windows.Data Information: 41 : BindingExpression path error: 'MaxDropDownWidth' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=(0).MaxDropDownWidth; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MaxWidth' (type 'Double')System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=(0).MaxDropDownWidth; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MaxWidth' (type 'Double')System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=(0).MaxDropDownWidth; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MaxWidth' (type 'Double')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=(0).MaxDropDownWidth; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'Popup' (Name='PART_Popup'); target property is 'MaxWidth' (type 'Double')System.Windows.Data Information: 41 : BindingExpression path error: 'DropDownResizeMode' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=(0).DropDownResizeMode; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'PopupResizerDecorator' (Name=''); target property is 'ResizeMode' (type 'PopupResizeMode')System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=(0).DropDownResizeMode; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'PopupResizerDecorator' (Name=''); target property is 'ResizeMode' (type 'PopupResizeMode')System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=(0).DropDownResizeMode; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'PopupResizerDecorator' (Name=''); target property is 'ResizeMode' (type 'PopupResizeMode')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=(0).DropDownResizeMode; DataItem='ComboBox' (Name='PART_FocusSite'); target element is 'PopupResizerDecorator' (Name=''); target property is 'ResizeMode' (type 'PopupResizeMode')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=PreDropDownAreaTemplate; DataItem=null; target element is 'ContentPresenter' (Name=''); target property is 'ContentTemplate' (type 'DataTemplate')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=PostDropDownAreaTemplate; DataItem=null; target element is 'ContentPresenter' (Name=''); target property is 'ContentTemplate' (type 'DataTemplate')System.Windows.Data Information: 41 : BindingExpression path error: 'Name' property not found for 'object' because data item is null. This could happen because the data provider has not produced any data yet. BindingExpression:Path=Name; DataItem=null; target element is 'ComboBox' (Name='PART_FocusSite'); target property is 'NoTarget' (type 'Object')System.Windows.Data Information: 20 : BindingExpression cannot retrieve value due to missing information. BindingExpression:Path=Name; DataItem=null; target element is 'ComboBox' (Name='PART_FocusSite'); target property is 'NoTarget' (type 'Object')System.Windows.Data Information: 21 : BindingExpression cannot retrieve value from null data item. This could happen when binding is detached or when binding to a Nullable type that has no value. BindingExpression:Path=Name; DataItem=null; target element is 'ComboBox' (Name='PART_FocusSite'); target property is 'NoTarget' (type 'Object')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=Name; DataItem=null; target element is 'ComboBox' (Name='PART_FocusSite'); target property is 'NoTarget' (type 'Object')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=HorizontalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'HorizontalContentAlignment' (type 'HorizontalAlignment')System.Windows.Data Information: 10 : Cannot retrieve value using the binding and no valid fallback value exists; using default instead. BindingExpression:Path=VerticalContentAlignment; DataItem=null; target element is 'ComboBoxItem' (Name=''); target property is 'VerticalContentAlignment' (type 'VerticalAlignment')
Hello Mike,
I am very glad that the sample application that I have sent you was helpful for you. I saw the other forum thread that you have posted and I am currently working on it.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Krasimir,
The example you sent is now working. I can see where you used an EventSetter tag, where I used a Setter tag. Now that I am using an EventSetter tag as you have done, both issues are solved; the data correctly displays and I can correctly set the SelectedIndex. So this worked out well for me, thanks.
The next issue I'm working on is two-way binding a XamComboEditor. I posted that question yesterday, I am wondering if maybe you have seen it?
Thanks again Krasimir!
Mike
I have been reading through your previous post and I could not manage to reproduce the behavior that you are describing. I have created a sample application using the code snippet that you have posted and it seems to work as expected. The items in the drop downs of the XamComboEditors are loaded and visible when they are opened. I am attaching the sample application that I am referring to.
Please let me know if you can reproduce the same behavior with my sample application or I have misunderstood you in any way. Would you please also give me more detailed information regarding the environment in which you are developing you application (Operating system, Service Release, Integrated development environment and the specific version of our product that you are using)?
Looking forward to hearing from you.
I do need some help, and I am not sure of the best way to go about it. I'll post a code snippet and maybe I am doing something wrong syntactally you can see. Basically, I took your code example and used it and added a setter property for SelectedIndex. Here is the code, hopefully you can see what my error is. Just to summerize, no data was appearing in the drop downs until I added the SelectedIndex setter property. However, the size of the dropdown was appropriate for the number of rows that should have been showing. So if, for example, one row would have more items than another row, its dropdown was longer - but no data would appear. Then after adding the SelectedIndex setter property, the data started appearing, but no item was selected. Hopefully you can gain some insight into this issue from my code snippet.
Also, in the data grid's Initialized event, I am setting the data context with my list of objects:
private void PopulatePDUserList( ObservableCollection<PDUser> PDUserList ) { this.dgPDUsers.DataContext = null; this.dgPDUsers.DataContext = PDUserList; }
and in the data grid loaded event, I am setting the active record
private void SetActiveRecord( int SelectedRow ) { if ( this.dgPDUsers.Records.Count > 0 ) { this.dgPDUsers.Records[ SelectedRow ].IsSelected = true; this.dgPDUsers.ActiveRecord = this.dgPDUsers.Records[ SelectedRow ]; } }
<igDP:XamDataGrid Grid.Row="0" HorizontalAlignment="Stretch" Name="dgPDUsers" DataSource="{Binding}" IsSynchronizedWithCurrentItem="True" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Initialized="dgPDUsers_Initialized" Loaded="dgPDUsers_Loaded" SelectedItemsChanged="dgPDUsers_SelectedItemsChanged"> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout Key="Expanded"> <igDP:FieldLayout.Fields> <igDP:Field Name="PDUserID" Label="User ID" Width="65" IsPrimary="True"/> <igDP:Field Name="Name" Label="Name" Width="105" Visibility="Collapsed" IsScrollTipField="True" /> <igDP:Field Name="FirstName" Label="First Name" Width="105" /> <igDP:Field Name="LastName" Label="Last Name" Width="105"/> <igDP:UnboundField Name="Clinics" Width="150"> <igDP:UnboundField.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" AllowEdit="True"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:CellValuePresenter}}, Path=Record.DataItem.Clinics}" /> <Setter Property="DisplayMemberPath" Value="Name" /> <Setter Property="ValuePath" Value="ClinicID" /> <Setter Property="SelectedIndex" Value="0" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField> <igDP:UnboundField Name="Roles" Width="100"> <igDP:UnboundField.Settings> <igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}" AllowEdit="True"> <igDP:FieldSettings.EditorStyle> <Style TargetType="{x:Type igEditors:XamComboEditor}"> <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type igDP:CellValuePresenter}}, Path=Record.DataItem.Roles}" /> <Setter Property="DisplayMemberPath" Value="Name" /> <Setter Property="ValuePath" Value="RoleID" /> <Setter Property="SelectedIndex" Value="0" /> </Style> </igDP:FieldSettings.EditorStyle> </igDP:FieldSettings> </igDP:UnboundField.Settings> </igDP:UnboundField> <igDP:Field Name="LockedOut" Label="Locked Out" Width="90" /> <igDP:Field Name="ActiveName" Label="Active" Width="80" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings CellClickAction="SelectRecord" LabelClickAction="SortByMultipleFields" AllowEdit="False" AllowRecordFiltering="True" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False" HighlightAlternateRecords="True" AllowDelete="False" FilterClearButtonLocation="RecordSelector" FilterRecordLocation="OnTopFixed" FilterUIType="Default" /> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid>
Thank you for helping me with this.