[英]WPF - Set Style of TextBox programatically
在我的XAML
我定义了一种特殊的样式。 在这里,我可以使用定义的资源访问这些资源,例如:
<TextBox Style="{StaticResource TransparentInput}" Text="Hello World!" [...] />
但是,如何通过编程设置组件的Style
?
我不会像这样以编程方式添加组件
TextBox test = new TextBox();
test.Text = "Hello World!";
test.Style = [???] //<--- How i set here the static resource "TransparentInput"?
尝试这个:
test.Style = TryFindResource("TransparentInput") as Style;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.