首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Metro App Callisto框架扩展CustomDialog -添加TitleBackground

Metro App Callisto框架扩展CustomDialog -添加TitleBackground
EN

Stack Overflow用户
提问于 2013-05-03 03:31:08
回答 1查看 243关注 0票数 1

有人知道如何从Callisto metro应用程序框架中扩展CustomDialog控件来添加TitleBackground属性吗?

实际上,我希望对Title所在行的Background进行着色。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-04 17:22:19

弄清楚了:

在CustomDialog.cs add中:

代码语言:javascript
复制
 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样式并将栅格定义更改为:

代码语言:javascript
复制
                        <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}}" />
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16346235

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档