本文介绍了呈现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"?

推荐答案

  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的实际高度和实际宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 17:10