(New user of xamDataGrid 8.1)
My ultimate goal is to be able to perform my logic in my viewmodel class.
I am binding the grid to an XmlDataProvider, and currently I've got it to work sort of by hooking the SelectedItemsChanging event and adding a dummy xml attribute to the bound data indicating if it is selected or not. While seems to work it feels like a hack.
Would it possible to directly bind the IsSelected of a datarecord to an xml attribute?
Is there a better way to make the viewmodel aware of currently selected items/records without taking a reference to the grid?
Hi!
Unfortunataly your solution doesn't work for me.If I bind my CollectionViewModel "PersonList" to the DataGrid DataSource I receive a BindingExpression Error after I active another record.
BindingExpression path error: 'DataItem' property not found on 'object' ''PersonList'.
It seems that the DataContext of the DataPresenter is not the selected ViewModel but rather the bound CollectionViewModel "PersonList". Therefore DateItem.IsSelected can not be found.
Have I done something wrong? Here is the Xaml im using:
<Grid.DataContext> <local:PersonList /> </Grid.DataContext> <igDP:XamDataGrid Theme="Office2k7Black" Grid.Row="1" DataSource="{Binding Path=Persons}"> <igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Setter Property="IsSelected" Value="{Binding DataItem.IsSelected, Mode=TwoWay}"/> </Style> </igDP:XamDataGrid.Resources> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings SelectionTypeField="Range" SelectionTypeRecord="Range"/> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid>
Hello,
You can put that style inside the Resource of the XamDataGrid so that this style can take precendece over the theme. You can also set the based on property on that theme's style like this:
<Style TargetType="{x:Type igDP:DataRecordPresenter}" BasedOn="{x:Static Themes:DataPresenterOnyx. igDP:DataRecordPresenter}">
Let me know if you still have problems with that.
Great, just what I was looking for.
Unfortunately, by adding this it's also "overwriting" the theme style for the DataRecordPresenter. Is there anyone who knows how to keep the original settings and just adding the IsSelected binding ?
I was thinking using the "BasedOn" maybe, but how can I find the name of the style that it should be BasedOn?
Awesome, thanks.
Hopefully you already found your answer, but if anyone else is looking (like I was):
<igDP:XamDataGrid.Resources>
<Style TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="IsSelected" Value="{Binding DataItem.IsSelected, Mode=TwoWay}"/>
</Style>
</igDP:XamDataGrid.Resources>