Am trying to Load a Content View in a Content page. When I run the code it doesn't hit my Content View. I am assigning two Bindable parameters from my content page.
Content Page:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:templates="clr-namespace:G2.Scanner.Views.Templates"
xmlns:viewModelBase="clr-namespace:G2.Scanner.ViewModels.Base;assembly=G2.Scanner"
xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
xmlns:local ="clr-namespace:G2.Scanner.Views.Transaction"
x:Class="G2.Scanner.Views.Transaction.TransactionView"
viewModelBase:ViewModelLocator.AutoWireViewModel="true">
<local:GenerateScreen x:Name="generateScreen" ControllerName="{Binding ControllerName}" IsBusy="{Binding IsBusy}"/>
</ContentPage>
Content View:
public partial class GenerateScreen : ContentView
{
#region BindableProperties
public static readonly BindableProperty ControllerNameProperty = BindableProperty.Create("ControllerName", typeof(string), typeof(GenerateScreen));
public static readonly BindableProperty IsBusyProperty = BindableProperty.Create("IsBusy", typeof(bool), typeof(GenerateScreen));
#endregion
#region Properties
public string ControllerName
{
get { return (string)GetValue(ControllerNameProperty); }
set { SetValue(ControllerNameProperty, value); }
}
public bool IsBusy
{
get { return (bool)GetValue(IsBusyProperty); }
set { SetValue(IsBusyProperty, value); }
}
#endregion
public GenerateScreen()
{
InitializeComponent();
DesignScreenAsync();
}
public async void DesignScreenAsync()
{
IsBusy = true;
// Some Design code..
#region render
scroll = new ScrollView
{
Content = layout
};
TransactionElements.Children.Add(scroll);
#endregion
IsBusy = false;
}
Content View accepts two bindable property and is used at the time of load.
Content View Xaml:
<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="G2.Scanner.Views.Transaction.GenerateScreen">
<ContentView.Content>
<StackLayout x:Name="TransactionElements"/>
</ContentView.Content>
</ContentView>
I want this view to be rendered at the time content page is loaded. I figured out that this works if I don't use bindable properties in content view. But as per My requirement ControllerName and IsBusy in ContentView Class Should be Bindable Property. Any Help why it's not hitting this View.
DesignScreenAsyncis called? - JohannesDesignScreenAsyncmethod? No one of them was hitten? - Diego Rafael Souza