Noesis.Vector2 property naming doesn't match System.Windows.Vector
Posted: 27 Jun 2023, 19:29
In System.Windows.Vector, the X and Y properties are defined as capitals ("X" and "Y"). But in the Noesis implementation of Vector2, the properties are defined as lowercase ("x" and "y"). Using the System.Windows.Vector in the XAML ends up throwing errors that there is no binding for the X property.
For example:
and in the Xaml:
Will throw the following errors:
I was curious if there was a specific reason the properties are different in their capitalization?
Are there any issues I'm unaware of in implementing this change?
Is there a better way to represent Vector2 (or Vector3) data that I'm not aware of?
Using System.Numerics.Vector2 has no properties defined in the C# side, so Blend doesn't like it.
For example:
Code: Select all
using System.Windows;
public class ControllerVisualizationContext
{
...
public ControllerInput ControllerInput { get; set; }
}
public class ControllerInput
{
...
// Ranged -1 to 1. Inactive = 0
public Vector LStick { get; set; }
...
}
Code: Select all
<TextBlock x:Name="PreciseValue_L_Analog" Text="{Binding ControllerInput.LStick.X, StringFormat=\{0:F2\}}" />I can eliminate this if I modify the Vector2 reflection to add the capital accessors:Can't solve PropertyPath: Type 'Vector2' does not contain a property named 'X'
Binding failed: Path=ControllerInput.LStick.X, Source=Noesis.ControllerVisualizationContext.f1de4b00(''), Target=TextBlock('PreciseValue_L_Analog'), TargetProperty=TextBlock.Text
Code: Select all
NS_IMPLEMENT_INLINE_REFLECTION(Vector2, NoParent)
{
NsProp("x", &Vector2::x);
NsProp("y", &Vector2::y);
NsProp("X", &Vector2::x); // added
NsProp("Y", &Vector2::y); // added
}
Are there any issues I'm unaware of in implementing this change?
Is there a better way to represent Vector2 (or Vector3) data that I'm not aware of?
Using System.Numerics.Vector2 has no properties defined in the C# side, so Blend doesn't like it.