[英]WPF - Set Style of TextBox programatically
On my XAML
i have defined a special style. 在我的
XAML
我定义了一种特殊的样式。 Here i can access these with my defined resource like: 在这里,我可以使用定义的资源访问这些资源,例如:
<TextBox Style="{StaticResource TransparentInput}" Text="Hello World!" [...] />
But how i can set the Style
of an component programatically ? 但是,如何通过编程设置组件的
Style
?
I wan't to add components programatically like 我不会像这样以编程方式添加组件
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.