开发者

How to reset the Image.Width and Image.Height to auto in code-behind?

开发者 https://www.devze.com 2023-02-28 18:12 出处:网络
In Xaml code, I set the width and height of an Image to Auto. Then, in code-behind, I sometime have to set it to different values. But how can I set it back to Auto in codebehind?

In Xaml code, I set the width and height of an Image to Auto. Then, in code-behind, I sometime have to set it to different values. But how can I set it back to Auto in codebehind?

This is how it looks in the xaml code:

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <Image x:Name="FlickrImage"/>

And in codebehind:

FlickrImage.Source = new BitmapImage(new U开发者_开发技巧ri("/Images/error_image.png", UriKind.Relative));               
            FlickrImage.Width = 128;
            FlickrImage.Height = 128;

But after this, I want to set it back to Auto. Can anyone please give me a hand?


Check out this earlier SO question

How to say XAML <Button Height="Auto"/> in code behind?

You set it to double.NAN

0

精彩评论

暂无评论...
验证码 换一张
取 消