This is a migrated thread and some comments may be shown as answers.

IsSelected binding not working correctly for GridViewRow

4 Answers 532 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Don
Top achievements
Rank 1
Don asked on 07 Dec 2012, 08:31 PM
I have ObservableCollections that are bound to RadGridView and RadtreeListView controls to fill out the contents. I am using the IsSelected binding to process various operations on the ObservableCollections depending on what rows are selected.

Here is how the binding for IsSelected is defined in my XAML:

<em:StatusRowStyleSelector x:Key="StatusRowStyleDefinition">
    <em:StatusRowStyleSelector.StatusRowStyle>
        <Style TargetType="telerik:GridViewRow">
            <Setter Property="Background" Value="{StaticResource NormalBorderBrush}" />
            <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
            <Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}"/>
        </Style>
    </em:StatusRowStyleSelector.StatusRowStyle>
</em:StatusRowStyleSelector>

And here is how the style is applied as an attribute in both the RadGridView and RadtreeListView tag definitions:

RowStyleSelector="{DynamicResource StatusRowStyleDefinition}"
SelectionMode="Extended"
SelectionUnit="FullRow"

The problem:

If I have a view where some of the rows are not visible and I select all of the items (ctrl-A), only those items that are visible get the IsSelected property updated in the source objects.  If I scroll the hidden rows into view, the IsSelected property for the bound objects in the ObservableCollection finally gets updated as each row is scrolled into view.  So, apparently, "selecting all" selects all of the rows in the control, but the IsSelected property in the bound source objects in the ObservableCollection is updated only for visible rows.

The same happens if all rows are selected and I click on single row which deselects everything else: only the visible rows get the IsSelected property updated to false.

It works this way regardless of the state of the data virtualization. I'm scratching my head over this. Am I setting up the binding wrong or is this a bug?

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Dec 2012, 07:12 AM
Hi,

 Generally this is expected. You are using UI container to bind to a property in your model. You cannot invoke binding on containers that simply do not exists. 

All the best,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Don
Top achievements
Rank 1
answered on 11 Dec 2012, 05:22 PM
That's what I figured.  I decided to use the selection changed event and used the new and removed lists to update my secondary IsSelected properties.
0
Kristoffer
Top achievements
Rank 1
answered on 05 Jun 2013, 04:06 PM
There's no way to get this working? :(
0
Nick
Telerik team
answered on 10 Jun 2013, 08:06 AM
Hi Kristofer,

Unfortunately, no, there is no way that this could be working with enabled row virtualization. 

Regards,
Nik
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Don
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Don
Top achievements
Rank 1
Kristoffer
Top achievements
Rank 1
Nick
Telerik team
Share this question
or