I'm pretty new to .NET
In .NET MAUI 9.0 I am creating an app based on a custom Layout extending the Grid class, which uses several BindingProperties that i have no issues with:
namespace krizanke_ux.Resources.LayoutResources
{
public partial class ParametricGrid : Grid
{
public static readonly BindableProperty GridWidthProperty =
BindableProperty.Create(nameof(GridWidth), typeof(double), typeof(ParametricGrid), 10.0,
propertyChanged: (b, o, n) => ((ParametricGrid)b).RebuildGrid(),
validateValue: (b, value) => (double)value >= 0.0);
I've now started implementing attached properties for the Grid's children, which raise the following error: XC0009: No property, BindableProperty, or event found for "GridHorizontalAlignment", or mismatching type between value and property.
Here is the appropriate code:
private static readonly BindableProperty GridHorizontalAlignmentProperty =
BindableProperty.CreateAttached("GridHorizontalAlignment",
typeof(LayoutAlignment), typeof(ParametricGrid), LayoutAlignment.Start);
public static LayoutAlignment GetGridHorizontalAlignment(BindableObject view) =>
(LayoutAlignment)view.GetValue(GridHorizontalAlignmentProperty);
public static void SetGridHorizontalAlignment(BindableObject view, LayoutAlignment value) =>
view.SetValue(GridHorizontalAlignmentProperty, value);
<ContentPage ...
xmlns:layout="clr-namespace:krizanke_ux.Resources.LayoutResources"...>
<layout:ParametricGrid ...>
<Entry
Grid.Row="5"
layout:ParametricGrid.GridHorizontalAlignment="Center"
Grid.RowSpan="4"
Grid.ColumnSpan="7"/>
I cannot find the solution anywhere. I've tried using both LayoutOptions and LayoutAlignment, using GridHorizontalAlignmen="{x:Static LayoutAlignment.Center}" even though Visual Studio automatically suggests "Center" in XAML.
public?public. I feel very dumb, because i triple checked every single letter, but did not bother to check the beginning. Thank you.