[英]Programmatically get properties of UserControl.Grid?
我创建了一个简单的WPF测试程序,该程序基于Visual Studio在向用户项目添加UserControl1.xaml时提供的功能。 在XAML中,似乎空白的“背景画布”的类型为Grid。
创建UserControl1的实例时,是否可以通过编程方式访问基础的Grid实例(因此我可以更改背景颜色)?
为网格命名:
<UserControl>
<Grid x:Name="YourFancyGrid">
<!-- Grid stuff -->
</Grid>
</UserControl>
然后,您可以从C#端访问它:
YourFancyGrid.Background = new SolidColorBrush(Colors.Red);
由于UserControl是ContentControl,因此网格位于Content属性中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.