2009-10-06 2 views
0

콤보 상자 사용자 정의 문제 그래서 TemplateColumn이가는 길인 것 같습니다. 작게 시작하면서 표준 DataGridComboBoxColumn을 대체해야하는 다음 간단한 예제를 얻을 수 없습니다. 드롭 다운이 잘 나타나지만 '드롭 다운 항목'을 선택하면 허용되지 않고 이전 값으로 돌아갑니다. 나는 'Mode = TwoWay'의 변형을 시도했지만 운이 없다. 'CellEditingTemplate'이 필요합니까?WPF의 데이터 그리드 내가 다음으로 위대한 작품을 콤보 상자 바운드 열 데이터 그리드를

DefaultLocationID는 편집되는 외래 키 필드이고 'LocationID'는 'CustomerLocations'의 열입니다.

<tk:DataGridTemplateColumn Header="Default Location"> 
    <tk:DataGridTemplateColumn.CellTemplate> 
     <DataTemplate> 
      <ComboBox VerticalAlignment="Top" 
        SelectedItem="{Binding LocationID, Mode=TwoWay}" 
        SelectedValue="{Binding DefaultLocationID, Mode=TwoWay}" 

        ItemsSource="{Binding Source={StaticResource CustomerLocations}}" 
         SelectedValuePath="LocationID" 
         DisplayMemberPath="LocationName" > 
       </ComboBox> 
     </DataTemplate> 
    </tk:DataGridTemplateColumn.CellTemplate> 

감사합니다.

답변

0

CustomerLocations 리소스의 관련 부분을 게시 할 수 있습니까? 그리드가 바인딩하는 클래스 유형을 게시 할 수 있습니까?

ComboBox에서 SelectedValuePath, DisplayMemberPath 및 SelectedValue를 제거해보십시오.

당신이 당신의 콤보 상자에서 여러 데이터를 표시 할 경우 XAML

아래
<ComboBox ...> 
    <ComboBox.ItemTemplate> 
     <DataTemplate> 
      <StackPanel Orientation="Horizontal"> 
        <TextBlock Text="{Binding LocationId}"} /> 
        <TextBlock Text=" - "/> 
        <TextBlock Text="{Binding LocationName}"} /> 
      </StackPanel> 
     </DataTemplate> 
    </ComboBox.ItemTemplate> 
</ComboBox> 
참조
관련 문제