发布Silverlight 5中的模板单选按钮

发布Silverlight 5中的模板单选按钮,silverlight,xaml,silverlight-5.0,controltemplate,Silverlight,Xaml,Silverlight 5.0,Controltemplate,我尝试将一个非常简单的控件模板应用于RadioButton。但这导致了一种奇怪的行为。 只要我只是点击标签,一切正常,但当我点击按钮控件本身时,它就再也不会改变。下面是控件的完整代码: <UserControl x:Class="RadioButtonDemo.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.co

我尝试将一个非常简单的控件模板应用于RadioButton。但这导致了一种奇怪的行为。 只要我只是点击标签,一切正常,但当我点击按钮控件本身时,它就再也不会改变。下面是控件的完整代码:

    <UserControl x:Class="RadioButtonDemo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
    <ControlTemplate TargetType="RadioButton" x:Key="RadioButtonTemplate">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="2*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="{TemplateBinding Content}"/>
            <RadioButton IsChecked="{TemplateBinding IsChecked}" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center"/>
        </Grid>
    </ControlTemplate>

    <Style TargetType="RadioButton" x:Key="RadioButtonStyle">
        <Setter Property="Template" Value="{StaticResource RadioButtonTemplate}"/>
    </Style>

</UserControl.Resources>
<StackPanel>
    <RadioButton Content="Textbox diabled" GroupName="Group1" Style="{StaticResource RadioButtonStyle}"/>
    <RadioButton x:Name="EnabledButton" Content="Textbox enabled" GroupName="Group1" Style="{StaticResource RadioButtonStyle}"/>
    <TextBox IsEnabled="{Binding IsChecked, ElementName=EnabledButton}"/>
</StackPanel>


有人能帮忙吗?

请从以下链接获取默认样式


使用模板时只需交换内容和按钮(:-(代码是批量的)。

好吧,这对我来说太大了,但它起作用了。问题回答了!