tags:

views:

413

answers:

1

Using the following code, I'm retrieving a list of Integers from a DB and Converting them to Images of Flags

   <ComboBox Name="ComboBox1" ItemSource="{Binding Path=NumberList">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <Image Source="{Binding Path=Numbers, Converter={StaticResource myValueFlagConverter}}" />
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>

If I wanted to have a ComboBox with values 1 to 3 without Binding to the NumberList in the DB, how would I do that using my converter using the simple example below as a starting point or maybe bind to a local array or something?

    <ComboBox Name="ComboBox2" >
        <ComboBoxItem>1</ComboBoxItem>
        <ComboBoxItem>2</ComboBoxItem>
        <ComboBoxItem>3</ComboBoxItem>
    </ComboBox>
A: 

Not sure I understand what you're trying to do but I suppose it could be something like:

ComboBox1.ItemSource = new List() { 1, 2, 3};

   <ComboBox Name="ComboBox1">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <Image Source="{Binding Converter={StaticResource myValueFlagConverter}}" />
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>
vidalsasoon
Hi, I'm just trying to understand the best way to populate my combobox with integer values that are not derived from a DB and then convert those values to images using my converter. The ComboBox1 example works 100% but it's retrieving the integers from a DB not a local source.
Mitch
Also, I was Binding using code behind which wasn't clear in my example so I am now showing the Binding ItemsSource in XAML.
Mitch
I updated answer. maybe it help
vidalsasoon