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

[Solved] Win 8.1 RadGrid ColumnHeaderTap Command

2 Answers 67 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Randall
Top achievements
Rank 1
Randall asked on 15 May 2014, 02:56 PM
I have implemented a new class for the above mentioned command (http://www.telerik.com/help/windows-8-xaml/datagrid-commands-columnheadertapcommand.html).

My UI page has a RadGrid which is has the command bound to the new class via XAML and all is working as I need it except for one thing:

I need to notify my UI page from the command class I implemented that I have completed the operation I am doing in the code

How do I notify the UI page?

Here is the radgrid xaml:
---------------------------------

<telerikGrid:RadDataGrid x:Name="radEP">
    <telerikGrid:RadDataGrid.Commands>
        <local:CustomColumnHeaderTapCommand />
    </telerikGrid:RadDataGrid.Commands>
    
    <telerikGrid:RadDataGrid.Resources>
        <Style TargetType="gridPrimitives:DataGridCurrencyControl">
            <Setter Property="Background" Value="Transparent" />
        </Style>
        <Style TargetType="gridPrimitives:SelectionRegionBackgroundControl">
            <Setter Property="Background" Value="Yellow" />
        </Style>
        <Style TargetType="gridPrimitives:DataGridHoverControl">
            <Setter Property="Background" Value="#FFFFFF84" />
            <Setter Property="Opacity" Value="0.5" />
        </Style>
        <Style TargetType="gridPrimitives:SelectionRegionBorderControl">
            <Setter Property="BorderBrush" Value="Red" />
        </Style>
    </telerikGrid:RadDataGrid.Resources>

    <telerikGrid:RadDataGrid.Columns>

        ... 

        // all columns here

        ...
    </telerikGrid:RadDataGrid.Columns>
</telerikGrid:RadDataGrid>


The command class:
----------------------------
    /// <summary>
    ///     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    ///     Custom command for header tap to allow us to select a column
    ///     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
    /// </summary>
    public class CustomColumnHeaderTapCommand : DataGridCommand
    {
        private string _currentItem = string.Empty;


        public CustomColumnHeaderTapCommand ( )
        {
            this.Id = CommandId.ColumnHeaderTap;
        }

        public override bool CanExecute ( object parameter )
        {
            // set colname from parameter
            Telerik.UI.Xaml.Controls.Grid.Commands.ColumnHeaderTapContext context = parameter as ColumnHeaderTapContext;
            string gcSelectName = context.Column.Name;

            // clear all cells of selections
            this.Owner.DeselectAll();

            // get read only DataView data and count
            IReadOnlyList<object> roList = this.Owner.GetDataView().Items;
            int roCount = roList.Count;

            // displays the value for every column for the current row
            for (int row = 0; row < roCount; row++)
            {
                this.Owner.SelectCell(new DataGridCellInfo((this.Owner.ItemsSource as List<T_EPro>)[row], this.Owner.Columns[gcSelectName]));
            }

            // I WANT TO NOTIFY THE XAML PAGE HERE

            return true;
        }

        public override void Execute ( object parameter )
        {
            var context = parameter as ColumnHeaderTapContext;
        }
    }








2 Answers, 1 is accepted

Sort by
0
Rosy Topchiyska
Telerik team
answered on 19 May 2014, 09:07 AM
Hi Randall,

Thank you for writing.

I have attached a sample project that demonstrates how you can notify the page when the custom grid command is executed. I have added a CommandExecuted event handler in the view model and when the command is executed, I raise the event via the data context of the command owner. In the MainPage class I subscribe to the CommandExecuted event of the view model.

I hope this helps. Please, let us know if you have further questions.

Regards,
Rosy Topchiyska
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Randall
Top achievements
Rank 1
answered on 29 May 2014, 01:31 AM
works perfectly - I was able to add generics into the mix so I could use one tap command
Tags
Grid for XAML
Asked by
Randall
Top achievements
Rank 1
Answers by
Rosy Topchiyska
Telerik team
Randall
Top achievements
Rank 1
Share this question
or