【问题标题】:Failed to assign to property 'Microsoft.Toolkit.Uwp.UI.Controls.AdaptiveGridView.DesiredWidth'未能分配给属性“Microsoft.Toolkit.Uwp.UI.Controls.AdaptiveGridView.DesiredWidth”
【发布时间】:2017-08-28 18:50:04
【问题描述】:

每次我的 UWP 应用从 Microsoft.UWP.Toolkit 加载带有 AdaptiveGridView 的页面时,我都会收到此异常:

The text associated with this error code could not be found.

Failed to assign to property 'Microsoft.Toolkit.Uwp.UI.Controls.AdaptiveGridView.DesiredWidth'. [Line: 30 Position: 183]

这是我的应用程序主页中AdaptiveGridView 控件的示例 XAML 定义:

<toolkit:AdaptiveGridView ItemsSource="{Binding Path=Data}" Padding="5" Grid.Row="1" SelectionMode="None" IsItemClickEnabled="True" ItemClick="AnimeClick" DesiredWidth="400" ItemHeight="74">
    <toolkit:AdaptiveGridView.ItemTemplate>
        <DataTemplate>
            <Grid Height="74" Background="#242424" Margin="4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="54" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="auto" />
                </Grid.ColumnDefinitions>
                <Image Margin="2" Source="{Binding Path=Thumbnail}" />
                <TextBlock Grid.Column="1" TextAlignment="Center" FontWeight="Medium" FontSize="16" TextWrapping="WrapWholeWords" Text="{Binding Path=Name}" />
            </Grid>
        </DataTemplate>
    </toolkit:AdaptiveGridView.ItemTemplate>
</toolkit:AdaptiveGridView>

另外,这是我的project.json,以防万一:

{
  "dependencies": {
    "Fody": "2.1.2",
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
    "Microsoft.Toolkit.Uwp": "1.5.1",
    "Microsoft.Toolkit.Uwp.UI": "1.5.1",
    "Microsoft.Toolkit.Uwp.UI.Controls": "1.5.1",
    "Newtonsoft.Json": "9.0.1",
    "PropertyChanged.Fody": "2.1.4",
    "Win2D.UWP": "1.21.0"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

我是否遗漏了一些参考资料?是不是设置不正确?

谢谢!

【问题讨论】:

    标签: c# .net uwp uwp-xaml


    【解决方案1】:

    找不到与此错误代码相关的文本。

    当我在项目中使用 "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0" 时,它会抛出您提到的异常。但是,当我更新 Microsoft.NETCore.UniversalWindowsPlatform 版本为 5.4.0(Visual Studio 2017),效果很好。 请尝试将Microsoft.NETCore.UniversalWindowsPlatform 更新到最新的稳定版本。

    Install-Package Microsoft.NETCore.UniversalWindowsPlatform -Version 5.4.0
    

    【讨论】:

    • 谢谢!这解决了问题。起初我不确定我是否能够解决它,因为我没有 VS2017,但即使将它更新到 5.2.0 也足够了,它仍然适用于 VS2015。
    猜你喜欢
    • 2016-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-01
    • 1970-01-01
    • 2016-09-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多