Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 与WPF画布中的BackgroundImageLayout等效?_C#_Wpf_Canvas - Fatal编程技术网

C# 与WPF画布中的BackgroundImageLayout等效?

C# 与WPF画布中的BackgroundImageLayout等效?,c#,wpf,canvas,C#,Wpf,Canvas,Windows窗体使我们能够如下设置背景图像的图像布局: (GetDesignSurface(tabControl1.SelectedTab) as System.Windows.Forms.UserControl).BackgroundImageLayout = ImageLayout.Center; 现在,我如何在WPF(System.Windows.window)中为画布实现同样的功能 假设ib是一个ImageBrush它提供了两个属性,那么显然没有任何属性允许我实现这一点 获取或设置

Windows窗体使我们能够如下设置背景图像的图像布局:

(GetDesignSurface(tabControl1.SelectedTab) as System.Windows.Forms.UserControl).BackgroundImageLayout = ImageLayout.Center;
现在,我如何在WPF(System.Windows.window)中为画布实现同样的功能


假设
ib
是一个
ImageBrush
它提供了两个属性,那么显然没有任何属性允许我实现这一点

获取或设置TileBrush基本平铺中内容的水平对齐方式

获取或设置TileBrush基本平铺中内容的垂直对齐方式

因此,在您的代码中,您应该能够

ib.AlignmentX = AlignmentX.Center;
ib.AlignmentY = AlignmentY.Center;
您可能还需要将
拉伸
,从默认的
填充
值设置为

ib.Stretch = Stretch.None;
ib.Stretch = Stretch.None;