繁体   English   中英

WPF-以编程方式设置TextBox的样式

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM