2015-04-14 57 views

回答

0

的CustomDialog的模板計算它的標題的前景,其與背景對比,並設置字號,以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> 

如果你想改變這些,你需要重新設置對話框。您可以從Callisto's generic.xaml複製的模板,然後更換前景和字號屬性。您可能需要使用一個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> 
+0

謝謝!這似乎是我想要的方向。在模板中使用「ThemeResource」的任何引用複製樣式時是否有任何問題?我不知道如何讓這些工作。您是否需要將每個「ThemeResource」設置複製到您的樣式中? 實施例: floydbear

+0

即實際工作。我只需要複製一些ThemeResources並將正確的指令設置爲一個轉換器。工作很棒!非常感謝你的幫助。 – floydbear