Select Item based on row.IsSelected

3 posts, 0 answers
  1. Robin
    Robin avatar
    2 posts
    Member since:
    Sep 2014

    Posted 07 Jul Link to this post

    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. Robin
    Robin avatar
    2 posts
    Member since:
    Sep 2014

    Posted 07 Jul in reply to Robin Link to this post

    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

  3. UI for WPF is Visual Studio 2017 Ready
  4. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 12 Jul Link to this post

    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.
Back to Top