I have this code:
using System;
using Xamarin.Forms;
namespace Test
{
public partial class ScrollHeadingView : ContentPage
{
public ScrollHeadingView()
{
// more code here
if (RightIconVisible)
{
// do some actions to add elements to each other here
var rightIconPageHeadingSvg = new PageHeadingSvg() { HorizontalOptions = LayoutOptions.StartAndExpand }
.Bind(PageHeadingSvg.SourceProperty, nameof(RightIconSource), source: this);
grid3.AddChild(rightIconPageHeadingSvg);
grid2.GestureRecognizers.Add(rightIconTap);
grid3.AddChild(rightIconPageHeadingSvg);
}
}
}
and
public partial class DecksTabPage : ScrollHeadingView
{
public DecksTabViewModel vm;
public DecksTabPage()
{
RightIconVisible = true;
BindingContext = vm = new DecksTabViewModel();
InitializeComponent();
}
protected override void OnAppearing()
{
base.OnAppearing();
vm.OnAppearing();
}
}
I am setting RightIconVisible to true and want that to be reflected in ScrollHeadingView when it is constructed.
But it's not happening.
Is there a way that I can set this to happen with code in DecksTabPage?
Note that if I was using XAML I would have done this by binding to the IsVisible of a grid and then set the IsVisible to show or not show that code that has the elements. But as I am using C# I am not sure how to do this.