ComboBox populating inside ListView in WPF

I filled ComboBoxinside ListView. Screenshot below enter image description here

As shown above, it displays "M", "a", "c" instead of "Mac". Why does it divide a word into characters?

In the code behind the file, I wrote

ItemCategoryDAL itemCategoryDalObj = new ItemCategoryDAL ();
            DataTable dataTable = itemCategoryDalObj.GetAllItemCategory ();

            listView1.ItemsSource = dataTable.DefaultView;

And in the .xaml file I wrote:

<ListView Height = "148" HorizontalAlignment = "Left" Margin = "23,12,0,0" Name = "listView1" VerticalAlignment = "Top" Width = "447">
  <ListView.View>
     <GridView>
        - - - - - - - - 
        - - - - - - - -
        <GridViewColumn Header="Category Name" Width="150">
           <GridViewColumn.CellTemplate>
               <DataTemplate>
                  <ComboBox ItemsSource="{Binding Path=IC_NAME }" Width="120" />
               </DataTemplate>
           </GridViewColumn.CellTemplate>
        </GridViewColumn> 
        - - - - - - - - -
        - - - - - - - - -
     </GridView>
  </ListView.View>
</ListView>

Visual Studio 2010

dataTable, ItemSource ListView. ( ) enter image description here

+3
2

A ComboBox . , ItemsSource Items.

ItemsSource , . , ComboBox , , "Mac" "M", "a" "c".

, . : ( ) ? ComboBox? , , DataTable, - :

ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=ListView}, Path=ItemsSource}"

IC_Name , DataTemplate:

<ComboBox.ItemTemplate>
   <DataTemplate>
      <TextBlock Text="{Binding IC_Name}"/>
   </DataTemplate>
</ComboBox.ItemTemplate>

, , , . , "Foo" IC_Name, , , , "Foo" ComboBox es, . , "Foo", ComboBox "Foo" .

+4

, , , IC_NAME "Mac" . : "M", "a" "c". ItemSource ComboBox.

<ComboBox ItemsSource="{Binding Path=IC_NAME }" Width="120" />

, - :

<ComboBox 
  SelectedItem="{Binding Path=IC_NAME}"
  ItemsSource="{Binding Path=NameOfACollectionProperty }" 
  Width="120" />
0

Source: https://habr.com/ru/post/1794096/


All Articles