Esempio n. 1
0
        Control WrapLabel()
        {
            const string text  = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
            var          label = new Label
            {
                Text = text
            };

            var wrapDropDown = new EnumDropDown <WrapMode>();

            wrapDropDown.SelectedValueBinding.Bind(label, l => l.Wrap);

            var textAlignmentDropDown = new EnumDropDown <TextAlignment>();

            textAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.TextAlignment);

            var verticalAlignmentDropDown = new EnumDropDown <VerticalAlignment>();

            verticalAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.VerticalAlignment);

            var testVerticalAlignment = new CheckBox {
                Text = "Test VerticalAlignment"
            };

            testVerticalAlignment.CheckedChanged += (sender, e) => label.Size = new Size(-1, testVerticalAlignment.Checked == true ? 200 : -1);
            testVerticalAlignment.CheckedBinding.Bind(verticalAlignmentDropDown, c => c.Enabled, DualBindingMode.OneWayToSource);

            var fontSelector = new FontPicker();

            fontSelector.Bind(c => c.Value, label, l => l.Font);

            Func <Control> spacer = () => new Panel {
                BackgroundColor = Colors.DarkGray, Size = new Size(10, 10)
            };

            return(new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    TableLayout.Horizontal(5,    null,  "Wrap:",               wrapDropDown,              "Font:",          fontSelector,          null),
                    TableLayout.Horizontal(5,    null,  testVerticalAlignment, verticalAlignmentDropDown, "TextAlignment:", textAlignmentDropDown, null),
                    spacer(),
                    new TableLayout(
                        new TableRow(
                            spacer(),
                            new TableCell(label, true),
                            spacer()
                            )
                        ),
                    spacer()
                }
            });
        }
Esempio n. 2
0
        Control WrapLabel()
        {
            var label = new Label
            {
                Text = Utility.LoremText
            };

            var wrapDropDown = new EnumDropDown <WrapMode>();

            wrapDropDown.SelectedValueBinding.Bind(label, l => l.Wrap);

            var textAlignmentDropDown = new EnumDropDown <TextAlignment>();

            textAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.TextAlignment);

            var verticalAlignmentDropDown = new EnumDropDown <VerticalAlignment>();

            verticalAlignmentDropDown.SelectedValueBinding.Bind(label, l => l.VerticalAlignment);

            var testVerticalAlignment = new CheckBox {
                Text = "Test VerticalAlignment"
            };

            testVerticalAlignment.CheckedChanged += (sender, e) => label.Size = new Size(-1, testVerticalAlignment.Checked == true ? 200 : -1);
            testVerticalAlignment.CheckedBinding.Bind(verticalAlignmentDropDown, c => c.Enabled, DualBindingMode.OneWayToSource);

            var fontSelector = new FontPicker();

            fontSelector.Bind(c => c.Value, label, l => l.Font);

            Func <Control> spacer = () => new Panel {
                BackgroundColor = Colors.DarkGray, Size = new Size(10, 10)
            };

            return(new StackLayout
            {
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                Items =
                {
                    TableLayout.Horizontal(5,    null,  "Wrap:",               wrapDropDown,              "Font:",          fontSelector,          null),
                    TableLayout.Horizontal(5,    null,  testVerticalAlignment, verticalAlignmentDropDown, "TextAlignment:", textAlignmentDropDown, null),
                    spacer(),
                    new TableLayout(
                        new TableRow(
                            spacer(),
                            new TableCell(label, true),
                            spacer()
                            )
                        ),
                    spacer()
                }
            });
        }