WPF,C#. Xaml转换c#后台代码

2025-03-21 05:46:19
推荐回答(1个)
回答1:

So Easy!

ContentControl cc = new ContentControl ();
cc.Style = Resources["DesignerItemStyle"] as Style ;
cc.Name = "cc";
cc.Width = 186;
cc.Height = 170;
cc.Visibility = Visibility.Visible;
cc.Focusable = false;

Selector.SetIsSelected(cc,true);
Canvas.SetTop(cc,211);
Canvas.SetLeft(cc,47);

Image img = new Image();
Uri uri= new Uri("1.jpg");
img.Source = new BitmapImage(uri);
img.Width = ...
...

cc.Content = img;