Windows Presentation Foundation项目不支持PageFunction [英] PageFunction is not supported in a Windows Presentation Foundation project

查看:112
本文介绍了Windows Presentation Foundation项目不支持PageFunction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这与-但是,我不确定如何应用此处提到的解决方法,并认为将其作为一个单独的问题提出可能更合适.如果这违反网站精神,请提前道歉.

I'm aware this is the same issue as raised in "PageFunction is not supported in a Windows Presentation Foundation (WPF) project" 2012 - however, I'm unsure as to how to apply the workaround mentioned there, and thought it may be more appropriate to raise this as a separate question. Apologies in advance if this is against the site ethos.

总结问题:我有一个C#Visual Studio 2010 WPF项目,它已经存在了两年,现在我正尝试在Visual Studio 2012中打开它.尽管该项目仍然可以正常运行,但是我需要进行编辑XAML标记以及VS2012中的设计"视图抱怨标记无效".触发的确切错误是:

To summarise the problem: I have a C# Visual Studio 2010 WPF project that's a couple of years old, which I'm now trying to open in Visual Studio 2012. Although the project still builds and runs fine, I need to edit the XAML markup, and the Design view in VS2012 complains of "Invalid Markup". The exact error it's tripping up on is:

Windows Presentation Foundation不支持

页面功能 (WPF)项目

Page Function is not supported in a Windows Presentation Foundation (WPF) project

XAML的开始看起来像:

The start of the XAML looks like:

 <PageFunction
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyNamespace" 
    x:Class="MyProject.WizardPage1"
    x:TypeArguments="local:WizardResult"
    KeepAlive="True"
    WindowTitle="My Project" Height="350" ShowsNavigationUI="False" Width="700" >

如原始问题中所述,在

As mentioned in the original question, there are reports of this exact issue on this Microsoft page. There is a workaround mentioned involving "ViewBase", but I cannot see how this relates to the PageFunction problem (I'm very new to XAML so I may be missing something simple).

我已经尝试在VS2012(支持非Windows 8项目的新预览版)的Blend中打开项目,但是给出了关于不支持PageFunction的相同错误. VS2012的最新Update 1也没有解决此问题.

I've tried opening the project in Blend for VS2012 (the new Preview version that supports non-Windows 8 projects), but that gives the same error about PageFunction not being supported. The recent Update 1 for VS2012 hasn't fixed the problem either.

谁能建议我需要在XAML或代码隐藏中进行哪些更改,以便能够直观地编辑此页面?

Can anyone advise what I need to change in my XAML or code-behind in order to be able to visually edit this page?

还是应该放弃并重新下载VS2010才能编辑此项目?

Or should I give up and just re-download VS2010 in order to edit this project?

推荐答案

基于解决方法,您需要创建一个从PageFunction<WizardResult>派生的类,然后更新XAML以从该类继承.

Based on the workaround, you'll need to create a class which derives from PageFunction<WizardResult>, and then update your XAML to inherit from that class.

班级:

public class WizardResultPageFunction : PageFunction<WizardResult>
{
}

隐藏代码: 更改类以从您的新类继承,或者完全删除基类声明,然后让XAML定义基类:

Code-behind: Either change the class to inherit from your new class, or remove the base-class declaration completely and let the XAML define the base class:

public partial class WizardPage1
// or: 
// public partial class WizardPage1 : WizardResultPageFunction 
{
   ...
}

XAML:PageFunction替换为local:WizardResultPageFunction并删除x:TypeArguments属性:

XAML: Replace the PageFunction with local:WizardResultPageFunction and remove the x:TypeArguments attribute:

<local:WizardResultPageFunction 
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="clr-namespace:MyNamespace" 
   x:Class="MyProject.WizardPage1"
   KeepAlive="True"
   WindowTitle="My Project" Height="350" ShowsNavigationUI="False" Width="700"
>

这篇关于Windows Presentation Foundation项目不支持PageFunction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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