0
s.jpg가 BuildAction == Resource로 솔루션에 추가되었습니다.Silverlight : 이미지를 동적으로 그리는 방법?
XAML
<UserControl x:Class=...>
<Canvas x:Name="LayoutRoot">
</Canvas>
</UserControl>
CS
Image Model = new Image();
Model.Source = new BitmapImage(new Uri("/s.jpg", UriKind.Relative));
LayoutRoot.SetLeft(Model, Coor.X);
LayoutRoot.SetTop(Model, Coor.Y);
Model.Width = 50;
Model.Height = 30;
LayoutRoot.Children.Add(Model);
여기 내 질문이있다 : 내 이미지했다입니까? 나는 그 타원을 볼 수도 변화 CS 경우
Ellipse Model = new Ellipse();
Model.Fill = new SolidColorBrush(Colors.Gray);
Model.Stroke = new SolidColorBrush(Colors.Blue);
LayoutRoot.SetLeft(Model, Coor.X);
LayoutRoot.SetTop(Model, Coor.Y);
Model.Width = 50;
Model.Height = 30;
LayoutRoot.Children.Add(Model);
에, 당신은 그것을 볼 수
<UserControl x:Class=...>
<Canvas x:Name="LayoutRoot">
<Image Source="s.jpg"></Image>
</Canvas>
</UserControl>
에 XAML을 변경하는 경우 비록이 화면에 나타났다 has't. 무슨 문제 야?