내 실버 라이트 컨트롤의 눈금, 프로그래밍 방식으로 캔버스를 추가하는 중 캔버스에 이미지를로드하고 표시하는 중입니다.ActualWidth 및 ActualHeight를 강제로 업데이트하는 방법 (실버 라이트)
캔버스에 회전을 추가하고 있습니다. 문제는 기본적으로 회전의 CenterX 및 CenterY가 캔바스의 왼쪽 상단에 있다는 것입니다. 내가 원하는 것은 회전이 캔버스의 중심 주위에서 일어나는 것입니다.
이 작업을 수행하려면, 그러나 나는 내가 ActualWidth
및 ActualHeight
항상 적어도 지금 당장, 채워지지 않습니다 것을 발견했습니다의 이미지 ActualWidth
/2 및 ActualHeight
/2 회전의 CenterX 및 CenterY을 설정하려고했습니다 . 어떻게 강제 업데이트 할 수 있습니까?
심지어
Image imgTest = new Image();
Canvas cnvTest = new Canvas();
Uri uriImage = new Uri("myurl", UriKind.RelativeOrAbsolute);
System.Windows.Media.Imaging.BitmapImage bmpDisplay = new System.Windows.Media.Imaging.BitmapImage(uriImage);
bmpDisplay.DownloadProgress += new EventHandler<System.Windows.Media.Imaging.DownloadProgressEventArgs>(this.GetActualDimensionsAfterDownload);
imgTest.Source = bmpDisplay;
imgTest.Stretch = Stretch.Uniform;
imgTest.HorizontalAlignment = HorizontalAlignment.Center;
imgTest.VerticalAlignment = VerticalAlignment.Center;
cnvTest.Children.Add(imgTest);
this.grdLayout.Children.Add(imgTest);
this.Dispatcher.BeginInvoke(new Action(GetActualDimensions));
그게 내게 고마워, 고마워! –
나를 위해 일했습니다. 감사. – Jordan