Set ItemsSource of a ComboBox to an Array of Integers?

Shimmy Weitzhandler picture Shimmy Weitzhandler · Dec 1, 2009 · Viewed 13.1k times · Source

Set ItemsSource of a ComboBox to an Array of Integers?

Answer

Shimmy Weitzhandler picture Shimmy Weitzhandler · Dec 1, 2009
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <Window.Resources>
        <x:Array x:Key="Integers" Type="{x:Type sys:Int32}">
            <sys:Int32>0</sys:Int32>
            <sys:Int32>1</sys:Int32>
            <sys:Int32>2</sys:Int32>
        </x:Array>
    </Window.Resources>
    <ComboBox ItemsSource="{Binding Source={StaticResource Integers}}" />
</Window>