使用XAML声明一个可为空的int(int?)

使用XAML声明一个可为空的int(int?),xaml,Xaml,我正在尝试将组合框绑定到ViewModel上的属性。目标类型是short?,我希望选择null。基本上,我希望组合框中第一项的值是{x:Null} <ComboBox Grid.Row="9" Grid.Column="1" SelectedValue="{Binding Priority}"> <clr:Int16></clr:Int16> <clr:Int16>1</clr:Int16>

我正在尝试将组合框绑定到ViewModel上的属性。目标类型是
short?
,我希望选择
null
。基本上,我希望组合框中第一项的值是
{x:Null}

<ComboBox Grid.Row="9" Grid.Column="1" SelectedValue="{Binding Priority}">
            <clr:Int16></clr:Int16>
            <clr:Int16>1</clr:Int16>
            <clr:Int16>2</clr:Int16>
            <clr:Int16>3</clr:Int16>
            <clr:Int16>4</clr:Int16>
            <clr:Int16>5</clr:Int16>
            <clr:Int16>6</clr:Int16>
            <clr:Int16>7</clr:Int16>
            <clr:Int16>8</clr:Int16>
            <clr:Int16>9</clr:Int16>
            <clr:Int16>10</clr:Int16>
</ComboBox>

1.
2.
3.
4.
5.
6.
7.
8.
9
10

有什么建议吗?

如果您使用的是XAML 2009/.NET 4,那么您可以使用新语法来使用XAML创建泛型

xmlns="http://schemas.microsoft.com/netfx/2009/xaml/presentation"

<Nullable x:TypeArguments="clr:Int16" />
xmlns=”http://schemas.microsoft.com/netfx/2009/xaml/presentation"

对于XAML中的泛型,这还有其他更复杂的场景。

这在WPF中实际起作用吗?不幸的是,我不认为XAML 2009实际上在任何地方都实现了。如果您只是将XAML 2006声明替换为2009声明,一切都会正常工作。当我将2006替换为2009时,会出现大量错误,例如未知类型的usercontrol等。。。我正在开发UWP。有什么想法吗?