Is it possible to send some event when currently selected row is clicked?

2 posts, 0 answers
  1. James
    James avatar
    2 posts
    Member since:
    Aug 2014

    Posted 27 Aug 2014 Link to this post

    <telerik:RadGridView  Margin="0" Height="250" Grid.Row="1" Grid.ColumnSpan="1" Grid.Column="0" VerticalAlignment="Stretch" Grid.RowSpan="7"
        x:Name="rgvAviableSamples"
        ItemsSource="{Binding AviableSampleItems, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged }"
        SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
        CanUserFreezeColumns="False"
        CanUserReorderColumns="False"
        AutoGenerateColumns="False"
        ShowGroupPanel="False"
        CanUserResizeColumns="True"
        IsReadOnly="False"
        GridLinesVisibility="None"
        RowIndicatorVisibility="Collapsed"
        ScrollMode="Deferred" 
        ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left"
        ShowColumnHeaders="True"
        SelectionMode="Single"
        SelectionUnit="FullRow"
        local:CustomFilterBehavior.TextBox="{Binding ElementName=tbFilterByLot}">
     
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn UniqueName="IsSelected" Header="" IsReadOnly="True" Width="auto" >
                <telerik:GridViewDataColumn.CellEditTemplate>
                    <DataTemplate>
                        <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" telerik:StyleManager.Theme="{StaticResource Theme}" />
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellEditTemplate>
     
                <telerik:GridViewDataColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" telerik:StyleManager.Theme="{StaticResource Theme}" />
                    </DataTemplate>
                </telerik:GridViewDataColumn.CellTemplate>
            </telerik:GridViewDataColumn>
     
            <telerik:GridViewDataColumn UniqueName="Lot" Header="Lot" IsReadOnly="True" Width="*" />
            <telerik:GridViewDataColumn UniqueName="ExpirationDate" Header="ExpirationDate" DataFormatString="{}{0:yyyy-MM-dd}" IsReadOnly="True" Width="*" />
            <telerik:GridViewDataColumn UniqueName="UnitPrice" Header="UnitPrice" IsReadOnly="True" Width="*" />
        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

    What I would like to do is:

    When I click on some row, the checkbox in the first column is checked, when I click on the same row again (while it is selected), checkbox is unchecked. 

    I can check and uncheck rows... but only when the row I want to uncheck is not currently selected, if it is - nothing is happening.

    Any way around this?

    Thanks in advance.

    Best regards.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 28 Aug 2014 Link to this post

    Hello,

    You can subscribe for the MouseLeftButtonUp event  and monitor all the clicks.
    For example:

    public MainPage()
    {
        InitializeComponent();
        this.radGridView.AddHandler(RadGridView.MouseLeftButtonUpEvent, new MouseButtonEventHandler(OnMouseLeftButtonUp), true);
    }
     
    private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
         FrameworkElement clicked = e.OriginalSource as FrameworkElement;
     
         var clickedCell = clicked.ParentOfType<GridViewCell>();
          
         var clickedRow = clicked.ParentOfType<GridViewRow>();
     
         var boundItem = clickedRow.Item;
         ...
    }


    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
Back to Top