WPF - Passen Sie den Stil der Meldung in der Extended WPF Toolkit

Gründen der Anpassung für die MessageBox-style , ich benutze dieses toolkit, und ich kopiere den Stil-code von der offiziellen Seite:

http://wpftoolkit.codeplex.com/wikipage?title=MessageBox&referringTitle=Dokumentation

Ich es ein bisschen geändert:

<Application x:Class="TotaraEditor.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:TotaraEditor"
             xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
             StartupUri="MainWindow.xaml"
             ShutdownMode="OnMainWindowClose">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Themes/MetroDark/MetroDark.MSControls.Core.Implicit.xaml" />
                <ResourceDictionary Source="Themes/MetroDark/MetroDark.MSControls.Toolkit.Implicit.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <SolidColorBrush x:Key="MyButtonHoverBrush" Color="#FF2D2D30" />
            <SolidColorBrush x:Key="MyButtonPressedBrush" Color="#FF03A9DD" />

            <Style x:Key="MyCloseButtonStyle" TargetType="Button">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Grid>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal"/>
                                        <VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource MyButtonHoverBrush}"></DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background)">
                                                    <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{StaticResource MyButtonPressedBrush}"></DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Border x:Name="Background" CornerRadius="0,0,0,0" Background="Green">
                                    <Border Margin="1,0,1,1" BorderBrush="#59FFFFFF" BorderThickness="1" CornerRadius="0,0,1,0"/>
                                </Border>
                                <ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
                                <Path x:Name="path" Fill="White" Margin="0,0,0,1" Visibility="Collapsed"
                    Height="60"
        Width="7"
        Stretch="Fill"
        Opacity="1"
        Data="M 2,6 C2,6 3,6 3,6 3,6 3,5 3,5 3,5 4,5 4,5 4,5 4,6 4,6 4,6 5,6 5,6 5,6 7,6 7,6 7,6 7,5 7,5 7,5 6,5 6,5 6,5 6,4 6,4 6,4 5,4 5,4 5,4 5,2 5,2 5,2 6,2 6,2 6,2 6,1 6,1 6,1 7,1 7,1 7,1 7,0 7,0 7,0 5,0 5,0 5,0 4,0 4,0 4,0 4,1 4,1 4,1 3,1 3,1 3,1 3,0 3,0 3,0 2,0 2,0 2,0 0,0 0,0 0,0 0,1 0,1 0,1 1,1 1,1 1,1 1,2 1,2 1,2 2,2 2,2 2,2 2,4 2,4 2,4 1,4 1,4 1,4 1,5 1,5 1,5 0,5 0,5 0,5 0,6 0,6 0,6 2,6 2,6 z"/>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type toolkit:MessageBox}">
                <Setter Property="Background" Value="#FF1E1E1E" />
                <Setter Property="BorderBrush" Value="#FF999999" />
                <Setter Property="CaptionForeground" Value="#FFF1F1F1" />
                <Setter Property="WindowBorderBrush" Value="#FF686868" />
                <Setter Property="WindowBackground" Value="#FF2D2D30" />
                <Setter Property="WindowOpacity" Value="0.3" />
                <Setter Property="Foreground" Value="#FFF1F1F1"/>
                <Setter Property="CloseButtonStyle" Value="{StaticResource MyCloseButtonStyle}"/>
            </Style>



        </ResourceDictionary>

    </Application.Resources>
</Application>

Dies ist, wie ich es im code behind:

var res = Xceed.Wpf.Toolkit.MessageBox.Show( 
                            "R U sure?", 
                            "Confirm dialog", 
                            MessageBoxButton.YesNoCancel, 
                            MessageBoxImage.None, 
                            MessageBoxResult.Cancel, 
                            null 
                        ); 
if ("Cancel" == res.ToString()) {...} 
else if ("No" == res.ToString()) {...} 
else if ("Yes" == res.ToString()) {...} 
else {...}

Und was ich jetzt habe ist:
WPF - Passen Sie den Stil der Meldung in der Extended WPF Toolkit

Da es keine Möglichkeit gibt, zu berühren, der XAML-Code der Tasten, wie sollte ich ändern Sie die Schaltflächen-Stil? Zumindest möchte ich zum entfernen der leuchtende Effekt des headers.

Dank.

UPDATE

Ich bin sicher, dass die leuchtende Wirkung ist nicht verursacht durch den Stil angewendet, um das Etikett, es ist ein formatiertes Rechteck unter dem Label, ich fand dies in WPF Inspector:

WPF - Passen Sie den Stil der Meldung in der Extended WPF Toolkit

Nachdem ich die Höhe des "rect" zu 0, das glühende Ding verschwunden.

InformationsquelleAutor VincentZHANG | 2016-04-26
Schreibe einen Kommentar