是否有方法自定义除背景之外的Callisto自定义对话框的样式?我要更改自定义对话框的标题属性的字体大小和颜色。有什么建议不破坏基本风格吗?
发布于 2015-04-15 06:46:37
CustomDialog的模板将标题的前景色计算为与背景形成对比的颜色,并将FontSize设置为26.6667:
<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上设置它们:
<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>然后将它们设置为您自己的资源:
<callisto:CustomDialog Background="{ThemeResource MyCustomDialogBackground}" Foreground="{ThemeResource MyCustomDialogForeground}" Title="Lorem ipsum" Template="{StaticResource CustomDialogControlTemplate1}"></callisto:CustomDialog>https://stackoverflow.com/questions/29636757
复制相似问题