简体   繁体   中英

Controlling style of children controls

I need to create a transparent button with image and text. I have a DockPanel inside a button, with Image and TextBlock controls. When mouse is over it, it should create some zoom on the image, and also make some effect (ex glow) on TextBlock text.

Is there a way I can have one style only, for button, in which I can also specify style for image and TextBlock?

Yes, you can nest styles, eg

<Style TargetType="{x:Type Button}">
    <Style.Resources>
        <Style TargetType="{x:Type Image}">
            <!-- ... -->
        </Style>
    </Style.Resources>
    <!-- ... -->
</Style>

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