0

ListView でホストされている ComboBox があり、ListView がバインドされているサポート クラスを更新するには CombBox を変更する必要があります。

これが私のDataTemplateです

<DataTemplate x:Key="Category">
    <ComboBox IsSynchronizedWithCurrentItem="False" 
              Style="{StaticResource DropDown}" 
              ItemsSource="{Binding Source={StaticResource Categories}}"
              SelectedValuePath="Airport"
              SelectedValue="{Binding Path=Category}"
              />
    </DataTemplate>

これがリストビューです。ListView の ItemSource は Airports のコレクションであり、コード ビハインドで設定されており、更新するためにコンボ ボックスが必要な Category というプロパティがあります。

<ListView.View>
            <GridView>
                <GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="Airport" Width="100" />
                <GridViewColumn Header="Category" Width="100"  CellTemplate="{StaticResource Category}" />
            </GridView>
        </ListView.View>
4

2 に答える 2

1

なぜあなたはあなたに設定SelectedValuePathしましたComboBoxか?データ構造を見ずに言うのは難しいですが、それは私には正しくありません。

于 2008-12-24T18:23:20.123 に答える
0

ComboBox と ListView をサポートするデータは次のとおりです。

Imports System.Collections.ObjectModel

クラスウィンドウ1

Public Airports As New ObservableCollection(Of Airport)
Public Sub New()
    ' This call is required by the Windows Form Designer.
    InitializeComponent()

    '*************************
    'Dummy data for testing


    Dim anAirports As New Airport
    anAirports.Name = "ABC"
    anAirports.Category = "AA"

    Airports.Add(anAirports)

    anAirports = New Airport
    anAirports.Name = "DEF"
    anAirports.Category = "BB"

    Airports.Add(anAirports)
    '*************************
    'Bind the airports to the list for display
    lstCategories.ItemsSource = Airports

End Sub

クラス終了

パブリッククラスの空港

''' <summary>
''' Name of the Airport
''' </summary>
''' <remarks></remarks>
Private mName As String
Public Property Name() As String
    Get
        Return mName
    End Get
    Set(ByVal value As String)
        mName = value
    End Set
End Property

''' <summary>
''' Describes the type airport and is selected from a combobox
''' </summary>
''' <remarks></remarks>
Private mCategory As String
Public Property Category() As String
    Get
        Return mCategory
    End Get
    Set(ByVal value As String)
        mCategory = value
    End Set
End Property

クラス終了

''' ''' ComboBox ''' ''' Public Class Categories に表示されるアイテム

Inherits ObservableCollection(Of String)

Public Sub New()
    Me.Add("AA")
    Me.Add("BB")

End Sub

クラス終了

于 2008-12-24T18:58:36.370 に答える