I would like to bind a scaleTransform to a converter passing the ActualWidth
or ActualHeight
.
Here what I want to do :
<Canvas x:Name="Canevas">
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type UIElement}},
Path=ActualWidth, Mode=OneWay,
Converter={StaticResource ScaleConverter},
ConverterParameter={Binding Path=ActualWidth}"
ScaleY="{Binding RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type UIElement}},
Path=ActualHeight, Mode=OneWay,
Converter={StaticResource ScaleConverter},
ConverterParameter={Binding Path=ActualHeight}}"
/>
</TransformGroup>
</Canvas.RenderTransform>
<Ellipse Canvas.Left="47" Canvas.Top="48" Height="155"
Name="ellipse1" Stroke="Black" Width="174" Fill="#FF00C6C3" />
The problem is this don't compile :
ConverterParameter={Binding Path=ActualHeight}
So I want to know how to move these properties as parameters for my converter? Is it possible to resolve in full Xaml ?
Many thanks for your Help !
Converter source code :
public class ScaleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
double v = (double)value;
var actualSize = (double)parameter; //ActualWidth, ActualHeight
var vScale = v * (1 + (v / actualSize));
return vScale;
}
public object ConvertBack(object value, Type targetType, object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}