I have RadButton in a DataTemplate in a ListView. I have a command bound to the button that works fine.
But when I click my button, without selecting the row - i need to get the current row - how can I get the SelectedItem of the current ListView Row when the RadButton is clicked. For example I want to name the Button REMOVE and remove the current row - without having to click 'behind' the RadButton to select the row to be deleted. first.
thanks!!!!!!!!!!!!!!!!!
<
ListView x:Name="lstRangeColors" Width="225" MaxHeight="275" ScrollViewer.VerticalScrollBarVisibility="Visible" Margin="0,0,0,0" ItemsSource="{Binding Path=Filters.RangeColors}" SelectedItem="{Binding Path=RangeColor}">
<ListView.ItemTemplate>
<DataTemplate>
<ContentPresenter Margin="5,5,5,5" Content="{Binding}">
<ContentPresenter.ContentTemplate>
<DataTemplate>
<Grid x:Name="gridContent" Height="35" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20*"/>
<ColumnDefinition Width="60*"/>
<ColumnDefinition Width="40*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<CheckBox Grid.Row="0" Grid.Column="0" Width="40" IsChecked="{Binding RangeValue.IsSelected, Mode=TwoWay}" Margin="5,5,0,0"/>
<TextBox Grid.Row="0" Grid.Column="1" BorderBrush="Navy" BorderThickness="1" Width="40" Text="{Binding RangeValue, Mode=TwoWay}" Margin="15,0,0,0" FontSize="14" />
<<telerik:RadButton Grid.Row="0" Grid.Column="2" Height="30" Background="{Binding BlockColor, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView}, Path=DataContext.SelectColorCommand}" HorizontalAlignment="Left" Margin="25,0,0,0" Name="btnColor" Width="40" />
</Grid>
</DataTemplate>
</ContentPresenter.ContentTemplate>
</ContentPresenter>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>