Hi,
I'm doing a generic controller, right now is one button from telerik with two direferents datatemplates. Each dataTemplate has an specific key to id and in code-behind i change between them.
My problem is i cannot do the binding to my properties. For example:
My Xaml looks like:
<telerik:RadButton x:Class="Itim.Framework.Silverlight.UI.Controls.Button"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:Itim.Framework.Silverlight.UI.Controls"
SizeChanged="btnGeneric_SizeChanged">
<telerik:RadButton.Resources>
<!--Default dataTemplate-->
<DataTemplate x:Key="Standard">
<StackPanel DataContext="{Binding}" Orientation="Horizontal">
<Image Source="{Binding ImageSource}" Visibility="{Binding ImageVisibility}"
Stretch="Fill" VerticalAlignment="Stretch" HorizontalAlignment="Right" />
<TextBlock Text="{Binding Content, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
TextAlignment="Center" Visibility="{Binding TextVisibility,Mode=TwoWay}" Width="{Binding TextBlockWidth}" />
</StackPanel>
</DataTemplate>
<!--Ok button data template-->
<DataTemplate x:Key="Ok">
<StackPanel DataContext="{Binding}" Orientation="Horizontal" >
<Image Source="{Binding ImageOkSource}" Visibility="{Binding ImageVisibility}"
Stretch="Fill" VerticalAlignment="Stretch"/>
<TextBlock Text="{Binding DefaultOkText}" Visibility="{Binding TextVisibility,Mode=TwoWay}"
TextAlignment="Center" Width="{Binding TextBlockWidth}"/>
</StackPanel>
</DataTemplate>
</telerik:RadButton.Resources>
</telerik:RadButton>
and in c# when i wanna change the datatemplate i do something like this:
this.ContentTemplate = this.Resources["Standard"] as DataTemplate;
My button class will inherit from the teleriks RadButton, and every property is defined there (like ImageSource or DefaultOkText).
But when i use this controler with for example the Standard datatemplate the image (from ImageSource) doesn't show, but the Text from the textblock shows. the same happens when i chage for the OK datatemplate (in this case will not put anything because the binding of ImageOkSource or DefaultOkText will not do).
What can i do to get this working?
Thanks