当前位置: 代码迷 >> Windows Mobile >> 最近学到了标签样式,但是出有关问题,请高手帮帮忙看下,在此谢过了,详细请看代码
  详细解决方案

最近学到了标签样式,但是出有关问题,请高手帮帮忙看下,在此谢过了,详细请看代码

热度:115   发布时间:2016-04-25 07:13:22.0
最近学到了标签样式,但是出问题,请高手帮帮忙看下,在此谢过了,详细请看代码
 此处是mainpage.xaml:

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <StackPanel >
                <Button x:Name="custombutton" Content="custom styled button"
                        Margin="10" Width="350" Height="350" BorderBrush="White" 
                        BorderThickness="5" 
                        Style="{StaticResource custombuttonstyle}"/>
                <Button x:Name="standardbutton"
                        Content="standard button" Margin="10"/>
            </StackPanel >
        </Grid>
    </Grid>


此处是app.xaml:

    <Application.Resources>
        <Style x:Key="custombuttonstyle" TargetType="Button" >
            <Setter Property="Template" >
                <Setter.Value >
                    <ControlTemplate>
                        <Border Width="{TemplateBinding width}"
                                Height="{TemplateBinding height}" BorderBrush="{TemplateBinding borderbrush}"
                                BorderThickness ="{TemplateBinding borderthickness}">
                            <StackPanel >
                                <Image Source="ApplicationIcon.png" Width="200" Height="300"/>
                                <TextBlock Text="{TemplateBinding content}" TextAlignment="Center" />
                            </StackPanel >
                        </Border >
                    </ControlTemplate >
                </Setter.Value >
            </Setter >
        </Style >
    </Application.Resources>

此处是mainpage.xaml.cs

namespace 控件模板
{
    public partial class MainPage : PhoneApplicationPage
    {
        // 构造函数
        public MainPage()
        {
            InitializeComponent();
            this.Loaded +=(s,e)=>
                {
                    custombutton.Click +=
                        new RoutedEventHandler(custombutton_Click);
                    standardbutton.Click +=
                        new RoutedEventHandler(standardbutton_Click); 
  相关解决方案