Visual Studio Designer的预览问题 [英] Preview Problem of Visual Studio Designer

查看:161
本文介绍了Visual Studio Designer的预览问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个如下所示的窗口:


< Window
xmlns
= http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns < font color ="#ff0000"> x = http://schemas.microsoft .com / winfx / 2006 / xaml
x =" Desktop.InputDialog"
x 名称
=" Window"
标题
=" Neuer名称"
宽度 =" 300" 高度
=" 80"
已加载 =" Window_Loaded">



< Window.Triggers >
< EventTrigger RoutedEvent
=" FrameworkElement.Loaded">
< BeginStoryboard
故事板 =" { StaticResource DialogOpenAnimation }" />
< / EventTrigger
>
< / < font color ="#a31515"> Window.Triggers
>


...
< / 窗口
>

Visual Studio Designer无法加载此窗口,因为静态资源DialogAnimation,在App.xaml中定义了whis:


< 应用程序 x Class =" Desktop.App"
xmlns
= http://schemas.microsoft.com/winfx/2006/xaml/presentation
xmlns x = http://schemas.microsoft.com/winfx/2006/xaml
< font size = 2> xmlns local
=" clr-namespace:Desktop"
StartupUri =" Window1.xaml">


< Application.Resources >
< 故事板 x
=" DialogOpenAnimation">
< DoubleAnimationUsingKeyFrames BeginTime =" 00:00:00" Storyboard.TargetName =" { x }" Storyboard.TargetProperty
="(UIElement.Opacity)">
< SplineDoubleKeyFrame KeyT ime =" 00:00:00"
= " 0" />
< SplineDoubleKeyFrame KeySpline =" 0,0,1,0" KeyTime =" 00:00:00.2000000"
=" 1" />
< / DoubleAnimationUsingKeyFrames
>
< / 故事板
>
< / Application.Resources >
< /
申请
>

有人能告诉我吗为什么窗口没有正确显示?
最好的问候,
Adrian。

解决方案

Hi derKlecks

很抱歉花了这么长时间才回复。如果您还没有在其他地方阅读过,这是Visual Studio 2008 Designer的一个已知限制。即使您的XAML正确且运行正常,设计人员也无法加载app.xaml中定义的静态资源。

目前唯一的选择都有一些缺点:

1。将所有对app.xaml中定义的资源的StaticResouce引用更改为DynamicResource引用(这不是最理想的,可能会对您的应用产生性能影响)
2。将引用的资源从app.xaml复制/移动到Window.Resources部分(对于需要在窗口之间共享的资源,这也是次优的)
3。将资源移动到资源字典中,并直接从窗口引用该资源字典而不是通过app.xaml(对于许多情况来说这不是一个糟糕的解决方案,尽管它会强制您在每个使用它的窗口中添加引用,共享字典)
4。和设计师一起生活,不要加载这样做的页面(取决于你对视觉设计师的使用程度,这或多或少会有刺激性)。您可以隐藏设计器以查找执行此操作的页面,只需双击分隔XAML和设计器窗格的拆分器即可查看XAML视图,Visual Studio 2008 SP1将记住下次打开该特定窗口时的设置。 br>
我们知道这对许多用户来说是一个重要的限制,正在考虑在Visual Studio的下一个主要版本(Visual Studio 2010)中改变我们的行为

谢谢

Mark Wilson-Thomas
项目经理,WPF& Silverlight Designer,Visual Studio Team


Hello,

I have a Window that looks like this:

<Window
    xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    x:Class="Desktop.InputDialog"
    x:Name
="Window"
    Title
="Neuer Name"
    Width="300" Height
="80"
    Loaded="Window_Loaded">

<Window.Triggers>
    <EventTrigger RoutedEvent
="FrameworkElement.Loaded">
        <BeginStoryboard Storyboard="{StaticResource DialogOpenAnimation
}"/>
    </EventTrigger
>
</Window.Triggers>

...
</Window
>

The Visual Studio Designer cannot load this Window, because of the Static Resource DialogAnimation, whis is defined in App.xaml:

<Application x:Class="Desktop.App"
    xmlns
=http://schemas.microsoft.com/winfx/2006/xaml/presentation
    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
    xmlns:local="clr-namespace:Desktop"
    StartupUri="Window1.xaml">

<Application.Resources>
    <Storyboard x:Key
="DialogOpenAnimation">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="{x:Null}" Storyboard.TargetProperty
="(UIElement.Opacity)">
            <SplineDoubleKeyFrame KeyTime="00:00:00" Value
="0"/>
            <SplineDoubleKeyFrame KeySpline="0,0,1,0" KeyTime="00:00:00.2000000" Value
="1"/>
        </DoubleAnimationUsingKeyFrames
>
    </Storyboard
>
</Application.Resources>
</
Application
>

Could someone tell me why the window is not shown correctly?
Best Regards,
Adrian.

解决方案

Hi derKlecks

Sorry to have taken so long to respond. If you haven't already read elsewhere, this is a known limitation of the Visual Studio 2008 Designer. Even though your XAML is correct and will run properly, the designer cannot load static resources defined in app.xaml.

The only options you have at this point all have some disadvantages to them:

1. Change all your StaticResouce references to resources defined in app.xaml into DynamicResource references (this is suboptimal and can have performance consequences for your app)
2. Copy/move your referenced resource down into the Window.Resources section from app.xaml (this is also suboptimal for a resource that needs to be shared between windows)
3. Move the resource into a resource dictionary, and reference that resource dictionary from the window directly rather than via app.xaml (this not a bad solution for many cases although it will force you to add a reference in every window that uses it, to the shared dictionary)
4. Live with the designer not loading pages that do this (depending on how much use you make of the visual designer this will be more or less irritating). You can hide the designer for pages that do this, and just see the XAML view, by double-clicking the splitter that separates the XAML and designer panes, and Visual Studio 2008 SP1 will remember that setting next time that particular window is opened.

We are aware this is an important limitation for many users, and are considering changing our behavior in the next major release of Visual Studio (Visual Studio 2010)

Thanks

Mark Wilson-Thomas
Program Manager, WPF & Silverlight Designer, Visual Studio Team


这篇关于Visual Studio Designer的预览问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆