【问题标题】:Metro App Callisto Framework extend CustomDialog - Add TitleBackgroundMetro App Callisto Framework 扩展 CustomDialog - 添加 TitleBackground
【发布时间】:2013-05-05 00:40:59
【问题描述】:

有谁知道如何从Callisto Metro 应用框架扩展CustomDialog 控件,以添加TitleBackground 属性?

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

【问题讨论】:

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


    【解决方案1】:

    想通了:

    在 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}}" />
    

    【讨论】:

      猜你喜欢
      • 2014-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-09
      • 2016-02-22
      • 2021-12-06
      • 2016-04-14
      相关资源
      最近更新 更多