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:
Code-behind:
XAML:
<
UserControl
x:Class
=
"SilverlightApplication1.MainPage03"
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));
}
}
}
}