Page 1 of 1

Binding Multiple Values to a Margin

Posted: 18 Mar 2020, 14:09
by jpattersonCSpeed
Hello again,

I am trying to apply a margin to an element that will eventually have bindings to make certain sides of the margin change based on calculations. In WPF, this is achieved through the following link under "XAML Property Element Usage":
https://docs.microsoft.com/en-us/dotnet ... ment-usage

A quick demo app in WPF with a TextBlock confirms that this works as described:
<TextBlock Text="Some Text">
  <TextBlock.Margin>
    <Thickness Left="100" Top="100" Bottom="0" Right="0"/>
  </TextBlock.Margin>
</TextBlock>
The same code inside of Noesis doesn't produce the same results, and running it in the XAMLtoy app produces errors stating "Can't assign property to abstract class 'Thickness'." Since this is different behavior from WPF is this considered a bug? If it is not a bug, is there a different workflow that produces the same results?
Thanks.

Re: Binding Multiple Values to a Margin

Posted: 18 Mar 2020, 17:31
by sfernandez
In WPF you can specify a Thickness value using their individual properties (we don't support this in Noesis), but you won't be able to use bindings to set those properties:
<TextBlock Text="Some Text">
  <TextBlock.Margin>
    <Thickness Left="{Binding LeftMargin}" Top="100" Bottom="0" Right="0"/>
  </TextBlock.Margin>
</TextBlock>
This will throw the error: "A 'Binding' cannot be set on the 'Left' property of type 'Thickness'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject".

Struct properties should be set as a whole object via bindings:
<TextBlock Text="Some Text" Margin="{Binding TextMargin}"/>

Re: Binding Multiple Values to a Margin

Posted: 18 Mar 2020, 21:46
by jpattersonCSpeed
Ah I would have thought that the binding would have worked. No worries, this is a hint that I have to change up the area of the UI that was going to use this to be something better. Thanks.