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

Bug: Can't set complex content of RadButton with a style

2 Answers 98 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Patrick asked on 05 Jul 2012, 06:35 AM
Hello,
here is a sample Silverlight page that shows the problem.
To use it, just create a new Silverlight application and replace Page.xaml with the following code:
<?xml version='1.0' encoding='utf-8' ?>
<UserControl
  x:Class="SilverlightApplication1.MainPage"
  mc:Ignorable="d"
  d:DesignHeight="300" d:DesignWidth="400">
 
  <StackPanel>
    <StackPanel.Resources>
 
      <Style x:Key="Button3" TargetType="tk:RadButton">
        <Setter Property="Content" Value="Button 3" />
      </Style>
 
      <Style x:Key="Button4" TargetType="tk:RadButton">
        <Setter Property="Content">
          <Setter.Value>
            <TextBlock Text="Button 4" />
          </Setter.Value>
        </Setter>
      </Style>
 
    </StackPanel.Resources>
     
    <tk:RadButton Content="Button 1" />
 
    <tk:RadButton>
      <tk:RadButton.Content>
        <TextBlock Text="Button 2" />
      </tk:RadButton.Content>
    </tk:RadButton>
 
    <tk:RadButton Style="{StaticResource Button3}" />
 
    <tk:RadButton Style="{StaticResource Button4}" />
 
  </StackPanel>
</UserControl>

As you can see in the designer, and running the application, the fourth button has no content!
Normally, each button should show its content, which is defined properly.
This bug is very annoying because I can't define buttons with complex content with a style.
Do you have a workaround, excepted defining each button manually?
Patrick

2 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 09 Jul 2012, 10:04 AM
Hello Patrick,

 I guess this is a Framework Limitation. You can see that the native Button has the same behavior:

<Style x:Key="Button4" TargetType="Button">
                <Setter Property="Content">
                    <Setter.Value>
                        <TextBlock Text="Button 4" />
                    </Setter.Value>
                </Setter>
            </Style>
<Button Style="{StaticResource Button4}" />
This button behaves the same way - no Textblock is shown.
For this scenario and for complex controls in the Content you can use a ContentTemplate like so:
<Style x:Key="Button4" TargetType="telerik:RadButton">
                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock Text="Button 4" />
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
<telerik:RadButton Style="{StaticResource Button4}" />

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 16 Jul 2012, 04:52 AM
Thank you Petar, it is working fine.
That's really an annoying bug in Silverlight!
Patrick
Tags
Buttons
Asked by
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Petar Mladenov
Telerik team
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or