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

Select Item based on row.IsSelected

2 Answers 568 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Robin
Top achievements
Rank 1
Robin asked on 07 Jul 2016, 02:05 PM

Hi there,

I'm trying to get the multiselection of the RadGridView working. I have a class Building with a Property IsSelected. With the Selection_Changed event i set/unset the property of the item. Is it possible to bind to the Building.IsSelected, so each row gets selected, if its object.IsSelected is true?

I know about the solution with behaviors, but I'd like one without it.

A little sample here:

<telerik:RadGridView x:Name="BuildingListGrid" ItemsSource="{Binding BuildingList}" EnableRowVirtualization="True"
                                 SelectionUnit="FullRow" SelectionMode="Extended" SelectionChanged="MasterBuildingListGrid_OnSelectionChanged">     <telerik:RadGridView.Columns>
         <telerik:GridViewDataColumn DataMemberBinding="{Binding Building.Name}" Header="Column2" />

     </telerik:RadGridView.Columns>

</telerik:RadGridView>

 

public class Building : INotifyPropertyChanged
{
    public Building(Building building){}
    public bool IsSelected
    {
        get { return _isSelected; }
        set
        {
            if (value == _isSelected) return;
            _isSelected = value;
            OnPropertyChanged();
        }
    }

    public string Name { get; set; }

}

2 Answers, 1 is accepted

Sort by
0
Robin
Top achievements
Rank 1
answered on 07 Jul 2016, 02:38 PM
I also tried this with:
<Style TargetType="telerik:GridViewRow">
 <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Style>

 

and deactivated RowVirtualization. But still doesn't work.

 

Greetings Robin

0
Stefan
Telerik team
answered on 12 Jul 2016, 08:59 AM
Hi Robin,

Generally, the recommended approach for such requirement is demonstrated in the Binding Selected Items From View Model SDK Example. Can you please verify whether this is the example to which you referred? Are there any obstacles to adopting the approach demonstrated in it?

Regards,
Stefan X1
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Robin
Top achievements
Rank 1
Answers by
Robin
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or