当前位置: 首页>>代码示例>>C#>>正文


C# VisualBrush.AutoLayoutContent属性代码示例

本文整理汇总了C#中System.Windows.Media.VisualBrush.AutoLayoutContent属性的典型用法代码示例。如果您正苦于以下问题:C# VisualBrush.AutoLayoutContent属性的具体用法?C# VisualBrush.AutoLayoutContent怎么用?C# VisualBrush.AutoLayoutContent使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。


在下文中一共展示了VisualBrush.AutoLayoutContent属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StackPanel

StackPanel myStackPanel = new StackPanel();
myStackPanel.Margin = new Thickness(20, 0, 0, 0);
TextBlock myTextBlock = new TextBlock();
myTextBlock.Margin = new Thickness(0, 10, 0, 0);
myTextBlock.Text = "AutoLayoutContent: True";
myStackPanel.Children.Add(myTextBlock);

Rectangle myRectangle = new Rectangle();
myRectangle.Width = 100;
myRectangle.Height = 100;
myRectangle.Stroke = Brushes.Black;
myRectangle.StrokeThickness = 1;

// Create the Fill for the rectangle using a VisualBrush.
VisualBrush myVisualBrush = new VisualBrush();
myVisualBrush.AutoLayoutContent = true;

// This button is used as the visual for the VisualBrush.
Button myButton = new Button();
myButton.Content = "Hello, World";

myVisualBrush.Visual = myButton;

// Set the fill of the Rectangle to the Visual Brush.
myRectangle.Fill = myVisualBrush;

myStackPanel.Children.Add(myRectangle);

TextBlock myTextBlock2 = new TextBlock();
myTextBlock2.Margin = new Thickness(0, 10, 0, 0);
myTextBlock2.Text = "AutoLayoutContent: False";
myStackPanel.Children.Add(myTextBlock2);

Rectangle myRectangle2 = new Rectangle();
myRectangle2.Width = 100;
myRectangle2.Height = 100;
myRectangle2.Stroke = Brushes.Black;
myRectangle2.StrokeThickness = 1;

// Create the Fill for the rectangle using a VisualBrush.
VisualBrush myVisualBrush2 = new VisualBrush();
myVisualBrush2.AutoLayoutContent = false;

// This button is used as the visual for the VisualBrush.
Button myButton2 = new Button();
myButton2.Content = "Hello, World";
myButton2.Width = 100;
myButton2.Height = 100;

myVisualBrush2.Visual = myButton2;

// Set the fill of the Rectangle to the Visual Brush.
myRectangle2.Fill = myVisualBrush2;

myStackPanel.Children.Add(myRectangle2);
开发者ID:.NET开发者,项目名称:System.Windows.Media,代码行数:55,代码来源:VisualBrush.AutoLayoutContent

示例2: NameScope

// Create a name scope for the page.
NameScope.SetNameScope(this, new NameScope());

StackPanel myStackPanel = new StackPanel();
myStackPanel.Margin = new Thickness(20, 0, 0, 0);
TextBlock myTextBlock = new TextBlock();
myTextBlock.Margin = new Thickness(0, 10, 0, 0);
myTextBlock.Text = "The UIElement";
myStackPanel.Children.Add(myTextBlock);

Button myButton = new Button();
myButton.Content = "Hello, World";
myButton.Width = 70;
this.RegisterName("MyButton", myButton);
myStackPanel.Children.Add(myButton);

TextBlock myTextBlock2 = new TextBlock();
myTextBlock2.Margin = new Thickness(0, 10, 0, 0);
myTextBlock2.Text = "AutoLayoutContent: True";
myStackPanel.Children.Add(myTextBlock2);

Rectangle myRectangle = new Rectangle();
myRectangle.Width = 100;
myRectangle.Height = 100;
myRectangle.Stroke = Brushes.Black;
myRectangle.StrokeThickness = 1;

// Create the Fill for the rectangle using a VisualBrush.
VisualBrush myVisualBrush = new VisualBrush();
myVisualBrush.AutoLayoutContent = true;
Binding buttonBinding = new Binding();
buttonBinding.ElementName = "MyButton";
BindingOperations.SetBinding(myVisualBrush, VisualBrush.VisualProperty, buttonBinding);

// Set the fill of the Rectangle to the Visual Brush.
myRectangle.Fill = myVisualBrush;

// Add the first rectangle.
myStackPanel.Children.Add(myRectangle);

TextBlock myTextBlock3 = new TextBlock();
myTextBlock3.Margin = new Thickness(0, 10, 0, 0);
myTextBlock3.Text = "AutoLayoutContent: False";
myStackPanel.Children.Add(myTextBlock3);

Rectangle myRectangle2 = new Rectangle();
myRectangle2.Width = 100;
myRectangle2.Height = 100;
myRectangle2.Stroke = Brushes.Black;
myRectangle2.StrokeThickness = 1;

// Create the Fill for the rectangle using a VisualBrush.
VisualBrush myVisualBrush2 = new VisualBrush();
myVisualBrush2.AutoLayoutContent = false;
Binding buttonBinding2 = new Binding();
buttonBinding2.ElementName = "MyButton";
BindingOperations.SetBinding(myVisualBrush2, VisualBrush.VisualProperty, buttonBinding2);

// Set the fill of the Rectangle to the Visual Brush.
myRectangle2.Fill = myVisualBrush2;

myStackPanel.Children.Add(myRectangle2);
开发者ID:.NET开发者,项目名称:System.Windows.Media,代码行数:62,代码来源:VisualBrush.AutoLayoutContent


注:本文中的System.Windows.Media.VisualBrush.AutoLayoutContent属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。