DataBinding to GridView.SelectItem is ignored RRS feed

  • Question

  • Hello,

    I have a strange issue with databinding to a GridView. Similar Code with a ListView works fine.

    <GridView ItemsSource="{Binding}" 
                                    SelectedValue="{Binding Test, Mode=TwoWay}"
                                   SelectedItem="{Binding Test, Mode=TwoWay}"
                                   SelectedIndex="{Binding Test, Mode=TwoWay}">
                        <VariableSizedWrapGrid ItemWidth="{Binding GridItemWidth}" ItemHeight="{Binding GridItemHeight}"/>

    However the databinding to the SelectedItem etc is just ignored.... no errorMessages... nothing...

    Can anyone help me out?


    Monday, January 27, 2014 4:35 PM

All replies

  • Hi Klaus,

    could you please show what you're actually binding to?

    Binding SelectedValue AND SelectedItem AND SelectedIndex makes no sense to me. You should choose one.

    A binding to SelectedIndex is really rare, I've never seen someone doing that. :)

    Binding to SelectedItem: Use it if you want to bind to the full object, e.g. a Person-Object

    Binding to SelectedValue: Use it if you want to bind to a specific value that you identify via the SelectedValuePath-Property. This is typically used to e.g. bind to the Id-Property of the Person-Object

    Thomas Claudius Huber

    "If you can't make your app run faster, make it at least look & feel extremly fast"

    My latest app: The "Womanizer" :-)
    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com
    author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook

    Monday, January 27, 2014 8:45 PM
  • I am binding to an


    and I orginally binded only SelectedItem - but with no effect.

    I just wanted to try if SelectedValue or SelectIndex shows a different behaviour.

    Monday, January 27, 2014 8:54 PM
  • Even if I add something like

                                   SelectedItem="{Binding SomeFieldThatDoesntExist, Mode=TwoWay}"

    I get no error messages.

    The binding seems to be ignored at all.

    Monday, January 27, 2014 9:55 PM
  • The best Solution I've found is to use the WinRT XAML Toolkit : http://winrtxamltoolkit.codeplex.com/ 

    Then just set :


    and with your GridView/ListView something like this

    <ListView x:Name="ListThumbMode" Visibility="Collapsed" Grid.Row="1" ItemsSource="{Binding Items, Mode=OneWay}" 
                                    IsSwipeEnabled="True" IsItemClickEnabled="True"
                                    SelectionMode="Multiple" Extensions:ListViewExtensions.BindableSelection="{Binding SelectedItems, Mode=TwoWay}"  >


    Wednesday, January 29, 2014 10:08 AM