Wpf Datagrid crashes when applying style for button

Apr 28, 2009 at 9:50 AM

Hello All,
We are fed up with an issue regarding WPF toolkit datagrid.
We have created a style for buttons in our application, but when we are including this theme in app.xaml, wpf datagrid crashes in design view and Visualstudio becomes not responding state .
Please help us resolving this issue.
am including the theme here with this
regards
sreeraj

<ResourceDictionary
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <DrawingBrush x:Key="ButtonInnerBackground" Stretch="Fill">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <DrawingGroup.Children>
                    <GeometryDrawing Brush="#00000000" Geometry="F1 M 0,-9.53674e-007L 166.667,-9.53674e-007L 166.667,29.3333L 0,29.3333L 0,-9.53674e-007 Z "/>
                    <GeometryDrawing Geometry="F1 M 1.00931e-005,4.76837e-006L 166.667,4.76837e-006L 166.667,14.7278C 138.05,14.7278 115.251,10.3944 84.9167,10.3944C 54.5821,10.3944 27.0979,14.7278 1.00931e-005,14.7278L 1.00931e-005,4.76837e-006 Z ">
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="-0.003,0.5" EndPoint="1.003,0.5">
                                <LinearGradientBrush.GradientStops>
                                    <GradientStop Color="#5FFFFFFF" Offset="0"/>
                                    <GradientStop Color="#1AFFFFFF" Offset="0.495455"/>
                                    <GradientStop Color="#5FFFFFFF" Offset="1"/>
                                </LinearGradientBrush.GradientStops>
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                </DrawingGroup.Children>
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>

 

    <LinearGradientBrush x:Key="ButtonBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#FF89BEEB" Offset="0"/>
        <GradientStop Color="#FF114DA6" Offset="1"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="ButtonForeground" Color="#FFFAFCFF"/>

    <LinearGradientBrush x:Key="ButtonBorder" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#FF1B232C" Offset="0"/>
        <GradientStop Color="#FF1B222C" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HoverButtonBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#FF366FC2" Offset="0"/>
        <GradientStop Color="#FF2475EB" Offset="1"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="HoverButtonForeground" Color="#FFFFFFFF"/>

    <LinearGradientBrush x:Key="HoverButtonBorder" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#888888" Offset="0"/>
        <GradientStop Color="#000000" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="PressedButtonBackground" EndPoint="0,0" StartPoint="0,1">
        <GradientStop Color="#FF124DD2" Offset="0"/>
        <GradientStop Color="#FF0C2439" Offset="0.996"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="PressedButtonForeground" Color="#FFFFFFFF"/>

    <LinearGradientBrush x:Key="PressedButtonBorder" EndPoint="0,0" StartPoint="0,1">
        <GradientStop Color="#282828" Offset="0"/>
        <GradientStop Color="#686868" Offset="0.5"/>
        <GradientStop Color="#B2000002" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="DisabledButtonBackground" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#A8A8A8" Offset="0"/>
        <GradientStop Color="#5E5E5E" Offset="1"/>
    </LinearGradientBrush>

    <SolidColorBrush x:Key="DisabledButtonForeground" Color="#151515"/>

    <LinearGradientBrush x:Key="DisabledButtonBorder" EndPoint="0,1" StartPoint="0,0">
        <GradientStop Color="#282828" Offset="0"/>
        <GradientStop Color="#282828" Offset="1"/>
    </LinearGradientBrush>

    <Style x:Key="ButtonFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle SnapsToDevicePixels="true" Stroke="{StaticResource ButtonBorder}" StrokeDashArray="2 1" StrokeThickness="1" Margin="2" RadiusX="2" RadiusY="2"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type Button}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Foreground" Value="{StaticResource ButtonForeground}"/>
        <Setter Property="Background" Value="{StaticResource ButtonBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="FontFamily" Value="Arial"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Margin" Value="3"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="5,2"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border SnapsToDevicePixels="true" x:Name="BorderContent" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                        <Border.BitmapEffect>
                            <DropShadowBitmapEffect ShadowDepth="1" Softness="0.2" Opacity="1"/>
                        </Border.BitmapEffect>
                        <Border Background="{StaticResource ButtonInnerBackground}" BorderThickness="1" BorderBrush="Transparent" CornerRadius="2">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" Value="{StaticResource HoverButtonBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource HoverButtonBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource HoverButtonForeground}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Background" Value="{StaticResource PressedButtonBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource PressedButtonBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource PressedButtonForeground}"/>
                            <Setter Property="BitmapEffect" TargetName="BorderContent">
                                <Setter.Value>
                                    <DropShadowBitmapEffect Opacity="0.3" ShadowDepth="0" Softness="0.1"/>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Margin" Value="4,4,2,2"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="{StaticResource DisabledButtonBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource DisabledButtonBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource DisabledButtonForeground}"/>
                            <Setter Property="BitmapEffect" TargetName="BorderContent">
                                <Setter.Value>
                                    <DropShadowBitmapEffect Opacity="0" ShadowDepth="0" Softness="0.1"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
   
    <Style TargetType="{x:Type ToggleButton}">
        <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
        <Setter Property="Foreground" Value="{StaticResource ButtonForeground}"/>
        <Setter Property="Background" Value="{StaticResource ButtonBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ButtonBorder}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="FontSize" Value="11"/>
        <Setter Property="FontFamily" Value="Arial"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Margin" Value="3"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="5,3"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border SnapsToDevicePixels="true" x:Name="BorderContent" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                        <Border.BitmapEffect>
                            <DropShadowBitmapEffect ShadowDepth="1" Softness="0.2" Opacity="1"/>
                        </Border.BitmapEffect>
                        <Border Background="{StaticResource ButtonInnerBackground}" BorderThickness="1" BorderBrush="Transparent" CornerRadius="2">
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Background" Value="{StaticResource HoverButtonBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource HoverButtonBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource HoverButtonForeground}"/>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Background" Value="{StaticResource PressedButtonBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource PressedButtonBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource PressedButtonForeground}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" Value="{StaticResource DisabledButtonBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource DisabledButtonBorder}"/>
                            <Setter Property="Foreground" Value="{StaticResource DisabledButtonForeground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>