Data Binding to property with name "Name" does not work.
Hey!
I have a small element that uses databindings and found something I can't explain.
If I call my bound property "Name" it doesn't evaluate properly. If I call it anything else but "Name" it does.
Is that some kind of hidden protected property name I shouldn't use?
Here an excerpt of my surrounding code:
.h of my UserControl:
Noesis::String Name = "GameMode Name";
.cpp of my UserControl:
NS_IMPLEMENT_REFLECTION(GameModeSelectionElement)
{
//NsProp("Name", &GameModeSelectionElement::Name); --> THIS DOES NOT WORK!
NsProp("GameModeName", &GameModeSelectionElement::Name); --> THIS WORKS?!
}
XAML:
//<Label HorizontalAlignment="Center" FontSize="36" Content="{Binding Name}"/> --> THIS in combination with the commented "Name" property DOES NOT WORK!
<Label HorizontalAlignment="Center" FontSize="36" Content="{Binding GameModeName}"/> --> THIS in combination with the "GameModeName" property DOES WORK!
I have a small element that uses databindings and found something I can't explain.
If I call my bound property "Name" it doesn't evaluate properly. If I call it anything else but "Name" it does.
Is that some kind of hidden protected property name I shouldn't use?
Here an excerpt of my surrounding code:
.h of my UserControl:
Noesis::String Name = "GameMode Name";
.cpp of my UserControl:
NS_IMPLEMENT_REFLECTION(GameModeSelectionElement)
{
//NsProp("Name", &GameModeSelectionElement::Name); --> THIS DOES NOT WORK!
NsProp("GameModeName", &GameModeSelectionElement::Name); --> THIS WORKS?!
}
XAML:
//<Label HorizontalAlignment="Center" FontSize="36" Content="{Binding Name}"/> --> THIS in combination with the commented "Name" property DOES NOT WORK!
<Label HorizontalAlignment="Center" FontSize="36" Content="{Binding GameModeName}"/> --> THIS in combination with the "GameModeName" property DOES WORK!
-
-
sfernandez
Site Admin
- Posts: 3198
- Joined:
Re: Data Binding to property with name "Name" does not work.
Hello,
The "Name" property is already defined by the UserControl's base class FrameworkElement. As indicated in the documentation the dependency property "Name" provides a reference so that code-behind, such as event handler code, can refer to a markup element after it is constructed by the XAML parser.
This property is typically set in XAML by using the x:Name attribute:
Control inherited classes should not define a "Name" property, you should use a different name in that case.
The "Name" property is already defined by the UserControl's base class FrameworkElement. As indicated in the documentation the dependency property "Name" provides a reference so that code-behind, such as event handler code, can refer to a markup element after it is constructed by the XAML parser.
This property is typically set in XAML by using the x:Name attribute:
Code: Select all
<MyUserControl x:Name="MyControl".../>
-
- KeldorKatarn
- Posts: 234
- Joined:
Re: Data Binding to property with name "Name" does not work.
Name indeed should be avoided. That's the property that's used for a lot, including Bindings using ElementName as the source.Hey!
I have a small element that uses databindings and found something I can't explain.
If I call my bound property "Name" it doesn't evaluate properly. If I call it anything else but "Name" it does.
Is that some kind of hidden protected property name I shouldn't use?
[...]
And not to mention Caliburn uses that for its conventions ;)
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 2 guests