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

How do you bind to the IsSelected property?

2 Answers 137 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Simplex
Top achievements
Rank 1
Simplex asked on 25 Jun 2009, 10:01 PM
So in a ListView I can do the following and in my View Model it would set the IsRowSelected property for each object when the row is selected. How can I do this with a RadGridView? We are using MVVM pattern and are trying to have little to no code in the xaml code behind.

Thanks

        <Style x:Key="RowItemStyle" TargetType="{x:Type ListViewItem}"
            <Setter Property="HorizontalContentAlignment" Value="Stretch" /> 
            <Setter Property="IsSelected" Value="{Binding Path=IsRowSelected, Mode=TwoWay}" /> 
            <Style.Triggers> 
                <MultiTrigger> 
                    <MultiTrigger.Conditions> 
                        <Condition Property="ItemsControl.AlternationIndex" Value="1" /> 
                        <Condition Property="IsSelected" Value="False" /> 
                        <Condition Property="IsMouseOver" Value="False" /> 
                    </MultiTrigger.Conditions> 
                    <Setter Property="Background" Value="#EEEEEEEE" /> 
                </MultiTrigger> 
            </Style.Triggers> 
        </Style> 
 
            <ListView  
                Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" 
                MaxHeight="200"  
                ScrollViewer.CanContentScroll="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" 
                ItemContainerStyle="{StaticResource RowItemStyle}" 
                ItemsSource="{Binding Path=MasterList}" IsSynchronizedWithCurrentItem="True" 
                SelectionMode="Single" 
            > 
                <ListView.View> 
                    <GridView> 
                        <GridViewColumn Header="Item Name" Width="Auto" DisplayMemberBinding="{Binding Path=ItemName}" /> 
                    </GridView> 
                </ListView.View> 
            </ListView> 
 

2 Answers, 1 is accepted

Sort by
0
Simplex
Top achievements
Rank 1
answered on 29 Jun 2009, 06:56 PM
Anyone have any ides?
0
Milan
Telerik team
answered on 02 Jul 2009, 04:41 PM
Hello Edward,

There is a known problem in Q1 SP2 that prevents such bindings to the IsSelected property to work but this limitation will be lifter with Q2 2009, which is just around the corner.

Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Simplex
Top achievements
Rank 1
Answers by
Simplex
Top achievements
Rank 1
Milan
Telerik team
Share this question
or