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

button in column not working on touch tablet

5 Answers 157 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
David Ocasio asked on 14 Apr 2015, 06:08 PM

The application is written for a windows 8 tablet desktop.  I have applied the windows 8 touch theme in the code behind of my main window.

StyleManager.ApplicationTheme= new Windows8TouchTheme();

 

Started with a GridViewToggleRowDetailsColumn to open the detail of a row. Unfortunaltely the arrow is too small for the tablet and therefore the touch registration for the arrow would be very finicky. 

Decided to create a custom gridview column that mimicked the behavior of the GridViewToggleRowDetailsColumn as authored in these forums many times. 

public class InoToggleColumn: GridViewBoundColumnBase
{
    public override object Header
    {
        get
        {
            return null;
        }
        set
        {
            base.Header = value;
        }
    }
 
    public InoToggleColumn()
    {
        EditTriggers = GridViewEditTriggers.None;
    }
 
    public override System.Windows.FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
    {
 
        var gvt = new RadToggleButton()
            { Margin = new System.Windows.Thickness(3) };
 
        gvt.SetBinding(RadToggleButton.IsCheckedProperty, DataMemberBinding);
 
        gvt.Checked += (sender, e) => _setImage((RadToggleButton)sender);
        gvt.Unchecked += (sender, e) => _setImage((RadToggleButton)sender);
 
        _setImage(gvt);
 
        var row = cell.ParentRow as GridViewRow;
        if (row != null)
        {
            row.SetBinding(GridViewRow.DetailsVisibilityProperty, new Binding("IsChecked")
            {
                Source = gvt, Converter = new BooleanToVisibilityConverter(), Mode = BindingMode.TwoWay
            });
        }
        return gvt;
    }
 
    private void _setImage(RadToggleButton radToggleButton)
    {
        Image sourceImage;
        if(radToggleButton==null) return;
        if (radToggleButton.IsChecked == null) return;
 
        if (radToggleButton.IsChecked.Value)
        {
            sourceImage = new Image()
            {
                Source =
                    new BitmapImage(new Uri(@"/InoAuto;component/Assets/Images/arrow-down.png",
                        UriKind.Relative)),Width = 40
            };
        }
        else
        {
            sourceImage = new Image()
            {
                Source =
                    new BitmapImage(new Uri(@"/InoAuto;component/Assets/Images/arrow-right.png",
                        UriKind.Relative)),Width = 40
            };
        }
        radToggleButton.Content = sourceImage;
    }
 
    public override bool CanSort()
    {
        return false;
    }
 
    public override bool CanFilter()
    {
        return false;
    }
 
    public override bool CanGroup()
    {
        return false;
    }
 
 
     
}

 

It works fine with a mouse but when I move it to my windows 8 surface tablet.

The Touchs do not register, the button does not toggle ,  and the detail is not displayed.

 

Any assistance would be appreciated

 

thanks

dco
 

5 Answers, 1 is accepted

Sort by
0
Accepted
Nick
Telerik team
answered on 15 Apr 2015, 06:43 AM
Hello David,

The touch is being handled globally for RadGridView thus the button you have created in the CreateCellElement is not being recognized and it does not react to touch input. This behavior will be changed in Q2 2015.

In the mean time you can workaround this by setting TouchManager.SetIsTouchHitTestVisible(gvt, false)

Hope this helps.


Regards,
Nick
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 15 Apr 2015, 11:36 AM

that worked great.

thanks nick

0
Shaun
Top achievements
Rank 1
answered on 13 Jul 2016, 09:23 AM

Hi Nick,

Has this problem been fixed?

I am currently using the TouchManager.SetIsTouchHitTestVisible(gvt, false) as a work around but this stops the gridview from being scrolled by touch.

This is causing aggravation with end users as they expect to be able to scroll by touch. They currently have to go to the scrollbar to scroll which is not expected behaviour.

 

Regards,

 

Shaun

0
Yoan
Telerik team
answered on 18 Jul 2016, 08:48 AM
Hello Shaun,

Can you try setting TouchMode to None only for the button, not for the whole grid. In this the scrolling should work correctly.

Regards,
Yoan
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Shaun
Top achievements
Rank 1
answered on 30 Sep 2016, 02:03 PM

Hi Yoan,

Sorry for the late reply, I missed this post for some reason.

I have just tried out what you mentioned and all seems good so far.

Thanks for the help

 

Shaun

Tags
GridView
Asked by
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Nick
Telerik team
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Shaun
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or