Xamarin Forms - ResourceDictionary 和 <System:Uint32> 值

Xamarin Forms - ResourceDictionary and <System:Uint32> value

这是一个简单的问题,也许很愚蠢,但我被困了几个小时..

我在 XAML 部分有:

<ContentPage.Resources>
  <ResourceDictionary>
    <System:Uint32 x:Key="UintValue">50</System:Uint32>
  </ResourceDictionary>
</ContentPage.Resources>

当然,要获得 <System> 类型的访问权限,我有以下行:

xmlns:System="clr-namespace:System;assembly=mscorlib"

但是,我有一个 XAML 解析异常。当我评论 <System:Uint32...</System:Uint32> 时,它就起作用了。 #ButIDontHaveTheValue..

There is a link to the doc of Uint

Type | Range              | Size                    | .NET Framework type
uint | 0 to 4,294,967,295 | Unsigned 32-bit integer | System.UInt32

所以如果我是对的,那么 Uint32 来自系统,所以我必须像 System:Uint32 一样引用它?

感谢帮助!

有点晚了,但我还是会 post 回答的。您需要导入的类型应该是 UInt32 而不是 Uint32,区分大小写。无论如何,如果您想将此值绑定到 Margin 或类似值,您应该使用 String 代替,因为它们可以接受更多由冒号分隔的整数,并且它们是一个字符串。

<ContentPage 
xmlns="http://xamarin.com/schemas/2014/forms" 
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
xmlns:System="clr-namespace:System;assembly=mscorlib">
...
<System:UInt32 x:Key="sdsd">15</System:UInt32>
...
</ContentPage>