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
40
XamGrid ComboBox Column Binding
posted

I am having trouble binding the data in the combo box column in a xamGrid to the right data source.  I have two observablecollections defined, Tasks and userList.  I am binding correctly when I just bind the grid to the Tasks.  I want to bind the userList to the combobox column in the xamGrid when editing.  When not editing the row should display the value from the Tasks collection.

 

This works to display the userList data within Grid, so I know that the observable collection is getting loaded correclty.

<ComboBox  Name="comboBox1" VerticalAlignment="Top" Width="120" ItemsSource="{Binding Path=userList}" SelectedValuePath="Id" DisplayMemberPath="Name" />

When I attempt to bind this within the xamGrid, no data displays.  When the row is edited the combobox list is empty.  Any ideas?

 <Grid x:Name="LayoutRoot" Background="White" Height="180">            

 <Grid.RowDefinitions>                

<RowDefinition />                

<RowDefinition Height="Auto"/>            

</Grid.RowDefinitions>        

<ig:XamGrid x:Name="TaskGrid" VerticalAlignment="Top"                     ItemsSource="{Binding Path=Tasks}"             CellExitedEditMode="TaskGrid_CellExitingEditMode"                                AutoGenerateColumns="False">            

<ig:XamGrid.AddNewRowSettings>               

<ig:AddNewRowSettings AllowAddNewRow="Top" />                      

 <ig:XamGrid.EditingSettings>                    

<ig:EditingSettings AllowEditing="Row"/>                

 </ig:XamGrid.EditingSettings>                            

<ig:XamGrid.Columns>                  

 <ig:TextColumn Key="Subject" Width="200"/>                                

<ig:TextColumn Key="Description" HeaderText="Notes" Width="500"/>                    

 <!-- This works to display the original data in Tasks    <ig:TextColumn Key="OwnerId.Name" HeaderText="Assigned To" Width="100"/> -->                

<ig:ComboBoxColumn Key="OwnerId.Name" HeaderText="Assigned"                        ItemsSource="{Binding DataContext.userList, RelativeSource={RelativeSource FindAncestor, AncestorType= Grid}}"                            SelectedValuePath="Id" DisplayMemberPath="Name"/>                                

<ig:DateColumn Key="ScheduledEnd" SelectedDateFormat="Short"  HeaderText="Due" Width="125"/>                    

<ig:TextColumn Key="StateCode.Value" HeaderText="State" Width="100"/>                

 </ig:XamGrid.Columns>            

 </ig:XamGrid>      

</Grid>


 

Parents Reply Children
No Data