There is a code, I take the names of all the pictures in the grid and write them down to the List . Then for the combobox set this List as a data source. It is filled, but the names do not display. In XAML wrote:

 DisplayMemberPath="Name" 

Because I took the names Image . The list fills, but does not display:

 public void InputImage() { var children = grid.Children; foreach (var child in children) { var image = child as Image; if (image is Image) { Names.Add(image.Name); } } imglist.ItemsSource = Names; } 

    2 answers 2

    In XAML, remove DisplayMemberPath="Name" and do not need extra classes.

    Or easier, if the Names sheet itself will no longer be used, do not remove the DisplayMemberPath="Name" from the XAML, but the InputImage method will be

     public void InputImage() { imglist.ItemsSource = grid.Children.OfType<Image>(); } 
    • That's interesting who put a minus - Mikalai Kharevich
    • Not me. The question should sound, not "who", but "for what". - 0xdb
    • Agree) for what?) - Mikalai Kharevich

    Solved the problem by adding a class:

     public class ImageName { public string Name { get; set; } } public void InputImage() { var children = grid.Children; foreach (var child in children) { var image = child as Image; if (image is Image) { Names.Add(new ImageName { Name = image.Name}); } } imglist.ItemsSource = Names; }