c# - Scaling image to canvas parent height in WPF -


i'm new wpf , trying simple. i'm making custom control canvas have image higher canvas. when displays overflows canvas, want scale parent height. there's easy answer haven't found yet.

here's xaml:

<usercontrol x:class="wpfusercontrol.instance"              name="instancebox"              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"               xmlns:d="http://schemas.microsoft.com/expression/blend/2008"               mc:ignorable="d"               width="448" height="99.2">     <grid name="instancegrid" background="white" x:fieldmodifier="public" margin="0,0,0,0.2">         <canvas>             <image                  horizontalalignment="left"                   source="pack://siteoforigin:,,,/resources/m-series-single.jpg" />         </canvas>     </grid> </usercontrol> 

if rid of canvas (because doesn't measure children) , instead use stretch property of image, should able behaviour require. if not, might experiment viewbox.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -