UWP扩展绑定错误。无法设置“路径”

时间:2018-08-21 10:29:45

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

我有这样的代码:

<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”类型的对象

错误无法设置“路径”

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

谢谢, 康拉德

1 个答案:

答案 0 :(得分:0)

  1. 右键单击解决方案->清洁解决方案。
  2. 重复步骤1
  3. 关闭Visual Studio并重新打开它。
  4. 重建解决方案
相关问题