This is a migrated thread and some comments may be shown as answers.

Problem with theme on RadRadioButton with custom content

1 Answer 131 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Jenny
Top achievements
Rank 1
Jenny asked on 12 Dec 2016, 08:50 PM

We are using Telerik UI for WPF and are having some problems with the RadRadioButton when applying themes. The problem is that the style of the theme is not fully applied to the control if the content is custom, and in this case it has a stackpanel with an image and a textblock. Then the textblock won´t get the correct foreground color when selected:

       <telerik:RadRadioButton x:Name="MyRadioButton">
            <StackPanel Orientation="Horizontal">
                <Image Width="16" Height="16" Source="../Images/icon_16x16.png"/>
                <TextBlock>My radiobutton</TextBlock>
            </StackPanel>
        </telerik:RadRadioButton>
        

 

When the RadRadioButton only has a text as content the styling is correct:

 

<telerik:RadRadioButton x:Name="MyRadioButton" Conent="My radiobutton">
</telerik:RadRadioButton>

 

I have tried to use RelativeSource and AncestorType in the binding but it doesn´t seem to work:

ForeGround={Binding RelativeSource={RelativeSource AncestorType=TextBox}, Path=Tag}

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 15 Dec 2016, 02:46 PM
Hi Jenny,

What you described as result by comparing adding direct content to the RadRadioButton and the other one with the StackPanel is expected and I'll describe why below.
Since we don't support theming for MS TextBlock control it uses the dependency property inheritance and inherit its Foreground property from its parent in the element tree. There's very good article online that explains the property inheritance in WPF and I really recommend that you review it. So in your case the TextBlock simply inherits the Foreground property from the RadRadioButton (its logical parent).
On the other side when you directly provide Content to the Button by using the Content property our predefined theming kicks in and since we change the ContentPresenter's  Foreground in different visual states in the RadRadioButtonStyle -- this is what you'll see as result.
I don't really understand why are you trying to Bind to a Tag property of a TextBox element. Instead you can bind to the Foreground property of the ContentPresenter of the Button like this:

Foreground="{Binding RelativeSource={RelativeSource AncestorType=ContentPresenter},
               Path=(TextElement.Foreground)}" />

I hope this information helps.

Regards,
Evgenia
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Buttons
Asked by
Jenny
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or