如何在代码后面的列表框项目中显示按钮和按钮名称?

时间:2010-04-12 07:44:34

标签: c# silverlight silverlight-3.0 listbox

您好我有以下代码,它将自定义单选按钮列表分配给我的列表框。

List<RadioButton> listUserControlBtns = new List<RadioButton>();

CustomLocalFolderButton btnLocalFolder = new CustomLocalFolderButton ();
CustomLocalFolderButton btnPlayListFolder = new CustomLocalFolderButton ();
CustomVideoButton btnVideoFolder = new CustomVideoButton ();
CutsomAudioButton btnMusicFolder = new CutsomAudioButton ();
CustomImageButton btnImageFolder = new CustomImageButton ();
ListUserControlBtns.Add(btnLocalFolder);

ListUserControlBtns.Add(btnPlayListFolder);
ListUserControlBtns.Add(btnVideoFolder);
ListUserControlBtns.Add(btnMusicFolder);
ListUserControlBtns.Add(btnImageFolder);

listMainFolder.ItemsSource = listUserControlBtns;

现在。我能够在列表框中显示单选按钮,但我还想在单选按钮下方显示单选按钮的名称。这应该发生在列表框内的所有单选按钮上。

我不想在XAML中使用绑定。您的建议和解决方案将以一种很好的方式帮助我。

自定义Radiobutoons类如下所示:

namespace customAudioButton
{
    public class CutsomAudioButton:RadioButton
    {
        public CutsomAudioButton()
        {
            this.DefaultStyleKey = typeof(CutsomAudioButton);
        }
    }

}

此外,我的通用XAML如下所示:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:customImageButton">


    <Style TargetType="local:CutsomAudioButton">
        <Setter Property="Background" Value="#FF448DCA"/>
        <Setter Property="Foreground" Value="#FF000000"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Top"/>
        <Setter Property="Padding" Value="4,1,0,0"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="BorderBrush">
            <Setter.Value>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFA3AEB9" Offset="0"/>
                    <GradientStop Color="#FF8399A9" Offset="0.375"/>
                    <GradientStop Color="#FF718597" Offset="0.375"/>
                    <GradientStop Color="#FF617584" Offset="1"/>
                </LinearGradientBrush>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:CutsomAudioButton">
                    <Grid Width="200" Margin="0,0,0,19">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="canvas_Copy2" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path3" Storyboard.TargetProperty="(UIElement.Opacity)">

                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Pressed">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="canvas_Copy2" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                             <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="CheckStates">
                                <VisualState x:Name="Checked">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="path3_Copy" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>


                                            <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unchecked"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Focused"/>
                                <VisualState x:Name="Unfocused"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="ValidationStates">
                                <VisualState x:Name="Valid"/>
                                <VisualState x:Name="InvalidUnfocused"/>
                                <VisualState x:Name="InvalidFocused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="125"/>
                        </Grid.ColumnDefinitions>
                        <Path x:Name="path1" Stroke="#FF844B08" Width="Auto" Data="F1M12,1.087C12,1.087 28.814,1.087 49.294,1.087 53.671,1.087 58.215,13 62.799,13 91.625,13 122,13 122,13 127.523,13 132,17.477 132,23 132,23 132,98 132,98 132,103.523 127.523,108 122,108 122,108 12,108 12,108 6.477,108 2,103.523 2,98 2,98 2,12.337 2,12.337 2,6.815 6.477,1.087 12,1.087z" HorizontalAlignment="Stretch" Margin="10,1.765,-17.564,0" VerticalAlignment="Top" Height="108.5" UseLayoutRounding="False">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFE5B802" Offset="0.996"/>
                                    <GradientStop Color="#FFF3EFDE"/>
                                    <GradientStop Color="#FFBF9A05" Offset="0.065"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        <Path x:Name="path1_Copy" Stroke="#FF844B08" Width="Auto" Data="F1 M120.50496,0.50000012 C126.02796,0.50000012 130.50496,4.9769998 130.50496,10.5 C130.50496,10.5 130.50496,85.355896 130.50496,85.355896 C130.50496,90.878891 126.02796,95.355896 120.50496,95.355896 C120.50496,95.355896 10.504963,95.355896 10.504963,95.355896 C4.9819636,95.355896 0.5049634,90.878891 0.5049634,85.355896 C0.5049634,85.355896 0.5049634,12.040168 0.5049634,12.040168 C0.33018857,5.8202529 4.7881746,0.99969035 11.184806,0.94185221 C39.903023,0.68218291 120.50496,0.50000012 120.50496,0.50000012 z" HorizontalAlignment="Stretch" Margin="11.497,14.41,-17.502,0" VerticalAlignment="Top" Height="95.856" UseLayoutRounding="False">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFE5B802" Offset="0.996"/>
                                    <GradientStop Color="#FFFADC5E" Offset="0.007"/>
                                    <GradientStop Color="#FFE2BC22" Offset="0.166"/>
                                    <GradientStop Color="#FFA16908" Offset="0.948"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                       <Canvas x:Name="canvas_Copy2" Margin="57.333,46.833,14.667,14.167" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" >
                            <Canvas.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform Angle="34.232"/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Canvas.RenderTransform>
                            <Path x:Name="Shape_7" Width="53" Height="49" Data="F1M4.253,1.753C4.253,1.753 48.829,1.753 48.829,1.753 50.486,1.753 51.829,3.096 51.829,4.753 51.829,4.753 51.829,44.314 51.829,44.314 51.829,45.971 50.486,47.314 48.829,47.314 48.829,47.314 4.253,47.314 4.253,47.314 2.597,47.314 1.253,45.971 1.253,44.314 1.253,44.314 1.253,4.753 1.253,4.753 1.253,3.096 2.597,1.753 4.253,1.753z" Fill="White" UseLayoutRounding="False"/>
                            <Path x:Name="Shape_8_copy3" Width="49" Height="40" Data="F1M4.252,1.795C4.252,1.795 44.832,1.795 44.832,1.795 46.34,1.795 47.563,3.017 47.563,4.526 47.563,4.526 47.432,38.028 47.432,38.028 47.432,38.028 1.452,38.028 1.452,38.028 1.452,38.028 1.521,4.526 1.521,4.526 1.521,3.017 2.743,1.795 4.252,1.795z" Fill="#FFDC0C6F" UseLayoutRounding="False" Canvas.Left="2" Canvas.Top="2"/>
                            <Path x:Name="Shape_8" Width="27" Height="20" Data="F1M4.2,17.8C4.2,17.8 1.2,5.6 6.8,6 6.8,6 10,6.6 10,6.6 10,6.6 9.2,5 11.8,4 11.8,4 16.2,1.6 17.4,5.4 17.4,5.4 19.4,5.8 19.4,5.8 19.4,5.8 20.8,1.6 23.8,4.6 23.8,4.6 25.6,5.8 25.6,5.8 25.6,5.8 26,18.4 26,18.4 26,18.4 4.2,17.8 4.2,17.8z" Opacity="0.895" UseLayoutRounding="False" Canvas.Left="24" Canvas.Top="12">
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="White" Offset="0"/>
                                        <GradientStop Color="White" Offset="1"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                           <Path x:Name="Shape_9" Width="49" Height="22" Data="F1M1.8,20.8C1.8,20.8 47.8,20.6 47.8,20.6 47.8,20.6 47.8,7.4 47.8,7.4 47.8,7.4 26.8,2 1.2,14.2 1.2,14.2 1.2,20.8 1.2,20.8 1.2,20.8 1.8,20.8 1.8,20.8z" UseLayoutRounding="False" Canvas.Left="2" Canvas.Top="20">
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF1BD3D8" Offset="0"/>
                                        <GradientStop Color="#FF0E5759" Offset="0.996"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                        </Canvas>
                        <Path x:Name="path3" Stroke="#FF844B08" Width="133" Data="F1M12,1.087C12,1.087 28.814,1.087 49.294,1.087 53.671,1.087 58.215,13 62.799,13 91.625,13 122,13 122,13 127.523,13 132,17.477 132,23 132,23 132,98 132,98 132,103.523 127.523,108 122,108 122,108 12,108 12,108 6.477,108 2,103.523 2,98 2,98 2,12.337 2,12.337 2,6.815 6.477,1.087 12,1.087z" HorizontalAlignment="Right" Margin="0,1.719,-18,0" VerticalAlignment="Top" Height="108.5" UseLayoutRounding="False" Opacity="0">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF6A5603" Offset="1"/>
                                    <GradientStop Color="#FFF3EFDE"/>
                                    <GradientStop Color="#FFDAB20D" Offset="0.349"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        <Canvas x:Name="canvas_Copy" Margin="0,8.333,7.667,52.667" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" Opacity="0" HorizontalAlignment="Right" Width="53">
                            <Canvas.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform Angle="34.232"/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Canvas.RenderTransform>
                            <Path x:Name="Shape_4" Width="53" Height="49" Data="F1M4.253,1.753C4.253,1.753 48.829,1.753 48.829,1.753 50.486,1.753 51.829,3.096 51.829,4.753 51.829,4.753 51.829,44.314 51.829,44.314 51.829,45.971 50.486,47.314 48.829,47.314 48.829,47.314 4.253,47.314 4.253,47.314 2.597,47.314 1.253,45.971 1.253,44.314 1.253,44.314 1.253,4.753 1.253,4.753 1.253,3.096 2.597,1.753 4.253,1.753z" Fill="White" UseLayoutRounding="False"/>
                            <Path x:Name="Shape_8_copy2" Width="49" Height="40" Data="F1M4.252,1.795C4.252,1.795 44.832,1.795 44.832,1.795 46.34,1.795 47.563,3.017 47.563,4.526 47.563,4.526 47.432,38.028 47.432,38.028 47.432,38.028 1.452,38.028 1.452,38.028 1.452,38.028 1.521,4.526 1.521,4.526 1.521,3.017 2.743,1.795 4.252,1.795z" Fill="#FFDC0C6F" UseLayoutRounding="False" Canvas.Left="2" Canvas.Top="2"/>
                           <Path x:Name="Shape_6" Width="49" Height="22" Data="F1M1.8,20.8C1.8,20.8 47.8,20.6 47.8,20.6 47.8,20.6 47.8,7.4 47.8,7.4 47.8,7.4 26.8,2 1.2,14.2 1.2,14.2 1.2,20.8 1.2,20.8 1.2,20.8 1.8,20.8 1.8,20.8z" UseLayoutRounding="False" Canvas.Left="2" Canvas.Top="20">
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF1BD3D8" Offset="0"/>
                                        <GradientStop Color="#FF0E5759" Offset="0.996"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                        </Canvas>
                        <Path x:Name="path4" Width="154.261" Data="F1 M37.066082,0.5 C37.066082,0.5 143.61697,0.5 143.61697,0.5 C149.13997,0.5 154.73392,5.6793203 153.61697,10.5 C153.61697,10.5 133.61697,55.5 133.61697,55.5 C133.61697,55.5 128.07298,67.252579 127.88042,66.737434 C127.88042,66.737434 13.617228,66.737434 13.617228,66.737434 C9.6519403,66.778893 3.0821178,65.676422 0.5,58.919891 C0.5,58.919891 23.617235,10.5 23.617235,10.5 C26.732969,3.0064244 31.543129,0.5 37.066082,0.5 z" HorizontalAlignment="Right" Margin="0,43.59,-41.214,0" VerticalAlignment="Top" Height="67.254" UseLayoutRounding="False" Stroke="#FF844B08" Opacity="0">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFE5B802" Offset="0.684"/>
                                    <GradientStop Color="White"/>
                                    <GradientStop Color="#FFFAD336" Offset="0.378"/>
                                    <GradientStop Color="#FFA16908" Offset="1"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                       <Canvas x:Name="canvas_Copy1" Margin="0,8.333,7.667,52.667" RenderTransformOrigin="0.5,0.5" UseLayoutRounding="False" Opacity="0" HorizontalAlignment="Right" Width="53">
                            <Canvas.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform/>
                                    <SkewTransform/>
                                    <RotateTransform Angle="34.232"/>
                                    <TranslateTransform/>
                                </TransformGroup>
                            </Canvas.RenderTransform>
                            <Path x:Name="Shape_1" Width="53" Height="49" Data="F1M4.253,1.753C4.253,1.753 48.829,1.753 48.829,1.753 50.486,1.753 51.829,3.096 51.829,4.753 51.829,4.753 51.829,44.314 51.829,44.314 51.829,45.971 50.486,47.314 48.829,47.314 48.829,47.314 4.253,47.314 4.253,47.314 2.597,47.314 1.253,45.971 1.253,44.314 1.253,44.314 1.253,4.753 1.253,4.753 1.253,3.096 2.597,1.753 4.253,1.753z" Fill="White" UseLayoutRounding="False"/>
                            <Path x:Name="Shape_8_copy1" Width="49" Height="40" Data="F1M4.252,1.795C4.252,1.795 44.832,1.795 44.832,1.795 46.34,1.795 47.563,3.017 47.563,4.526 47.563,4.526 47.432,38.028 47.432,38.028 47.432,38.028 1.452,38.028 1.452,38.028 1.452,38.028 1.521,4.526 1.521,4.526 1.521,3.017 2.743,1.795 4.252,1.795z" Fill="#FFDC0C6F" UseLayoutRounding="False" Canvas.Left="2" Canvas.Top="2"/>
                            <Path x:Name="Shape_2" Width="27" Height="20" Data="F1M4.2,17.8C4.2,17.8 1.2,5.6 6.8,6 6.8,6 10,6.6 10,6.6 10,6.6 9.2,5 11.8,4 11.8,4 16.2,1.6 17.4,5.4 17.4,5.4 19.4,5.8 19.4,5.8 19.4,5.8 20.8,1.6 23.8,4.6 23.8,4.6 25.6,5.8 25.6,5.8 25.6,5.8 26,18.4 26,18.4 26,18.4 4.2,17.8 4.2,17.8z" Opacity="0.895" UseLayoutRounding="False" Canvas.Left="24" Canvas.Top="12">
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="White" Offset="0"/>
                                        <GradientStop Color="White" Offset="1"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                            <Path x:Name="Shape_10_copy1" Width="20" Height="14" Data="F1M3.925,11.948C3.925,11.948 1.925,3.816 5.658,4.083 5.658,4.083 7.791,4.483 7.791,4.483 7.791,4.483 7.258,3.416 8.991,2.75 8.991,2.75 11.923,1.15 12.723,3.683 12.723,3.683 14.056,3.95 14.056,3.95 14.056,3.95 14.989,1.15 16.989,3.15 16.989,3.15 18.189,3.95 18.189,3.95 18.189,3.95 18.455,12.348 18.455,12.348 18.455,12.348 3.925,11.948 3.925,11.948z" Opacity="0.815" UseLayoutRounding="False" Canvas.Top="22">
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="White" Offset="0"/>
                                        <GradientStop Color="White" Offset="1"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                            <Path x:Name="Shape_3" Width="49" Height="22" Data="F1M1.8,20.8C1.8,20.8 47.8,20.6 47.8,20.6 47.8,20.6 47.8,7.4 47.8,7.4 47.8,7.4 26.8,2 1.2,14.2 1.2,14.2 1.2,20.8 1.2,20.8 1.2,20.8 1.8,20.8 1.8,20.8z" UseLayoutRounding="False" Canvas.Left="2" Canvas.Top="20">
                                <Path.Fill>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FF1BD3D8" Offset="0"/>
                                        <GradientStop Color="#FF0E5759" Offset="0.996"/>
                                    </LinearGradientBrush>
                                </Path.Fill>
                            </Path>
                        </Canvas>
                        <Path x:Name="path4_Copy" Width="154.261" Data="F1 M37.066082,0.5 C37.066082,0.5 143.61697,0.5 143.61697,0.5 C149.13997,0.5 154.73392,5.6793203 153.61697,10.5 C153.61697,10.5 133.61697,55.5 133.61697,55.5 C133.61697,55.5 128.07298,67.252579 127.88042,66.737434 C127.88042,66.737434 13.617228,66.737434 13.617228,66.737434 C9.6519403,66.778893 3.0821178,65.676422 0.5,58.919891 C0.5,58.919891 23.617235,10.5 23.617235,10.5 C26.732969,3.0064244 31.543129,0.5 37.066082,0.5 z" HorizontalAlignment="Right" Margin="0,43.59,-41.214,0" VerticalAlignment="Top" Height="67.254" UseLayoutRounding="False" Stroke="#FF844B08" Opacity="0">
                            <Path.Fill>
                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FFE5B802" Offset="0.684"/>
                                    <GradientStop Color="White"/>
                                    <GradientStop Color="#FFFAD336" Offset="0.378"/>
                                    <GradientStop Color="#FFA16908" Offset="1"/>
                                </LinearGradientBrush>
                            </Path.Fill>
                        </Path>
                        <Border x:Name="border" Margin="-8,-14,-61,-15" Opacity="0" BorderBrush="#FFC20050" BorderThickness="5,5,6,5" CornerRadius="5"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

谢谢, Subhen

2 个答案:

答案 0 :(得分:2)

假设您的自定义RadioButtons未替换DefaultStyleKey,或者您的新模板仍然包含ContentPresenter,其Content属性绑定了“{TemplateBinding Content }”。则: -

List<RadioButton> listUserControlBtns = new List<RadioButton>(); 

var btnLocalFolder = new CustomLocalFolderButton() {Content = "Label 1"}; 
var btnPlayListFolder = new CustomLocalFolderButton() {Content = "Label 2"};  
var btnVideoFolder = new CustomVideoButton() {Content = "Label 3"}; 
var btnMusicFolder = new CutsomAudioButton() {Content = "Label 4"}; 
var btnImageFolder = new CustomImageButton()  {Content = "Label 5"}; 

listUserControlBtns.Add(btnLocalFolder);  
listUserControlBtns.Add(btnPlayListFolder); 
listUserControlBtns.Add(btnVideoFolder); 
listUserControlBtns.Add(btnMusicFolder); 
listUserControlBtns.Add(btnImageFolder); 

listMainFolder.ItemsSource = listUserControlBtns; 

修改

概述您需要做什么将内容呈现器还原到自定义控件的模板: -

<ControlTemplate TargetType="local:CustomLocalFolderButton">
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto"/>  <!-- May need a specific size -->
      <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <vsm:VisualStateManager.VisualStateGroups>
      <!-- Your existing set of visual state groups here -->
    </vsm:VisualStateManager.VisualStateGroups>
    <!-- Your existing UI for this control -->
    <ContentPresenter
      Grid.Column="1"
      x:Name="contentPresenter"
      Content="{TemplateBinding Content}"
      ContentTemplate="{TemplateBinding ContentTemplate}"
      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
      Margin="{TemplateBinding Padding}" />
</ControlTemplate>

答案 1 :(得分:0)

您可以使用按钮的content属性来显示与它们相邻的一些文本。