简体   繁体   中英

WPF TextBox Property Inheritance

Why this works:

<StackPanel TextBlock.FontWeight="Bold">
    <!-- All text boxes inside have their text in bold -->
    <TextBox Width="100" Height="24" Text="AaBbCc"  />
</StackPanel>

and this does not?

<StackPanel TextBox.TextDecorations="Underline">
    <TextBox Width="100" Height="24" Text="AaBbCc"  />
</StackPanel>

error MC3015: The attached property 'TextBox.TextDecorations' is not defined on 'StackPanel' or one of its base classes.

But FontWeight property is also not defined on StackPanel ! So why they behave differently?

As it says -- TextDecorations is not AttachedProperty !

if you want to apply this to multiple, there are other ways like style setting or making it a template

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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