【问题标题】:Uwp extension binding error. Failed to set "path"Uwp 扩展绑定错误。未能设置“路径”
【发布时间】:2018-08-21 10:29:44
【问题描述】:

我有这样的代码:

<Page
x:Class="App4.Views.AddPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App4.Views"
xmlns:conv="using:App4.Converters"
xmlns:extensions="using:Microsoft.Toolkit.Uwp.UI.Extensions"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
DataContext="{Binding AddPageInstance, Source={StaticResource Locator}}"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<Page.Resources>
    <conv:SalaryConverter x:Key="SalaryConverter"/>
</Page.Resources>

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <StackPanel Padding="20" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="300">
        <TextBox Text="{x:Bind Vm.Name, Mode=TwoWay}" 
                 x:Name="CharactValidator"
                 Header="Name"
                 PlaceholderText="Type Name here"
                 extensions:TextBoxRegex.ValidationMode="Dynamic"
                 extensions:TextBoxRegex.ValidationType="Characters"/>
        <TextBlock Text="{Binding (extensions:TextBoxRegex.IsValid), ElementName=CharactValidator}"/>
        <TextBlock Text="Salary"/>
        <TextBox Text="{x:Bind Vm.Salary, Mode=TwoWay, Converter={StaticResource SalaryConverter}}" PlaceholderText="Type Salary here"/>
        <TextBlock/>
        <TextBlock Text="Title"/>
        <TextBox Text="{x:Bind Vm.Title, Mode=TwoWay}" PlaceholderText="Type Title here"/>
        <TextBlock/>
        <TextBlock Text="Surname"/>
        <TextBox Text="{x:Bind Vm.Surname, Mode=TwoWay}" PlaceholderText="Type Surname here"/>
        <TextBlock/>
    </StackPanel>

</Grid>

问题是我有与扩展有关的错误:

无法将“动态”转换为“Microsoft.Toolkit.Uwp.UI.Extensions.TextBoxRegex+ValidationMode”类型的对象

无法将“字符”转换为“Microsoft.Toolkit.Uwp.UI.Extensions.TextBoxRegex+ValidationType”类型的对象

错误未能设置“路径”

构建应用程序后,它运行良好。但我不知道如何删除这些错误消息以及它出现的原因。如果需要任何其他信息,请询问我。

谢谢, 康拉德

【问题讨论】:

    标签: xaml uwp uwp-xaml windows-community-toolkit


    【解决方案1】:
    1. 右键解决方案 -> 清洁解决方案。
    2. 重复步骤 1
    3. 关闭 Visual Studio 并重新打开。
    4. 重建解决方案

    【讨论】:

    • 还是一样。我在后面的代码中添加了引用,但它仍然显示错误。
    • 很奇怪的错误,你在社区工具包 github repo 上打开过问题吗?
    • 还没有。我正在尝试逐步检查所有内容,以确保它没有故障。
    • 我建议你在那里打开一个问题,看起来你已经完成了一切工作,因为你能够成功运行构建并运行应用程序吗?
    • 是的,我是。它可以正常工作。我在 github repo 上发布了新问题。 github.com/Microsoft/WindowsCommunityToolkit/issues/2418
    猜你喜欢
    • 1970-01-01
    • 2018-06-21
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    • 1970-01-01
    • 1970-01-01
    • 2017-07-14
    • 2014-07-13
    相关资源
    最近更新 更多