コード例 #1
0
        public SearchPageView(SearchPageViewModel searchPageViewModel)
        {
            this.searchPageListViewModel = searchPageViewModel.SearchPageEntityViewModel;
            InitializeComponent();
            AddToolBarItems();
            Title = this.searchPageListViewModel.FormSettings.Title;
            this.BindingContext = this.searchPageListViewModel;

            void AddToolBarItems()
            {
                foreach (var button in this.searchPageListViewModel.Buttons)
                {
                    this.ToolbarItems.Add(BuildToolbarItem(button));
                }
            }

            ToolbarItem BuildToolbarItem(CommandButtonDescriptor button)
            => new ToolbarItem
            {
                AutomationId = button.ShortString,
                //Text = button.LongString,
                IconImageSource = new FontImageSource
                {
                    FontFamily = EditFormViewHelpers.GetFontAwesomeFontFamily(),
                    Glyph      = FontAwesomeIcons.Solid[button.ButtonIcon],
                    Size       = 20
                },
                Order            = ToolbarItemOrder.Primary,
                Priority         = 0,
                CommandParameter = button
            }

            .AddBinding(MenuItem.CommandProperty, new Binding(button.Command))
            .SetAutomationPropertiesName(button.ShortString);
        }
コード例 #2
0
        public ReadOnlyMultiSelectPageCS(IReadOnly multiSelectReadOnly)
        {
            this.multiSelectReadOnly           = multiSelectReadOnly;
            this.multiSelectTemplateDescriptor = (MultiSelectTemplateDescriptor)this.multiSelectReadOnly.GetType()
                                                 .GetProperty(nameof(MultiSelectReadOnlyObject <ObservableCollection <string>, string> .MultiSelectTemplate))
                                                 .GetValue(this.multiSelectReadOnly);

            Content = new AbsoluteLayout
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Children          =
                {
                    new ContentView
                    {
                        Content = new StackLayout
                        {
                            Style    = LayoutHelpers.GetStaticStyleResource("MultiSelectPopupViewStyle"),
                            Children =
                            {
                                new Grid
                                {
                                    Style    = LayoutHelpers.GetStaticStyleResource("PopupHeaderStyle"),
                                    Children =
                                    {
                                        new Label
                                        {
                                            Style = LayoutHelpers.GetStaticStyleResource("PopupHeaderLabelStyle"),
                                        }.AddBinding(Label.TextProperty, new Binding("Title"))
                                    }
                                },
                                new Grid
                                {
                                    Children =
                                    {
                                        new CollectionView
                                        {
                                            Style        = LayoutHelpers.GetStaticStyleResource("MultiSelectPopupCollectionViewStyle"),
                                            ItemTemplate = EditFormViewHelpers.GetMultiSelectItemTemplateSelector(this.multiSelectTemplateDescriptor)
                                        }
                                        .AddBinding(ItemsView.ItemsSourceProperty, new Binding("Items"))
                                        .AddBinding(SelectableItemsView.SelectedItemsProperty, new Binding("SelectedItems")),
                                        new BoxView()
                                    }
                                },
                                new BoxView                  {
                                    Style = LayoutHelpers.GetStaticStyleResource("PopupFooterSeparatorStyle")
                                },
                                new Grid
                                {
                                    Style             = LayoutHelpers.GetStaticStyleResource("PopupFooterStyle"),
                                    ColumnDefinitions =
                                    {
                                        new ColumnDefinition {
                                            Width = new GridLength(1, GridUnitType.Star)
                                        },
                                        new ColumnDefinition {
                                            Width = new GridLength(1, GridUnitType.Star)
                                        },
                                        new ColumnDefinition {
                                            Width = new GridLength(1, GridUnitType.Star)
                                        }
                                    },
                                    Children =
                                    {
                                        new Button
                                        {
                                            Style = LayoutHelpers.GetStaticStyleResource("PopupCancelButtonStyle")
                                        }
                                        .AddBinding(Button.CommandProperty, new Binding("CancelCommand"))
                                        .SetGridColumn(2)
                                    }
                                }
                            }
                        }
                    }
                    .AssignDynamicResource(VisualElement.BackgroundColorProperty, "PopupViewBackgroundColor")
                    .SetAbsoluteLayoutBounds(new Rectangle(0, 0, 1, 1))
                    .SetAbsoluteLayoutFlags(AbsoluteLayoutFlags.All)
                }
            };

            this.BackgroundColor = Color.Transparent;
            Visual = VisualMarker.Material;
            this.BindingContext = this.multiSelectReadOnly;
        }