1. 程式人生 > >wpf讓圖片自適應容器大小,而且又不會拉昇變形

wpf讓圖片自適應容器大小,而且又不會拉昇變形

 1         <Grid Grid.Column="3"
 2               Margin="0,4,0,0"
 3               Background="Black">
 4             <Viewbox>
 5                 <Image Width="{Binding RelativeSource={RelativeSource Self}, Path=Source.PixelWidth}"
 6                        Height="{Binding RelativeSource={RelativeSource Self}, Path=Source.PixelHeight}
" 7 Source="{Binding CtrlImage, IsAsync=True}" 8 Stretch="None" /> 9 </Viewbox> 10 </Grid>