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
245
MVVM Binding to IsSelected
posted

I'd like to bind xamDataGrid rows to an IsSelected property in my ViewModel, so I did this:

    <Style TargetType="{x:Type igDP:DataRecordPresenter}">

        <EventSetter Event="MouseLeftButtonUp" Handler="object_MouseLeftClick"/>
        <EventSetter Event="MouseDoubleClick" Handler="object_MouseDoubleClick"/>
        <EventSetter Event="MouseRightButtonUp" Handler="object_MouseRightClick"/>
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>

    </Style>

However, this seems to have no effect because the IsSelected property of DataRecordPresenter seems to remain false when a row is selected! For instance, when I set a breakpoint in object_MouseDoubleClick, ((DataRecordPresenter)sender).IsSelected==false even though the row is clearly selected. So how do I do it properly?
Note: I need two-way binding, so that items can be selected or deselected by changing the ViewModel.IsSelected property. I have learned that this can be tricky even with a standard ListBox or ListView control.

Parents Reply Children
No Data