Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
785
Prevent RowSelection when Custom Switch Column Value is Changed
posted

I'm wondering what is the best way to prevent a Row from being selected when a change is made to a custom column that contains a UISwitch. I have my custom GridViewColumnDefinition which contains a custom IGgridViewCell which contains my UISwitch. That switch implements the ValueChanged Event Handler. I execute some code when the value changes, but don't want the row to be selected because that executes some other code specific to DidSelectRow.

Anyways, I believe you get my point by now, I'm leaning towards overriding the WillSelectRow method and doing a HitTest to see which Column was pressed at the time when a selection was performed, but I'm not sure if this is the correct approach. Looking for the best approach to precent the DidSelectRow method from firing when a specific column is clicked.

Thanks for all you help as always.

  • 40030
    Verified Answer
    Offline posted

    Hi, 

    Its actually pretty easy to do. In your custom cell, just add the following method along with the export attribute: 

    [Export("selectGesture:")]
            public void overrideSelectGesture(UIGestureRecognizer gesture)
            {
                // Do Nothing
            }

    Basically, this overrides the cell's selection gesture, and thus disables selection via that cell. 

    I've attached a sample that does exactly that. 

    Hope this helps, 

    -SteveZ

    GridSample.zip