Callisto Custom Dialog Пользовательский стиль для приложения Windows

Есть ли способ настроить стиль Callisto Custom Dialog, кроме фона? Я хочу изменить размер шрифта и цвет свойства заголовка в настраиваемом диалоге. Любые предложения, не возиться с базовым стилем?

Ссылка: https://github.com/timheuer/callisto/wiki/CustomDialog

1 ответ

Решение

Шаблон 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 Каллисто, а затем заменить свойства Foreground и 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>
Другие вопросы по тегам