I have a SFExpander with a Grid as its content.
The Page also has a SFDataForm on it.
Based on the selection of one of the fields in the form I am trying to make the expander visible or not.
The field source of the IsVisible target binding is DisplayDependents and is set in the DataFormItemManager SetValue method based on the value of a picker field.
The following code is a snippet of the view.
However when the SFExpander does not show when DisplayDependents is set to true in Set Value.
var layout = new StackLayout
{
Margin = new Thickness(10, 20, 10, 20),
Spacing = 5,
};
policyForm.DataObject = _vm.InsurancePolicy;
// policy info
var policyHeader = new Grid()
{
RowDefinitions =
{
new RowDefinition {Height = new GridLength(1, GridUnitType.Star) },
},
ColumnDefinitions =
{
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star) },
},
BackgroundColor = Color.FromHex(HJHexColors.HJBlack),
Children =
{
new Label()
{
Text = "Policy Information",
TextColor = Color.FromHex(HJHexColors.HJWhite),
Margin = new Thickness(5),
}
}
};
var policyContent = new Grid()
{
RowDefinitions =
{
new RowDefinition {Height = new GridLength(1, GridUnitType.Star) },
},
ColumnDefinitions =
{
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star) },
},
BackgroundColor = Color.FromHex(HJHexColors.HJGray),
Children =
{
policyForm,
}
};
layout.Children.Add(new SfExpander()
{
Header = policyHeader,
Content = policyContent,
HeaderIconPosition = IconPosition.End,
Margin = new Thickness(5),
HeaderBackgroundColor = Color.FromHex(HJHexColors.HJBlack),
IconColor = Color.FromHex(HJHexColors.HJWhite),
IsExpanded = true,
});
// dependent info
var dependentHeader = new Grid()
{
RowDefinitions =
{
new RowDefinition {Height = new GridLength(1, GridUnitType.Star) },
},
ColumnDefinitions =
{
new ColumnDefinition {Width = new GridLength(1, GridUnitType.Star) },
},
BackgroundColor = Color.FromHex(HJHexColors.HJBlack),
Children = {
new Label()
{
Text = "Add Dependents",
TextColor = Color.FromHex(HJHexColors.HJWhite),
Margin = new Thickness(5),
}
}
};
var dependentExpander = new SfExpander()
{
Header = dependentHeader,
Content = MakeDependentGrid(),
HeaderIconPosition = IconPosition.End,
Margin = new Thickness(5),
HeaderBackgroundColor = Color.FromHex(HJHexColors.HJBlack),
IconColor = Color.FromHex(HJHexColors.HJWhite),
IsExpanded = true
};
layout.Children.Add(dependentExpander);
dependentExpander.BindingContext = BindingContext;
var test = dependentExpander.BindingContext;
dependentExpander.SetBinding(IsVisibleProperty, "DisplayDependents");