Closed cemeceme closed 4 months ago
Thanks for the help! I came across that piece of documentation multiple times, but I think I just figured out why I couldn't get it to work before.
For some reason if I register the property using:
public static readonly AvaloniaProperty<string> stringPropertyProperty =
AvaloniaProperty.Register<test, string>("stringProperty");
it works, but if I change the name of the variable to something like:
public static readonly AvaloniaProperty<string> testProperty =
AvaloniaProperty.Register<test, string>("stringProperty");
which I was using while testing this, then I get the error as before. Trying some more names, it seems any variation from stringPropertyProperty causes an error on my end.
Is there some sort of required naming scheme for defining properties?
You need to fulfill the naming convention.
string String { get.... ; set....}
AvaloniaProperty StringProperty
@grokys I guess another part that needs to be covered in updated documentation for properties.
Oh man, @Gillibald - that caused me so much headache! Definitely echo @MarchingCube that somewhere this needs to say in big red text and neon-flashing lights that the naming really matters in this case
I'm trying to create a usercontrol that will accept some properties, however it appears that it fails with the error:
The main window xaml is:
MainWindows ViewModel is:
The test xaml is:
And the code-behind for test is:
I have also tried to use direct/attached/styled/etc. properties, but nothing seems to have helped.
One thing I have noticed however, is that when not using databinding in the main window, the code does compile and work as expected. I left out bindings in the usercontrol and related code to make sure that wasn't causing the issue, and when using just a static string the property is indeed set properly.
I'm fairly new to Avalonia and mvvm so I might have misconceptions about how usercontrols and their properties work. So if this is intended behavior and I'm using the wrong control or something do tell me, as I have been stuck for the past few days.