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>
Hi Sandra,
you can only bind the ComboBoxColumn's ItemsSource property to static resource(or you could set it in code behind)- check out Darrell's post on the subject.
Hope this helps,
I was hoping that the ig:xamGrid would support relative sources in the combo box of the grid -- the post below implies that Silverlight 5 should support this in a grid -- but xamGrid does not, or am I missing something?
http://weblogs.asp.net/dwahlin/archive/2011/10/07/new-line-of-business-features-in-silverlight-5-ancestor-relativesource-binding.aspx
In the grid I show a list of tasks (observablecollection). I bind the xamgrid to the task. Each task has a user; I need the user field to be a combobox, the values of which are ID and Name -- and that list is also created in a an observablecollection. If I cannot bind to the relativesource, can I take that observablecollection and make it into a static resource? Any pointers? The observablecollectino is created from a database query. Any help is much appreciated.