locked
Media Element insertion in Comboboxes

    Question

  • Hello,

    Is there any way to list the media elements files inside a Combobox. For example, if i have something like 3-4 videos, Is it possible to arrange it in a drop down for the selection to be easier?

    Thanks & Regards,

    Manideep

    Orbit Technology Research Limited


    manideep

    Tuesday, October 14, 2014 8:37 AM

Answers

  • Not with videos, but images from videos :

                        <ComboBox ItemsSource="{Binding VideoImageList}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <Image Source="{Binding ImagePath}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>

    with :

                        public ObservableCollection<ImageData> VideoImageList { get; set; }

                        public class ImageData
                        {
                               public string ImagePath { get; set; }

                         }

                                                                
    Tuesday, October 14, 2014 10:24 AM
  • All together ...

        public class ImageData
        {
            public string ImagePath { get; set; }
            public string IdVideo { get; set; }
        }

        public class AppData
        {
            public ObservableCollection<ImageData> ImageList
            {
                get { return _ImageList; }
                set { _ImageList = value; }
            }
            private ObservableCollection<ImageData> _ImageList = new ObservableCollection<ImageData>();

            public AppData()
            {
                ImageList.Add(new ImageData() { ImagePath = "ms-appx:///Assets/1.jpg" });
                ImageList.Add(new ImageData() { ImagePath = "ms-appx:///Assets/2.jpg" });
                ImageList.Add(new ImageData() { ImagePath = "ms-appx:///Assets/3.jpg" });
            }
        }

        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();

                AppData appData = new AppData();

                this.DataContext = appData;

                coboImage.SelectedIndex = 0;
            }
        }
        
    in MainPage.xaml :
        
            <StackPanel Orientation="Horizontal" Margin="0,20,0,0" HorizontalAlignment="Left" Height="200">
                <TextBlock Text="Image:" FontSize="24" Height="32" Width="100" HorizontalAlignment="Left" Margin="100,0,0,0"/>
                <ComboBox x:Name="coboImage" ItemsSource="{Binding ImageList}" HorizontalAlignment="Left" Height="120" Width="150">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <Image Source="{Binding ImagePath}"  Height="100" HorizontalAlignment="Left" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </StackPanel>

    Regards

    Torsten

    Tuesday, October 14, 2014 12:38 PM

All replies

  • Not with videos, but images from videos :

                        <ComboBox ItemsSource="{Binding VideoImageList}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <Image Source="{Binding ImagePath}" />
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>

    with :

                        public ObservableCollection<ImageData> VideoImageList { get; set; }

                        public class ImageData
                        {
                               public string ImagePath { get; set; }

                         }

                                                                
    Tuesday, October 14, 2014 10:24 AM
  • Hello Menzel,

    Thanks for the reply, Can you please provide the sample project what you have done with the data inserted in the combobox.

    Thanks & Regards 

    ManiDeep

    Orbit Technology Research Limited


    manideep

    Tuesday, October 14, 2014 10:40 AM
  • All together ...

        public class ImageData
        {
            public string ImagePath { get; set; }
            public string IdVideo { get; set; }
        }

        public class AppData
        {
            public ObservableCollection<ImageData> ImageList
            {
                get { return _ImageList; }
                set { _ImageList = value; }
            }
            private ObservableCollection<ImageData> _ImageList = new ObservableCollection<ImageData>();

            public AppData()
            {
                ImageList.Add(new ImageData() { ImagePath = "ms-appx:///Assets/1.jpg" });
                ImageList.Add(new ImageData() { ImagePath = "ms-appx:///Assets/2.jpg" });
                ImageList.Add(new ImageData() { ImagePath = "ms-appx:///Assets/3.jpg" });
            }
        }

        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();

                AppData appData = new AppData();

                this.DataContext = appData;

                coboImage.SelectedIndex = 0;
            }
        }
        
    in MainPage.xaml :
        
            <StackPanel Orientation="Horizontal" Margin="0,20,0,0" HorizontalAlignment="Left" Height="200">
                <TextBlock Text="Image:" FontSize="24" Height="32" Width="100" HorizontalAlignment="Left" Margin="100,0,0,0"/>
                <ComboBox x:Name="coboImage" ItemsSource="{Binding ImageList}" HorizontalAlignment="Left" Height="120" Width="150">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <Image Source="{Binding ImagePath}"  Height="100" HorizontalAlignment="Left" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </StackPanel>

    Regards

    Torsten

    Tuesday, October 14, 2014 12:38 PM