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

Q1 2013 bug: Radbutton Content disappears when data binding the FontSize property in a Style

2 Answers 82 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
hwsoderlund
Top achievements
Rank 1
hwsoderlund asked on 21 Feb 2013, 02:27 PM
If I data bind the FontSize property in the inline markup everything works fine, but when I set the same data binding in a Style, the entire Content of the RadButton disappears. I am using the Windows8 theme. When using the default theme everything works fine. I have not tried the other themes. This was never an issue in the previous RadControls version (the one I used was RadControls_for_Silverlight_5_2012_3_1411_DEV_hotfix). To reproduce, please see the code below. I am also attaching two screen shots so you can see the actual behaviour vs the expected behaviour.

XAML:
<UserControl x:Class="SilverlightApplication1.MainPage03"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:SilverlightApplication1"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             d:DesignHeight="300"
             d:DesignWidth="400"
             mc:Ignorable="d">
 
    <UserControl.Resources>
 
        <local:DataContainer x:Key="DataContainer">
        </local:DataContainer>
 
        <Style x:Name="Style_DataBoundFontSize"
               TargetType="telerik:RadButton">
            <Setter Property="FontSize"
                    Value="{Binding TheFontSize,
                                    Source={StaticResource DataContainer}}" />
        </Style>
 
    </UserControl.Resources>
 
    <Grid x:Name="LayoutRoot"
          Background="White">
 
        <StackPanel Width="400"
                    Margin="0 50 0 0">
 
            <TextBlock Margin="5">Font size data binding inline:</TextBlock>
 
            <telerik:RadButton Height="40"
                               Margin="5 5 0 10"
                               Content="Some Button Text"
                               FontSize="{Binding TheFontSize,
                                                  Source={StaticResource DataContainer}}">
            </telerik:RadButton>
 
            <TextBlock Margin="5"
                       TextWrapping="Wrap">
                Font size data binding set on the Style (content disappears in Q1 2013 but works in previous version):
            </TextBlock>
 
            <telerik:RadButton Height="40"
                               Margin="5 5 0 10"
                               Content="Some Button Text"
                               Style="{StaticResource Style_DataBoundFontSize}">
            </telerik:RadButton>
 
 
        </StackPanel>
 
    </Grid>
</UserControl>


Code-behind:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
 
namespace SilverlightApplication1
{
    public partial class MainPage03 : UserControl
    {
        public MainPage03()
        {
            StyleManager.ApplicationTheme = new Windows8Theme();
 
            InitializeComponent();
        }
    }
 
    public class DataContainer : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
 
        private double _TheFontSize = 22.0;
 
        public double TheFontSize
        {
            get
            {
                return _TheFontSize;
            }
            set
            {
                _TheFontSize = value;
                OnPropertyChanged("TheFontSize");
            }
        }
 
        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Christian
Top achievements
Rank 2
answered on 25 Feb 2013, 01:46 PM
Same problem here! What happen on 2013 Q1. RadButton Content is empty, always. Only works with images.

Anyone from Telerik?
0
Pavel R. Pavlov
Telerik team
answered on 26 Feb 2013, 02:12 PM
Hello Christian,

Thank you for bringing this issue to our attention. In the last queue we worked on improving our Win8 and Win8Touch styles, specifically to better work with FontSizes that are changed dynamically.
Unfortunately, setting an Application theme via StyleManager breaks the binding of the Fontsize via Style. This has to do with an existing Silverlight Framework issue. We know this used to work before but our styles were not ready to work with dynamical FontSize change. We hope you will understand that this breaking change is in a right direction.

However, In order to overcome this issue you can use ImplicitStyles and NoXaml dlls. For more information you can refer to this article. Also, for your convenience I implemented the described approach in the attached solution. Please take a look at it and let me know if it works for you.

Please accept our apologies for the inconvenience caused.

All the best,
Pavel R. Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Buttons
Asked by
hwsoderlund
Top achievements
Rank 1
Answers by
Christian
Top achievements
Rank 2
Pavel R. Pavlov
Telerik team
Share this question
or