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
Configuring Swipe Row C# Example
posted

Can anyone provide me with an example of implementing http://ko.infragistics.com/help/topic/d82bbb57-98be-4311-928d-ca3fe760a93a (Configuring Swipe Row) in C#?

I can't seem to get my  ResolveSlideRowLeftView override method in IGGridViewDelegate to fire and think I may be using the wrong override method.....

Parents
No Data
Reply
  • 40030
    Offline posted

    Hi,

    Sure thing! There are just a few things you need to make sure you do. 

    1. First your grid can't scroll horizontally. That means your total column widths must be smaller or equal to the frame of the grid. That happens automatically though, as all columns are set to SizeToFit by default. 

    2. Make sure you set the SwipeRowAction property on the grid to: IGGridViewSwipeRowActionSlideRowLeft

    3. Set the delegate property on the grid to an instance of your custom delegate class. 

    4. Override the ResolveSlideRowLeftView method on your delegate. 

    Here is the code for a ViewController that i've implemented that does all of the above. 

    public class MyDelegate : IGGridViewDelegate
        {
            public override UIView ResolveSlideRowLeftView (IGGridView gridView, IGRowPath path)
            {
                UILabel label = new UILabel () { Text="Hello", BackgroundColor=UIColor.Green };
                return label;
            }
        }


        public partial class GridViewController : UIViewController
        {
            IGGridView _gridView;
            IGGridViewDataSourceHelper _dsh;

            public GridViewController ()
                : base ()
            {
            }

            public override void ViewDidLoad ()
            {
                base.ViewDidLoad ();

                this.View.BackgroundColor = UIColor.White;
                
                _gridView = new IGGridView(new RectangleF(0,0,this.View.Frame.Size.Width, this.View.Frame.Size.Height), IGGridViewStyle.IGGridViewStyleDefault);
                _gridView.RowBackgroundColor = UIColor.White;
                _gridView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
                _gridView.SwipeRowAction = IGGridViewSwipeRowAction.IGGridViewSwipeRowActionSlideRowLeft;
                this.View.AddSubview (_gridView);

                _dsh = new IGGridViewDataSourceHelper ();

                List<Data> data = new List<Data> () { new Data(){Name="Hello"}, new Data(){Name="World"} };

                _dsh.Data = data.ToArray();

                _gridView.WeakDataSource = _dsh;
                _gridView.WeakDelegate = new MyDelegate ();

                _gridView.UpdateData ();


            }

        
        }

        public class Data : NSObject
        {
            [Export("name")]
            public string Name{get;set;}
        }

    Let me know if you have any questions. I hope this helps!

    -SteveZ

Children
No Data