Metro App Callisto Framework扩展CustomDialog - 添加TitleBackground

时间:2013-05-02 19:31:08

标签: c#-4.0 windows-runtime microsoft-metro winrt-xaml callisto

有谁知道如何从CustomDialog metro app框架扩展Callisto控件,添加TitleBackground属性?

实际上,我想为Background出现的行的Title上色。

1 个答案:

答案 0 :(得分:0)

想出来:

在CustomDialog.cs中添加:

 public Brush TitleBackground
    {
        get { return (Brush)GetValue(TitleBackgroundProperty); }
        set { SetValue(TitleBackgroundProperty, value); }
    }

    public static readonly DependencyProperty TitleBackgroundProperty =
        DependencyProperty.Register("TitleBackground", typeof(Brush), typeof(CustomDialog), null);

然后在Generic.xaml中,转到CustomDialog样式并将Grid定义更改为:

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="80"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <Rectangle Grid.ColumnSpan="3" Grid.Row="0" Fill="{TemplateBinding TitleBackground}"/>
                        <Button Grid.Column="0" Grid.Row="0" x:Name="PART_BackButton" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,24,0,0" Style="{StaticResource DialogBackButtonStyle}" Command="{TemplateBinding BackButtonCommand}" CommandParameter="{TemplateBinding BackButtonCommandParameter}" Visibility="{TemplateBinding BackButtonVisibility}"/>
                        <local:DynamicTextBlock Grid.Column="1" Grid.Row="0" Foreground="{TemplateBinding TitleForeground}" x:Name="PART_Title" Text="{TemplateBinding Title}" FontFamily="Segoe UI" FontSize="26.6667" FontWeight="Light" Margin="0,0,0,8" />
                        <ContentPresenter Grid.Column="1" Grid.Row="1" Margin="0" x:Name="PART_Content" Foreground="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Background, Converter={StaticResource ColorContrast}}" />