.Net MAUI Styles.xaml не обнаруживает свойства настраиваемого элемента управления в Visual Studio (XFC0001)C#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 .Net MAUI Styles.xaml не обнаруживает свойства настраиваемого элемента управления в Visual Studio (XFC0001)

Сообщение Anonymous »

Когда я создавал собственные элементы управления в рамках своего проекта, я понял, что мне нужно обеспечить возможность их стилизации с помощью файла Styles.xaml. Для этого мне, видимо, пришлось преобразовать все свойства элемента управления в BindableProperties. Я сделал то же самое с одним из моих пользовательских элементов управления CameraView.xaml, и он работал нормально.
После этого я сделал то же самое с другим моим элементом управления LoadingView. xaml, выполнив те же действия, чтобы превратить все свойства в привязываемые свойства. Все шло нормально, вплоть до того, что я захотел создать для него стиль.
Очевидно, файл Styles.xaml не распознает ни одно из пользовательских свойств элемента управления. . Я действительно не знаю почему, поскольку я выполнил те же действия, что и при первом контроле. Стоит отметить, что он распознает все стандартные свойства ContentView, но ни одно из созданных мной свойств.
Я потратил много времени, пытаясь чтобы понять, почему это не работает, пока все безрезультатно. Я также экспериментировал, изменяя некоторые свойства, перестраивая все решение, закрывая и открывая VisualStudio и т. д. и т. п. Все безрезультатно.
Поэтому хочу спросить: есть ли что-то не так с тем, как я написал свойства? Их довольно много, и я заранее прошу прощения, но я действительно не знаю, что делать на данный момент.
LoadingView.xaml.cs:

Код: Выделить всё

(...)
/// 
/// Gets or sets the title's style.
/// 
public Style StyleTitle
{
set => SetValue(StyleTitleProperty, value);
get => (Style)GetValue(StyleTitleProperty);
}
/// 
/// StyleTitle bindable property.
/// 
public readonly BindableProperty StyleTitleProperty = BindableProperty.Create(nameof(StyleTitle), typeof(Style), typeof(LoadingView));

/// 
/// Gets or sets the text's style.
/// 
public Style StyleText
{
set => SetValue(StyleTextProperty, value);
get => (Style)GetValue(StyleTextProperty);
}
/// 
/// StyleText bindable property.
/// 
public readonly BindableProperty StyleTextProperty = BindableProperty.Create(nameof(StyleText), typeof(Style), typeof(LoadingView));

/// 
/// Gets or sets the retry button's style.
/// 
public Style StyleButton
{
set => SetValue(StyleButtonProperty, value);
get => (Style)GetValue(StyleButtonProperty);
}
/// 
/// StyleButton bindable property.
/// 
public readonly BindableProperty StyleButtonProperty = BindableProperty.Create(nameof(StyleButton), typeof(Style), typeof(LoadingView));

/// 
/// Gets or sets the current lottie source.
/// 
public SKLottieImageSource? LottieSource
{
set => SetValue(LottieSourceProperty, value);
get => GetValue(LottieSourceProperty) as SKLottieImageSource;
}
/// 
/// LottieSource bindable property.
/// 
public readonly BindableProperty LottieSourceProperty = BindableProperty.Create(nameof(LottieSource), typeof(SKLottieImageSource), typeof(LoadingView));

/// 
/// Gets or sets the image source for when the view is loading.
/// 
public SKLottieImageSource? LoadingLottieSource
{
set => SetValue(LoadingLottieSourceProperty, value);
get => GetValue(LoadingLottieSourceProperty) as SKLottieImageSource;
}
/// 
/// LoadingLottieSource bindable property.
/// 
public readonly BindableProperty LoadingLottieSourceProperty = BindableProperty.Create(nameof(LoadingLottieSource), typeof(SKLottieImageSource), typeof(LoadingView));

/// 
/// Gets or sets the image source for when an exception is thrown while loading.
/// 
public SKLottieImageSource? ErrorLottieSource
{
set => SetValue(ErrorLottieSourceProperty, value);
get => GetValue(ErrorLottieSourceProperty) as SKLottieImageSource;
}
/// 
/// ErrorLottieSource bindable property.
/// 
public readonly BindableProperty ErrorLottieSourceProperty = BindableProperty.Create(nameof(ErrorLottieSource), typeof(SKLottieImageSource), typeof(LoadingView));

/// 
/// Gets or sets the view's title.
/// 
public string? Title
{
set => SetValue(TitleProperty, value);
get => GetValue(TitleProperty) as string;
}
/// 
/// Title bindable property.
/// 
public readonly BindableProperty TitleProperty = BindableProperty.Create(nameof(Title), typeof(string), typeof(LoadingView));

/// 
/// Gets or sets the view's text.
/// 
public string? Text
{
set => SetValue(TextProperty, value);
get => GetValue(TextProperty) as string;
}
/// 
/// Text bindable property.
/// 
public readonly BindableProperty TextProperty = BindableProperty.Create(nameof(Text), typeof(string), typeof(LoadingView));

/// 
/// Gets or sets the title for when the view is loading.
/// 
public string? LoadingTitle
{
set => SetValue(LoadingTitleProperty, value);
get =>  GetValue(LoadingTitleProperty) as string;
}
/// 
/// LoadingTitle bindable property.
/// 
public readonly BindableProperty LoadingTitleProperty = BindableProperty.Create(nameof(LoadingTitle), typeof(string), typeof(LoadingView));

/// 
/// Gets or sets the text for when the view is loading.
/// 
public string? LoadingText
{
set => SetValue(LoadingTextProperty, value);
get => GetValue(LoadingTextProperty) as string;
}
/// 
/// LoadingText bindable property.
/// 
public readonly BindableProperty LoadingTextProperty = BindableProperty.Create(nameof(LoadingText), typeof(string), typeof(LoadingView));

/// 
/// Gets or sets the title for when the view throws an exception.
/// 
public string? ErrorTitle
{
set => SetValue(ErrorTitleProperty, value);
get => GetValue(ErrorTitleProperty) as string;
}
/// 
/// ErrorTitle bindable property.
/// 
public readonly BindableProperty ErrorTitleProperty = BindableProperty.Create(nameof(ErrorTitle), typeof(string), typeof(LoadingView));

/// 
/// Gets or sets the text for when the view throws an exception.  Can use string.Format with the following indexes:
/// 0: The exception type;
/// 1: The exception message.
/// 
public string? ErrorText
{
set => SetValue(ErrorTextProperty, value);
get => GetValue(ErrorTextProperty) as string;
}
/// 
/// ErrorText bindable property.
/// 
public readonly BindableProperty ErrorTextProperty = BindableProperty.Create(nameof(ErrorText), typeof(string), typeof(LoadingView));

/// 
/// Gets or sets the retry button's text.
/// 
public string? ButtonText
{
set => SetValue(ButtonTextProperty, value);
get => GetValue(ButtonTextProperty) as string;
}
/// 
/// ButtonText bindable property.
/// 
public readonly BindableProperty ButtonTextProperty = BindableProperty.Create(nameof(ButtonText), typeof(string), typeof(LoadingView));

/// 
/// Gets or sets the lottie's repeat count.
/// 
public int LottieRepeat
{
set => SetValue(LottieRepeatProperty, value);
get => (int)GetValue(LottieRepeatProperty);
}
/// 
/// LottieRepeat bindable property.
/// 
public readonly BindableProperty LottieRepeatProperty = BindableProperty.Create(nameof(LottieRepeat), typeof(int), typeof(LoadingView));

/// 
/// Number of times that the loading lottie has to repeat.
/// 
public int LoadingLottieRepeat
{
set => SetValue(LoadingLottieRepeatProperty, value);
get => (int)GetValue(LoadingLottieRepeatProperty);
}
/// 
/// LoadingLottieRepeat bindable property.
/// 
public readonly BindableProperty LoadingLottieRepeatProperty = BindableProperty.Create(nameof(LoadingLottieRepeat), typeof(int), typeof(LoadingView));
(...)
LoadingView.xaml: Styles.xaml:

Код: Выделить всё

(...)














(...)
Буду признателен за любую помощь, которая прольет мне свет в этом вопросе. Заранее спасибо!
РЕДАКТИРОВАТЬ: даже если я принудительно добавлю пользовательское свойство в стиль элемента управления, компилятор выдаст следующее исключение:

Код: Выделить всё

XFC0001: Cannot resolve property "LoadingTitle" on type "LoadingView (property missing or missing accessors)".
Похоже, что компилятор по какой-то причине не может обнаружить ни одно из пользовательских свойств.

Подробнее здесь: https://stackoverflow.com/questions/792 ... ual-studio
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»