I simplify everything to better focus the problem
this is the page that displays the cardview
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:controls="clr-namespace:TestCard"
x:Class="TestCard.MainPage"
Title="Test Card">
<ContentPage.Resources>
<ControlTemplate x:Key="TestCardView">
<Label x:Name="lblTitolo" Text="{TemplateBinding TitoloCardView}" />
</ControlTemplate>
</ContentPage.Resources>
<VerticalStackLayout BindingContext="{Binding Source={RelativeSource TemplatedParent}}">
<controls:ControlCardViews x:Name="ctrlName01" TitoloCardView="Questo è il primo Titolo"
ControlTemplate="{StaticResource TestCardView}" />
<controls:ControlCardViews x:Name="ctrlName02" TitoloCardView="Secondo Titolo"
ControlTemplate="{StaticResource TestCardView}" />
</VerticalStackLayout>
</ContentPage>
here i check the cardview data
namespace TestCard;
public class ControlCardViews : ContentView
{
public static readonly BindableProperty TitoloCardViewProperty = BindableProperty.Create(nameof(TitoloCardView), typeof(string),
typeof(ControlCardViews), string.Empty);
public string TitoloCardView
{
get => (string)GetValue(TitoloCardViewProperty);
set => SetValue(TitoloCardViewProperty, value);
}
}
I would like to set/modify the text of the "TitoloCardView" not in the xaml file but as a C# code
I would also like to create this part
<controls:ControlCardViews x:Name="ctrlName01" TitoloCardView="Questo è il primo Titolo"
ControlTemplate="{StaticResource TestCardView}" />
<controls:ControlCardViews x:Name="ctrlName02" TitoloCardView="Secondo Titolo"
ControlTemplate="{StaticResource TestCardView}" />
not as xaml code but C# code thanks
I tried to google it but I couldn't find any idea on how to fix it