开发者

Define global textbox (or other control) width in WPF

I'd like to be able to maintain the width of controls globally throughout my WPF application.

Previously in winforms world I'd override onload in a base form and iterate through all controls and containers and determine the type of controls and set开发者_开发问答 the dimensions accordingly.

I guess I could do the same in WPF but is there any better way to do this?


Set a Style for TextBox at the highest level in your Visual Hierarchy.


Define TextBox style in the resource dictionary and put a setter to set the desired width

<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
    <Setter Property="Width" Value="200" />
      ..........
</Style>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜