【问题标题】:WinRt :XAML Tag doesnot exist in the namespaceWinRt:命名空间中不存在 XAML 标记
【发布时间】:2014-08-05 07:21:21
【问题描述】:

我正在创建一个我想要验证文本框的项目,因此为此使用 prism 并实现如下示例

http://msdn.microsoft.com/en-us/library/windows/apps/xx130660.aspx

我实现的一切工作正常,但是当我更改 Page 的 xaml 中的代码时,它找不到我实现的类等。

举例

<prism:VisualStateAwarePage
     xmlns:prism="using:Microsoft.Practices.Prism.StoreApps"
     xmlns:vm="using:PrismExample.ViewModels"
     xmlns:Behaviors="using:PrismExample.Behaviors"
     x:Class="PrismExample.Views.UserInfoView"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">

<Page.DataContext>
    **<vm:UserInfoViewModel/>**
</Page.DataContext>

<TextBox x:Name="FirstNameValue" Grid.Row="2"
    Text="{Binding UserInfo.FirstName, Mode=TwoWay}">
    <interactivity:Interaction.Behaviors>
    <!--<Behaviors:HighlightFormFieldOnErrors PropertyErrors="{Binding UserInfo.Errors[FirstName]}">-->
    **<quickstartBehaviors:HighlightFormFieldOnErrors** PropertyErrors="{Binding UserInfo.Errors[FirstName]}" />
    </interactivity:Interaction.Behaviors>
</prism:VisualStateAwarePage>

现在在这里,粗体文本给出了它在命名空间中不存在的错误。 任何人都可以帮我解决这个问题。我怎样才能摆脱这个。

【问题讨论】:

  • 这是全部一个组件吗?还是您的视图模型在不同的程序集中?如果您的视图模型位于不同的程序集中,请确保您引用的是该程序集。

标签: windows-store-apps winrt-xaml prism


【解决方案1】:

你有:

<Page.DataContext>
    **<vm:UserInfoViewModel/>**
</Page.DataContext>

这应该是:

<prism:VisualStateAwarePage.DataContext>
   <vm:UserInfoViewModel/>
</prism:VisualStateAwarePage.DataContext>

【讨论】:

  • 不,你可以这样引用基数。
【解决方案2】:

在您的代码中,您引用了quickstartBehaviors,但您的页面中只定义了Behaviors 的XMLNS。您应该查看HighlightFormFieldOnErrors 的定义位置。

让我们假设它有效。但是,努尔,我不知道该怎么说。控件上的验证不同于视图模型中的验证。我的意思是,我认为可能有更好的方法供您考虑。如果您有兴趣,请阅读:http://blog.jerrynixon.com/2014/07/lets-code-handling-validation-in-your.html

祝你好运!

【讨论】:

  • 感谢您的支持..但我只是实现那篇文章所包含的内容..:) 我一定会尝试理解所引用的文章。
  • 我意识到这一点。我认为值得指出的是,验证已从 Prism 中删除。因此,如果您升级... :( 悲伤。
猜你喜欢
  • 1970-01-01
  • 2011-10-11
  • 2014-08-23
  • 1970-01-01
  • 2014-04-19
  • 1970-01-01
  • 2020-10-13
  • 1970-01-01
  • 2014-02-15
相关资源
最近更新 更多