Hi
In a project I have used a BasePage which have a CustomView inside it, and I set the customview differently.
For example
namespace XXX.Page
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class BaseFunctionalityPage : ContentPage
{
public static readonly BindableProperty CustomViewProperty = BindableProperty.Create(nameof(CustomView), typeof(ContentView), typeof(BaseFunctionalityPage));
public ContentView CustomView
{
get { return (ContentView)GetValue(CustomViewProperty); }
set { SetValue(CustomViewProperty, value); }
}
public BaseFunctionalityPage()
{
InitializeComponent();
}
public BaseFunctionalityPage(ContentView customView, object viewModel, RowDefinitionCollection rowDefinitions = null)
{
InitializeComponent();
CustomView = customView;
BindingContext = viewModel;
}
}
}
int the xml I have this:
<ContentView
Grid.Row="1"
Grid.Column="0"
Margin="0"
Padding="0"
Content="{Binding Source={x:Reference this}, Path=CustomView}" />
Then I have my ContentView, for example your tickets:
<?xml version="1.0" encoding="UTF-8" ?>
<ContentView
x:Class="TesiBoom.View.Functionality.Inventario.InventarioView"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:customview="clr-namespace:TesiBoom.CustomView"
xmlns:viewmodel="clr-namespace:TesiBoom.ViewModel.Functionality.Inventario"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:DataType="viewmodel:InventarioViewModel">
<ContentView.Content>
<Grid
ColumnDefinitions="*,*"
IsEnabled="{Binding BarcodeData, Converter={StaticResource IsNotNullOrEmptyConverter}}"
Opacity="{Binding BarcodeData, Converter={StaticResource IsNullToOpacityConverter}}"
RowDefinitions="*,*">
<customview:QuantityView
Title="{xct:Translate Colli}"
Grid.Row="{Binding ColliRow}"
Grid.Column="{Binding ColliColumn}"
IsEnabled="{Binding IsColliEnabled}"
IsVisible="{Binding IsColliVisibile}"
Quantity="{Binding QtaColli}" />
<customview:QuantityView
Title="{Binding CurrentBarcodeData.Data.PesoVariabile, Converter={StaticResource PesoVariabileToStringConverter}}"
Grid.Row="{Binding PzKgRow}"
Grid.Column="{Binding PzKgColumn}"
IsVisible="{Binding IsPzKgVisibile}"
Quantity="{Binding QtaPzKg}" />
<customview:LabelView
Title="{xct:Translate QtaTotaleRilevata}"
Grid.Row="{Binding QtaTotaleRilevataRow}"
Grid.Column="{Binding QtaTotaleRilevataColumn}"
Text="{Binding QtaTotaleRilevata}" />
<customview:LabelView
Title="{xct:Translate TotaleContato}"
Grid.Row="{Binding TotaleContatoRow}"
Grid.Column="{Binding TotaleContatoColumn}"
IsVisible="{Binding IsTotaleContatoVisibile}"
Text="{Binding TotaleContato}" />
</Grid>
</ContentView.Content>
</ContentView>
then, I add programmatically the content to the page and push it in the stack like this
await Display.PushAsync(new BaseFunctionalityPage(new InventarioView(), new InventarioViewModel(SelectedIndexZona, SelectedTipoRilevazione, NumeroZona, Corsia, Scaffale)));