首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows应用程序的Callisto自定义对话框自定义样式

Windows应用程序的Callisto自定义对话框自定义样式
EN

Stack Overflow用户
提问于 2015-04-14 20:24:29
回答 1查看 275关注 0票数 0

是否有方法自定义除背景之外的Callisto自定义对话框的样式?我要更改自定义对话框的标题属性的字体大小和颜色。有什么建议不破坏基本风格吗?

参考资料:https://github.com/timheuer/callisto/wiki/CustomDialog

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-15 06:46:37

CustomDialog的模板将标题的前景色计算为与背景形成对比的颜色,并将FontSize设置为26.6667:

代码语言:javascript
复制
<StackPanel Margin="13,19,13,25" HorizontalAlignment="Center" Width="{TemplateBinding Width}" MaxWidth="680"> 
    <local:DynamicTextBlock Foreground="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Background, Converter={StaticResource ColorContrast}}" x:Name="PART_Title" Text="{TemplateBinding Title}" FontFamily="Segoe UI" FontSize="26.6667" FontWeight="Light" Margin="0,0,0,8" /> 
    <ContentPresenter Margin="0" x:Name="PART_Content" Foreground="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=Background, Converter={StaticResource ColorContrast}}" /> 
</StackPanel> 

如果您想要更改这些内容,则需要重新定位对话框。您可以从卡里斯托氏generic.xaml复制模板,然后替换前台和FontSize属性。您可能希望使用TemplateBinding,以便在调用它时可以在CustomDialog上设置它们:

代码语言:javascript
复制
<StackPanel Margin="9,5" HorizontalAlignment="Center" Width="{TemplateBinding Width}" MaxWidth="680">
    <callisto:DynamicTextBlock Foreground="{TemplateBinding Foreground}" x:Name="PART_Title" Text="{TemplateBinding Title}" FontFamily="Segoe UI" FontSize="{TemplateBinding FontSize}" FontWeight="Light" Margin="0,0,0,8" />
    <ContentPresenter Margin="0" x:Name="PART_Content" Foreground="{TemplateBinding Foreground}" />
</StackPanel>

然后将它们设置为您自己的资源:

代码语言:javascript
复制
<callisto:CustomDialog Background="{ThemeResource MyCustomDialogBackground}" Foreground="{ThemeResource MyCustomDialogForeground}" Title="Lorem ipsum" Template="{StaticResource CustomDialogControlTemplate1}"></callisto:CustomDialog>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29636757

复制
相关文章

相似问题

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