ListBoxItem IsSelected TwoWay Binding

Jun 19, 2013 at 9:21 AM
Edited Jun 19, 2013 at 9:21 AM
 <ListBox ItemsSource="{Binding Path=FilterBaseFields}" SelectionMode="Multiple">
                <ListBox.ItemTemplate >
                    <DataTemplate  >
                        <TextBox Text="{Binding Path=Key, Mode=TwoWay}" extensions:ListBoxItemExtensions.IsSelected="{Binding Path=IsSelected, Mode=TwoWay}"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
For Text TwoWay Binding works great, but for extensions:ListBoxItemExtensions.IsSelected - doesn't work (work only from source to view).
Have any Idea?
Coordinator
Jun 19, 2013 at 8:16 PM
That's right. It seems to be a limitation of this property. We would need to create a different one to support two way binding. Something like an "IsSelectedBinding" property using the pattern I described here: http://blog.onedevjob.com/2011/10/26/workaround-for-binding-not-supported-on-stylesettervalue-in-silverlight/
Maybe when I get a chance I will add that to the toolkit.
Jun 20, 2013 at 6:55 AM
Thanks for response. For Binding IsSelected property of ListBoxItem I use that SO answer.
Coordinator
Jun 20, 2013 at 5:10 PM
Cool, that looks like a good solution if you can use a derived control.