呈现imagecontrol的实际高度和实际宽度? [英] Rendered actualheight and actualwidth of the imagecontrol?

查看:103
本文介绍了呈现imagecontrol的实际高度和实际宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果image.source是height ="1024"的writeablebitmap,如何获得图像控件的渲染的ActualHeight和ActualWidth.和width ="768"?

How to get the rendered ActualHeight and ActualWidth of the image control if the image.source is writeablebitmap whose height="1024" and width="768"?

推荐答案

我认为您需要等到实际的位图在屏幕上呈现后, 像这样:

I think you need to wait until the actual bitmap is rendered on the screen,  like this:

  protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            var wbmp = new WriteableBitmap(1024, 768);
            var info =
                Application.GetResourceStream(new Uri(@"/DataBoundApp1;component/screenshot1.png", UriKind.Relative));
            wbmp.LoadJpeg(info.Stream);
            image.Source = wbmp;
            Console.Write(image.ActualHeight); // Returns 0.0
            base.OnNavigatedTo(e);
        }

        private void Image_OnTap(object sender, GestureEventArgs e)
        {
            Console.Write(image.ActualHeight); // For my example image, returns 480.0
        }


这篇关于呈现imagecontrol的实际高度和实际宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆