I'm trying to figure out how to get the "View size" of an image which is set as the background on a Canvas
control.
The background is set with a ImageBrush
, with strech set to UniForm.
If the strech property was set to Fill, then I could just use the ActualWidth and ActualHeight of the canvas.
This is not possible with UniForm, so how should I approach this?
Here is my XAML:
<Grid DataContext="{Binding ImageViewerVM.CurrentImage}">
<controls:RubberBandingCanvas x:Name="RubCanvas">
<controls:RubberBandingCanvas.Resources>
<Converters:ControlVisibilityConverter x:Key="VisibilityHiddenConverter" />
<Converters:StringToBitmapConverter x:Key="StringToBitmapConverter" />
</controls:RubberBandingCanvas.Resources>
<controls:RubberBandingCanvas.Background>
<ImageBrush x:Name="ibCurrentImage" ImageSource="{Binding Path=Path, Converter={StaticResource StringToBitmapConverter}}" Stretch="Uniform"></ImageBrush>
</controls:RubberBandingCanvas.Background>
<Ellipse Canvas.Top="10" Canvas.Right="10" Fill="Red" Stroke="Black" Height="15" Width="15" Visibility="{Binding Path=IsMultiTiff, Converter={StaticResource VisibilityHiddenConverter}}"/>
</controls:RubberBandingCanvas>
</Grid>
Best regards,
Jesper Jensen