1

I have a Windows 8.1 Application

I am using WinRT Xaml Toolkit to bind my IsSelected Property to my ViewModel as the Binding is supported out of the box.

I have included the following Namespace

xmlns:Extensions="using:WinRTXamlToolkit.Controls.Extensions"

Here is the ListBoxItem of my XAML

<ListBoxItem Extensions:ListBoxItemExtensions.IsSelected="{Binding MyBool, Mode=TwoWay}">
    <TextBlock Text="MyText" />
</ListBoxItem>

However I am unable to bind it TwoWay, the binding is working only from ViewModel -> View.

Is this a limitation of the Extension. If yes how do I achieve two way binding?

I would be very glad if someone can point me in the right direction. Thanks in Advance.

HelpMatters
  • 1,299
  • 1
  • 13
  • 32

1 Answers1

1

You cannot do this, unfortunately.

You can, however two-way bind to the ListView.SelectedItem.

If you need more than one selected item, the WinRT Toolkit has BindableSelection: http://winrtxamltoolkit.codeplex.com/SourceControl/latest#WinRTXamlToolkit/WinRTXamlToolkit.Shared/Controls/Extensions/ListViewExtensions.cs

Best of luck!

Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
  • No I just have 2 items in my List. Based on a boolean variable in my ViewModel one of them should be selected. I tried to do this using IsSelected, Mode=TwoWay binding, but it didn't work. Filip Skakun suggested that I write my own attached behavior or use code behind if I want to solve the problem quickly and easily. – HelpMatters Sep 04 '14 at 16:30