tags:

views:

62

answers:

1

I am trying to bind a combo box to a property on my ViewModel. The target type is short? and I would like to have null be an option. Basically I would like the value of the first item in the combo box be {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>

Any Suggestions?

+2  A: 

If you are using XAML 2009 / .NET 4 then you can use a new syntax for creating generics using XAML.

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

<Nullable x:TypeArguments="clr:Int16" />

This article has other, more complex, scenerios for generics in XAML.

Nate Zaugg