🔹 NumberToThicknessConverter Class
namespace NoesisApp
Converts numeric values into a Thickness structure for layout properties like Margin or Padding.
NumberToThicknessConverter can be used as both an IValueConverter and an IMultiValueConverter:
- Binding: Converts a single numeric value into a Thickness. The sides affected by this value are determined by the Format property (e.g., creating a left-only margin).
- MultiBinding: Accepts 1, 2, or 4 numeric bindings and converts them into a Thickness, mirroring standard XAML formatting rules (Uniform, Horizontal/Vertical, Left/Top/Right/Bottom).
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions">
<Grid.Resources>
<noesis:NumberToThicknessConverter x:Key="LeftMarginConverter" Format="Left" />
<noesis:NumberToThicknessConverter x:Key="MultiMarginConverter" />
</Grid.Resources>
<TextBlock Text="Indented Text" Margin="{Binding Indent,
Converter={StaticResource LeftMarginConverter}}" />
<Border>
<Border.Padding>
<MultiBinding Converter="{StaticResource MultiMarginConverter}">
<Binding Path="HorizontalPad" />
<Binding Path="VerticalPad" />
</MultiBinding>
</Border.Padding>
</Border>
</Grid>
Properties
NumberToThicknessConverter has no properties
Attached Properties
NumberToThicknessConverter has no attached properties
Methods
From BaseValueConverter
| Name | Description |
|---|---|
| ◆ TryConvert(BaseComponent*, const Type*, BaseComponent*, Ptr<BaseComponent>&) | The data binding engine calls this method when it propagates a value from the binding source to the binding target. Return DependencyProperty.UnsetValue to indicate that the converter produced no value and that the fallback (if available) or default value should be used instead. Return Binding.DoNothing to indicate that the binding should not transfer the value or use the fallback or default value. |
| ◆ TryConvertBack(BaseComponent*, const Type*, BaseComponent*, Ptr<BaseComponent>&) | The data binding engine calls this method when it propagates a value from the binding target to the binding source. Return Binding.DoNothing to indicate that no value should be set on the source property. Return DependencyProperty.UnsetValue to indicate that the converter is unable to provide a value for the source property, and no value will be set to it. |
Events
NumberToThicknessConverter has no events