1

有谁知道如何从Metro 应用程序框架扩展CustomDialog控件以添加属性?CallistoTitleBackground

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

4

1 回答 1

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}}" />
于 2013-05-04T09:22:18.780 回答