Hi,
I'm doing a generic controller, right now is one Radbutton with two different datatemplates. Each dataTemplate has an specific key and in code-behind i will 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: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>
this.ContentTemplate = this.Resources["Standard"] as DataTemplate;
My button class will inherit from the RadButton, and every property is defined there (like ImageSource or DefaultOkText of the image binding in the Xaml i post).
But when i use this controller, 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 change 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