Click here to Skip to main content
15,887,262 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can't simply set the x:Name attribute of the ComboBox because there are more than one. I also don't know how to get a specific ComboBox from code, to set/get the Text property.
Here is a simplified version of my XAML file:

<pre lang="XML">
<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!-- its Page because i'm using Kaxaml -->
  <Page.Resources>
    <XmlDataProvider x:Key="PropertyData" XPath="/properties">
                <x:XData>
                <!-- This is actually in an external xml file -->
                    <properties xmlns="">
                        <property name="some property">
                            <item value="5"  />
                            <item value="10"  />
                            <item value="15"  />
                            <item value="20"  />
                        </property>
                        <property name="other property">
                            <item value="5"  />
                            <item value="10"  />
                            <item value="15"  />
                            <item value="20"  />
                        </property>
                    </properties>
                </x:XData>
            </XmlDataProvider>
  </Page.Resources>
  <ListView  DataContext="{StaticResource PropertyData}" ItemsSource="{Binding XPath=property}">
    <ListView.View>
      <GridView>
        <GridViewColumn Header="Property" DisplayMemberBinding="{Binding XPath=@name}" />
        <GridViewColumn Header="Value">
          <GridViewColumn.CellTemplate>
            <DataTemplate>
              <ComboBox Width="100" ItemsSource="{Binding XPath=item}"  DisplayMemberPath="@value"></ComboBox>
            </DataTemplate>
          </GridViewColumn.CellTemplate>
        </GridViewColumn>
      </GridView>
    </ListView.View>
  </ListView>
</Page>

Ok, if you can solve this you get the genius label. Thanks in advance...

What I have tried:

I have tried to handle the Loaded event of the combo box in the code-behind file, but it works erractly. I also tried to create a dependency property for the selected item, but i don't know what to do with it.
Posted
Comments
Graeme_Grant 4-Jun-23 4:19am    
Why a ListView control? DataGrid would do a better job.

Why use an XmlDataProvider when a simple bound list would be a better choice?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900