private StackLayout ObterFormLista() { StackLayout layoutPrincipal = ObterLayoutPrincipal(); layoutPrincipal.WidthRequest = 350; StackLayout layoutOpcoes = new StackLayout(); layoutOpcoes.Padding = new Thickness(0, 0, 0, 0); layoutOpcoes.HorizontalOptions = LayoutOptions.CenterAndExpand; ListView listView = new ListView(); listView.HeightRequest = 200; listView.BackgroundColor = Color.FromHex("#FFFFFF"); listView.SeparatorColor = Color.FromHex("#B6B6B6"); DataTemplate cell = new DataTemplate(() => { ViewCell vCell = new ViewCell(); StackLayout layout = new StackLayout(); layout.HorizontalOptions = LayoutOptions.FillAndExpand; layout.VerticalOptions = LayoutOptions.CenterAndExpand; layout.Orientation = StackOrientation.Horizontal; CheckBoxView check = new CheckBoxView(); check.SetBinding(CheckBoxView.IsCheckedProperty, new Binding("selecionado", BindingMode.TwoWay)); layout.Children.Add(check); Label lblDescricao = new Label() { TextColor = Color.FromHex("#212121"), FontSize = 17 }; lblDescricao.SetBinding(Label.TextProperty, new Binding("descricao", BindingMode.OneWay)); layout.Children.Add(lblDescricao); vCell.View = layout; return(vCell); }); listView.ItemTemplate = cell; listView.ItemsSource = Item.Opcoes; layoutOpcoes.Children.Add(listView); //layoutPrincipal.HeightRequest = 300; layoutPrincipal.Children.Add(layoutOpcoes); layoutPrincipal.Children.Add(ObterLayoutBotoes()); return(layoutPrincipal); }
public void Initialize(int nivel, bool temFilhos) { Spacing = 0; StackLayout node = new StackLayout(); node.Spacing = 0; if (temFilhos) { node.Padding = new Thickness(10 + (5 * nivel), 4, 0, 4); } else { node.Padding = new Thickness(30 + (10 * nivel), 4, 0, 4); } node.Orientation = StackOrientation.Horizontal; if (count % 2 == 0) { node.BackgroundColor = Color.FromHex("#DEDEDE"); } else { node.BackgroundColor = Color.FromHex("#FFFFFF"); } StackLayout layoutCheck = new StackLayout(); layoutCheck.Padding = new Thickness(0, 0, 5, 0); Check = new CheckBoxView(); Check.VerticalOptions = LayoutOptions.Center; Check.SetBinding(CheckBoxView.IsCheckedProperty, new Binding("Item.Pesquisa04.selecionado", BindingMode.TwoWay)); Check.Checked += Check_Checked; layoutCheck.Children.Add(Check); StackLayout layoutImage = new StackLayout(); Botao = new ImageButtonItemArvore() { Source = "minus.png" }; Botao.SetBinding(ImageButtonItemArvore.CommandProperty, new Binding("CmdExpand", BindingMode.OneWay)); layoutImage.Children.Add(Botao); StackLayout layoutLabel = new StackLayout(); layoutLabel.HorizontalOptions = LayoutOptions.FillAndExpand; layoutLabel.Padding = new Thickness(5, 2, 0, 0); if (temFilhos) { Label label = new Label() { Text = Pesquisa04.descricao, FontSize = 17, VerticalOptions = LayoutOptions.Center, TextColor = Color.FromHex("#212121") }; label.FontAttributes = FontAttributes.Bold; layoutLabel.Children.Add(label); } else { LabelItemArvoreFormulario label = new LabelItemArvoreFormulario(Pesquisa04); label.SetBinding(LabelItemArvoreFormulario.CommandProperty, new Binding("CmdShowDialogResposta", BindingMode.OneWay)); label.BindingContext = this.BindingContext; layoutLabel.Children.Add(label); } Image imgFiltro = new Image(); imgFiltro.Source = "ic_filter_grey600_24dp.png"; imgFiltro.WidthRequest = 22; imgFiltro.HeightRequest = 22; //imgFiltro.Margin = new Thickness(0, 0, 10, 0); imgFiltro.SetBinding(Image.IsVisibleProperty, new Binding("TemFiltro", BindingMode.OneWay)); node.Children.Add(layoutCheck); if (temFilhos) { node.Children.Add(layoutImage); } node.Children.Add(layoutLabel); if (!temFilhos) { node.Children.Add(imgFiltro); } IsExpanded = true; Children.Add(node); }