public void UpdateBindings()
        {
            this.DataContext = App.Settings;

            var tipSettingsStack = new StackView
            {
                Items =
                {
                    new Group
                    {
                        Text          = "Tip Button",
                        Orientation   = Orientation.Horizontal,
                        ExpandContent = false,
                        Content       = tipButton = new BindingDisplay
                        {
                            MinimumSize = new Size(300, 0),
                            Store       = App.Settings?.TipButton
                        }
                    },
                    new Group
                    {
                        Text        = "Tip Pressure",
                        Orientation = Orientation.Horizontal,
                        Content     = tipPressure = new FloatSlider()
                    }
                }
            };

            tipButton.StoreBinding.BindDataContext <Settings>(s => s.TipButton);
            tipPressure.ValueBinding.BindDataContext <Settings>(s => s.TipActivationPressure);

            var eraserSettingsStack = new StackView
            {
                Items =
                {
                    new Group
                    {
                        Text          = "Eraser Button",
                        ExpandContent = false,
                        Orientation   = Orientation.Horizontal,
                        Content       = eraserButton = new BindingDisplay
                        {
                            MinimumSize = new Size(300, 0),
                            Store       = App.Settings?.EraserButton
                        }
                    },
                    new Group
                    {
                        Text        = "Eraser Pressure",
                        Orientation = Orientation.Horizontal,
                        Content     = eraserPressure = new FloatSlider()
                    }
                }
            };

            eraserButton.StoreBinding.BindDataContext <Settings>(s => s.EraserButton);
            eraserPressure.ValueBinding.BindDataContext <Settings>(s => s.EraserActivationPressure);

            var penBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.PenButtons.Count; i++)
            {
                BindingDisplay penBinding;

                var penBindingGroup = new Group
                {
                    Text          = $"Pen Button {i + 1}",
                    Orientation   = Orientation.Horizontal,
                    ExpandContent = false,
                    Content       = penBinding = new BindingDisplay
                    {
                        MinimumSize = new Size(300, 0),
                        Tag         = i,
                        Store       = App.Settings?.PenButtons[i]
                    }
                };
                penBinding.StoreChanged += (sender, e) =>
                {
                    var display = sender as BindingDisplay;
                    var index   = (int)display.Tag;
                    App.Settings.PenButtons[index] = display.Store;
                };
                penBindingsStack.AddControl(penBindingGroup);
            }

            var auxBindingsStack = new StackView();

            for (int i = 0; i < App.Settings?.AuxButtons.Count; i++)
            {
                BindingDisplay auxBinding;

                var auxBindingGroup = new Group
                {
                    Text          = $"Auxiliary Button {i + 1}",
                    Orientation   = Orientation.Horizontal,
                    ExpandContent = false,
                    Content       = auxBinding = new BindingDisplay
                    {
                        MinimumSize = new Size(300, 0),
                        Tag         = i,
                        Store       = App.Settings?.AuxButtons[i]
                    }
                };
                auxBinding.StoreChanged += (sender, e) =>
                {
                    var display = sender as BindingDisplay;
                    var index   = (int)display.Tag;
                    App.Settings.AuxButtons[index] = display.Store;
                };
                auxBindingsStack.AddControl(auxBindingGroup);
            }

            var firstRow = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Tip Bindings", tipSettingsStack)
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Eraser Bindings", eraserSettingsStack)
                    }
                }
            };

            var secondRow = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Pen Button Bindings", penBindingsStack)
                    },
                    new StackLayoutItem
                    {
                        Expand  = true,
                        Control = new Group("Auxiliary Button Bindings", auxBindingsStack)
                    }
                }
            };

            this.Content = new StackView
            {
                Orientation = Orientation.Vertical,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    new StackLayoutItem(firstRow,  true),
                    new StackLayoutItem(secondRow, true)
                }
            };
        }
        public BindingEditor()
        {
            this.Content = new TableLayout
            {
                Padding = 5,
                Rows    =
                {
                    new TableRow
                    {
                        Cells =
                        {
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Tip Bindings",
                                    Content = new StackView
                                    {
                                        Items =
                                        {
                                            new Group
                                            {
                                                Text          = "Tip Button",
                                                Orientation   = Orientation.Horizontal,
                                                ExpandContent = false,
                                                Content       = tipButton = new BindingDisplay
                                                {
                                                    MinimumSize = new Size(300, 0)
                                                }
                                            },
                                            new Group
                                            {
                                                Text        = "Tip Pressure",
                                                Orientation = Orientation.Horizontal,
                                                Content     = tipPressure = new FloatSlider()
                                            }
                                        }
                                    }
                                }
                            },
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Eraser Bindings",
                                    Content = new StackView
                                    {
                                        Items =
                                        {
                                            new Group
                                            {
                                                Text          = "Eraser Button",
                                                ExpandContent = false,
                                                Orientation   = Orientation.Horizontal,
                                                Content       = eraserButton = new BindingDisplay
                                                {
                                                    MinimumSize = new Size(300, 0)
                                                }
                                            },
                                            new Group
                                            {
                                                Text        = "Eraser Pressure",
                                                Orientation = Orientation.Horizontal,
                                                Content     = eraserPressure = new FloatSlider()
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    new TableRow
                    {
                        Cells =
                        {
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Pen Button Bindings",
                                    Content = new Scrollable
                                    {
                                        Border  = BorderType.None,
                                        Content = penButtons = new BindingDisplayList
                                        {
                                            Prefix = "Pen Button"
                                        }
                                    }
                                }
                            },
                            new TableCell
                            {
                                ScaleWidth = true,
                                Control    = new Group
                                {
                                    Text    = "Auxiliary Button Bindings",
                                    Content = new Scrollable
                                    {
                                        Border  = BorderType.None,
                                        Content = auxButtons = new BindingDisplayList
                                        {
                                            Prefix = "Auxiliary Button"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            tipButton.StoreBinding.Bind(SettingsBinding.Child(c => c.TipButton));
            eraserButton.StoreBinding.Bind(SettingsBinding.Child(c => c.EraserButton));
            tipPressure.ValueBinding.Bind(SettingsBinding.Child(c => c.TipActivationPressure));
            eraserPressure.ValueBinding.Bind(SettingsBinding.Child(c => c.EraserActivationPressure));
            penButtons.ItemSourceBinding.Bind(SettingsBinding.Child(c => (IList <PluginSettingStore>)c.PenButtons));
            auxButtons.ItemSourceBinding.Bind(SettingsBinding.Child(c => (IList <PluginSettingStore>)c.AuxButtons));
        }
 public BindingEditor()
 {
     this.Content = new TableLayout
     {
         Padding = 5,
         Rows    =
         {
             new TableRow
             {
                 Cells =
                 {
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Tip Bindings",
                             Content = new StackView
                             {
                                 Items =
                                 {
                                     new Group
                                     {
                                         Text          = "Tip Button",
                                         Orientation   = Orientation.Horizontal,
                                         ExpandContent = false,
                                         Content       = tipButton = new BindingDisplay
                                         {
                                             MinimumSize = new Size(300, 0)
                                         }
                                     },
                                     new Group
                                     {
                                         Text        = "Tip Pressure",
                                         Orientation = Orientation.Horizontal,
                                         Content     = tipPressure = new FloatSlider()
                                     }
                                 }
                             }
                         }
                     },
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Eraser Bindings",
                             Content = new StackView
                             {
                                 Items =
                                 {
                                     new Group
                                     {
                                         Text          = "Eraser Button",
                                         ExpandContent = false,
                                         Orientation   = Orientation.Horizontal,
                                         Content       = eraserButton = new BindingDisplay
                                         {
                                             MinimumSize = new Size(300, 0)
                                         }
                                     },
                                     new Group
                                     {
                                         Text        = "Eraser Pressure",
                                         Orientation = Orientation.Horizontal,
                                         Content     = eraserPressure = new FloatSlider()
                                     }
                                 }
                             }
                         }
                     }
                 }
             },
             new TableRow
             {
                 Cells =
                 {
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Pen Button Bindings",
                             Content = new Scrollable
                             {
                                 Border  = BorderType.None,
                                 Content = penButtons = new BindingDisplayList
                                 {
                                     Prefix = "Pen Button"
                                 }
                             }
                         }
                     },
                     new TableCell
                     {
                         ScaleWidth = true,
                         Control    = new Group
                         {
                             Text    = "Auxiliary Button Bindings",
                             Content = new Scrollable
                             {
                                 Border  = BorderType.None,
                                 Content = auxButtons = new BindingDisplayList
                                 {
                                     Prefix = "Auxiliary Button"
                                 }
                             }
                         }
                     }
                 }
             }
         }
     };
 }