Advertise with us

How to Target all Textbox's within a Groupbox on a Window – WPF

I am trying to setup a windows.resoruces style that targets all textbox's within all groupbox's (so it would not target textbox's that are not found within a groupbox)

I know I could use the x:key field, but was wondering if there was a way to target certain controls within controls for an entire window or application?

Last updated:2/4/2014 6:02:02 AM

1 Answers

Pravesh Singh
Pravesh Singh

Hi Ankita,


You could try a nested style for your TextBoxes in Style.Resources of GroupBox with Style.TargetType but without x:key.

<Style TargetType="GroupBox">

    <Style.Resources>

        <Style TargetType="TextBox">

            ...

        </Style>

    </Style.Resources>

</Style>

Answer