Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私のプロジェクトには、テキスト ボックスのカスタム スタイルがあります。次のように定義されています。
<Style TargetType="TextBox"/>
そのため、デフォルトですべてのテキスト ボックスの子コントロールに適用されます。
デフォルトのスタイルに基づいた別のスタイルを作成する必要があります。しかし、BasedOn 属性で、新しいスタイルが既定のスタイルを使用するように指定するにはどうすればよいでしょうか?
拡張したいコントロールのタイプを使用します
BasedOn="{StaticResource {x:Type TextBox}}"
完全な例:
<Style x:Key="NamedStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}"> <Setter property="Opacity" value="0.5" /> </Style>