none
WPF中设置Effect属性导致程序崩溃 RRS feed

  • 问题

  • 今天在另一台电脑(XP系统)测试程序的时候发现程序不能启动(或者说是启动后自动关闭,不会弹出任何提示),而在做开发的这台电脑(也是XP系统)上没有任何问题。最后分析原来是跟Effect有关。只要用到了Effect就会导致程序自动关闭。到底是什么原因,缺少组件?请各位大侠赐教!!!

    连给Effect效果赋null值也是一样:
     
      private void button1_Click(object sender, RoutedEventArgs e)
      {
      button1.Effect = null;
      }

    开发环境:Visual Studio 2008、Windows XP SP3

    2012年4月10日 4:23

答案

  • 你的代码在Windows 7, VS 2008 .Net 3.5 下没有任何问题。

    我想还是和具体机器或者显卡硬件相关。

    我想确认,你系统是否升级到了 .Net 3.5 SP1, 是否开发一个空白的WPF+Effect也会崩溃? 如果是的话,是否你看一下系统事件日志,或者打开 VS 2008 Output, 看看是否有异常抛出。


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年4月19日 10:12
    版主
  • 你好!我发现问题的所在了,就像你说的,我的部署包里的.net Framework还是3.5版本的,没有升级到3.5 SP1。我想问一下,想在系统必备中添加“.Net Framework 3.5 SP1”这个必备组件选项应该要怎么样做呢?

    2012年5月14日 2:27

全部回复

  • 有无完整代码,Effect得效果和硬件,机器支持的DX有关,请问你是否是独立显卡且安装了最新显卡驱动,并且在平时运行DX相关游戏或者等效果时是正常? 我建议你可以关注下显卡和DX方向的问题排查,建议可以尝试关闭硬件加速,通过软件来渲染效果进行测试,以排查是否是显卡支持的问题。(XP最高仅支持到DX 9.0,是否已经安装升级到DX 9)

    关于如何调整软硬件加速,请参考:http://msdn.microsoft.com/zh-cn/library/aa970912.aspx 

    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DisableHWAcceleration

    或者通过代码, 在Window.Loaded event:

                    HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
                    HwndTarget hwndTarget = hwndSource.CompositionTarget;
                    
                    // this is the new WPF API to force render mode.
                    hwndTarget.RenderMode = RenderMode.SoftwareOnly;


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年4月10日 16:38
    版主
  •        

    谢谢你的回复!已经安装好了Directx 9.0C。此外,我照你说的做了,但好像还是会崩溃,下面是一些源码。另外,我还发现在使用一些自定义样式的时候也会发生崩溃的问题,代码也贴在下面了。

    Window1.xaml.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Windows.Interop;
    namespace test
    {
        /// <summary>
        /// Window1.xaml 的交互逻辑
        /// </summary>
        public partial class Window1 : Window
        {
            public Window1()
            {
                InitializeComponent();
                 
            }
            private void button1_Click(object sender, RoutedEventArgs e)
            {
                HwndSource hwndSource = PresentationSource.FromVisual(button1) as HwndSource;
                HwndTarget hwndTarget = hwndSource.CompositionTarget;
                // this is the new WPF API to force render mode.
                hwndTarget.RenderMode = RenderMode.SoftwareOnly;
                button1.Effect = null;//使用Effect属性就崩溃关闭了
            }
            private void button2_Click(object sender, RoutedEventArgs e)
            {
                button2.Style = this.Resources["style1"] as Style;//使用样式style1就崩溃关闭了
            }
        }
    }

    Windows1.xaml

    <Window x:Class="test.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
        <Window.Resources>
            <Style x:Key="style1" TargetType="{x:Type Button}">
                <Style.BasedOn>
                    <Style TargetType="{x:Type ButtonBase}">
                        <Setter Property="FocusVisualStyle">
                            <Setter.Value>
                                <Style>
                                    <Setter Property="Control.Template">
                                        <Setter.Value>
                                            <ControlTemplate>
                                                <Border>
                                                    <Rectangle SnapsToDevicePixels="True" Margin="4,4,4,4" Stroke="#FF000000" StrokeDashArray="1 2" StrokeThickness="1"/>
                                                </Border>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                        <Setter Property="BorderBrush">
                            <Setter.Value>
                                <SolidColorBrush/>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="BorderThickness" Value="3,3,3,3"/>
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        <Setter Property="VerticalContentAlignment" Value="Center"/>
                        <Setter Property="Padding" Value="0,0,1,1"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ButtonBase}">
                                    <ControlTemplate.Resources>
                                        <Storyboard x:Key="Storyboard1">
                                            <PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.StartPoint)">
                                                <SplinePointKeyFrame KeyTime="00:00:00" Value="0.622,0.926"/>
                                                <SplinePointKeyFrame KeyTime="00:00:00.2000000" Value="0.387,0.063"/>
                                            </PointAnimationUsingKeyFrames>
                                            <PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.EndPoint)">
                                                <SplinePointKeyFrame KeyTime="00:00:00" Value="0.378,0.074"/>
                                                <SplinePointKeyFrame KeyTime="00:00:00.2000000" Value="0.613,0.937"/>
                                            </PointAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="5"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="-5"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.StrokeThickness)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="3"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFE1933C"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="Storyboard2">
                                            <PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.StartPoint)">
                                                <SplinePointKeyFrame KeyTime="00:00:00" Value="0.387,0.063"/>
                                                <SplinePointKeyFrame KeyTime="00:00:00.2000000" Value="0.622,0.926"/>
                                            </PointAnimationUsingKeyFrames>
                                            <PointAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(LinearGradientBrush.EndPoint)">
                                                <SplinePointKeyFrame KeyTime="00:00:00" Value="0.613,0.937"/>
                                                <SplinePointKeyFrame KeyTime="00:00:00.2000000" Value="0.378,0.074"/>
                                            </PointAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="5"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="-5"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.StrokeThickness)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="3"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFE1933C"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FF000000"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="Storyboard3">
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF8BCDE3"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FF727475"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="Storyboard4">
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF727475"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FF8BCDE3"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </ControlTemplate.Resources>
                                    <Grid Width="Auto" Height="Auto">
                                        <Rectangle Stroke="#FF000000" RadiusY="20" RadiusX="20" x:Name="rectangle">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint="0.378,0.074" StartPoint="0.622,0.926">
                                                    <GradientStop Color="#FFE3F3F8" Offset="0"/>
                                                    <GradientStop Color="#FF8BCDE3" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" x:Name="contentPresenter" RenderTransformOrigin="0.5,0.5" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Margin="{TemplateBinding Padding}" ContentTemplate="{TemplateBinding ContentTemplate}">
                                            <ContentPresenter.RenderTransform>
                                                <TransformGroup>
                                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                                    <SkewTransform AngleX="0" AngleY="0"/>
                                                    <RotateTransform Angle="0"/>
                                                    <TranslateTransform X="0" Y="0"/>
                                                </TransformGroup>
                                            </ContentPresenter.RenderTransform>
                                        </ContentPresenter>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <EventTrigger RoutedEvent="Mouse.MouseEnter">
                                            <BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="Mouse.MouseLeave">
                                            <BeginStoryboard Storyboard="{StaticResource Storyboard2}" x:Name="Storyboard2_BeginStoryboard"/>
                                        </EventTrigger>
                                        <Trigger Property="IsKeyboardFocused" Value="True"/>
                                        <Trigger Property="Button.IsDefaulted" Value="True"/>
                                        <Trigger Property="IsPressed" Value="True"/>
                                        <Trigger Property="ToggleButton.IsChecked" Value="True"/>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Trigger.ExitActions>
                                                <BeginStoryboard Storyboard="{StaticResource Storyboard4}" x:Name="Storyboard4_BeginStoryboard"/>
                                            </Trigger.ExitActions>
                                            <Trigger.EnterActions>
                                                <BeginStoryboard Storyboard="{StaticResource Storyboard3}" x:Name="Storyboard3_BeginStoryboard"/>
                                            </Trigger.EnterActions>
                                            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                        </Trigger>
                                        <Trigger Property="ClickMode" Value="Release"/>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Style.BasedOn>
                <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                <Setter Property="Cursor" Value="Hand"/>
            </Style>
        </Window.Resources>
        
        <Grid>
            <Button Height="23" Margin="65,61,138,0" Name="button1" VerticalAlignment="Top" Click="button1_Click">Button1</Button>
            <Button Height="23" Margin="65,0,138,103" Name="button2" VerticalAlignment="Bottom" Click="button2_Click">Button2</Button>
        </Grid>
    </Window>

    但如果用一下的自定义按钮样式,则能正常显示:

      <Style  TargetType="{x:Type Button}">
                <Style.BasedOn>
                    <Style TargetType="{x:Type ButtonBase}">
                        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
                        <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                        <Setter Property="BorderBrush">
                            <Setter.Value>
                                <SolidColorBrush/>
                            </Setter.Value>
                        </Setter>
                        <Setter Property="BorderThickness" Value="3,3,3,3"/>
                        <Setter Property="HorizontalContentAlignment" Value="Center"/>
                        <Setter Property="VerticalContentAlignment" Value="Center"/>
                        <Setter Property="Padding" Value="0,0,1,1"/>
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ButtonBase}">
                                    <ControlTemplate.Resources>
                                        <Storyboard x:Key="MouseIn">
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFDDD21B"/>
                                            </ColorAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="-5"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="5"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="MouseOut">
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFDDD21B"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFFFFFFF"/>
                                            </ColorAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="-5"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="5"/>
                                                <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
                                            </DoubleAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="MouseDown">
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFFFFF"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFDD781B"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                        <Storyboard x:Key="MouseUp">
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFDD781B"/>
                                                <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFFFFFFF"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </ControlTemplate.Resources>
                                    <Grid FocusVisualStyle="{x:Null}" Width="Auto" Height="Auto" Cursor="Hand">
                                        <Rectangle FocusVisualStyle="{x:Null}" Margin="0,0,0,0" x:Name="rectangle" VerticalAlignment="Stretch" Stroke="#FF000000" RadiusX="20" RadiusY="20" ScrollViewer.VerticalScrollBarVisibility="Disabled" StrokeThickness="0">
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <GradientStop Color="#FF2CA9EB" Offset="0"/>
                                                    <GradientStop Color="#FFFFFFFF" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <ContentPresenter HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Center" x:Name="contentPresenter" RenderTransformOrigin="0.5,0.5" Content="{TemplateBinding Content}" FocusVisualStyle="{x:Null}">
                                            <ContentPresenter.RenderTransform>
                                                <TransformGroup>
                                                    <ScaleTransform ScaleX="1" ScaleY="1"/>
                                                    <SkewTransform AngleX="0" AngleY="0"/>
                                                    <RotateTransform Angle="0"/>
                                                    <TranslateTransform X="0" Y="0"/>
                                                </TransformGroup>
                                            </ContentPresenter.RenderTransform>
                                        </ContentPresenter>
                                    </Grid>
                                    <ControlTemplate.Triggers>
                                        <EventTrigger RoutedEvent="Mouse.MouseDown">
                                            <BeginStoryboard Storyboard="{StaticResource MouseDown}" x:Name="MouseDown_BeginStoryboard"/>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="Mouse.MouseUp">
                                            <BeginStoryboard Storyboard="{StaticResource MouseUp}" x:Name="MouseUp_BeginStoryboard"/>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="Mouse.MouseEnter">
                                            <BeginStoryboard x:Name="MouseIn_BeginStoryboard" Storyboard="{StaticResource MouseIn}"/>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="Mouse.MouseLeave">
                                            <BeginStoryboard x:Name="MouseOut_BeginStoryboard" Storyboard="{StaticResource MouseOut}"/>
                                        </EventTrigger>
                                        <Trigger Property="IsKeyboardFocused" Value="True"/>
                                        <Trigger Property="Button.IsDefaulted" Value="True"/>
                                        <Trigger Property="IsPressed" Value="True"/>
                                        <Trigger Property="ToggleButton.IsChecked" Value="True"/>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Style.BasedOn>
            </Style>


    2012年4月19日 7:47
  • 你的代码在Windows 7, VS 2008 .Net 3.5 下没有任何问题。

    我想还是和具体机器或者显卡硬件相关。

    我想确认,你系统是否升级到了 .Net 3.5 SP1, 是否开发一个空白的WPF+Effect也会崩溃? 如果是的话,是否你看一下系统事件日志,或者打开 VS 2008 Output, 看看是否有异常抛出。


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年4月19日 10:12
    版主
  • 你好!我发现问题的所在了,就像你说的,我的部署包里的.net Framework还是3.5版本的,没有升级到3.5 SP1。我想问一下,想在系统必备中添加“.Net Framework 3.5 SP1”这个必备组件选项应该要怎么样做呢?

    2012年5月14日 2:27
  • 首先,你发布用的机器上要先安装了.Net 3.5 SP1, 然后在VS Setup项目的“先决条件”中,就会有.Net 3.5 SP1这个选项:

    或者,你可以根据文档 http://msdn.microsoft.com/zh-cn/library/ms165429.aspx 来创建引导工具包清单(工具:http://archive.msdn.microsoft.com/bmg/Release/ProjectReleases.aspx?ReleaseId=1567),让其检查并安装你需要的3.5 SP1。

    .Net 3.5 SP1下载:http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=ab99342f-5d1a-413d-8319-81da479ab0d7


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年5月14日 3:16
    版主