Ejemplo n.º 1
0
        public void Execute(object parameter)
        {
            System.Diagnostics.Debug.Assert(parameter != null);

            OpenFileDialog fileNavigator = new OpenFileDialog();

            fileNavigator.Filter = "*.jpg;*.dib;*.bmp;*.jpeg;*.jpe;*.jfif;*.gif;*.tif;*.tiff;*.png;*.wmv;*.mpg;*.mp4|*.jpg;*.dib;*.bmp;*.jpeg;*.jpe;*.jfif;*.gif;*.tif;*.tiff;*.png;*.wmv;*.mpg;*.mp4";

            if (fileNavigator.ShowDialog() == true)
            {
                if (parameter is MediaElement)
                {
                    // ((MediaElement)parameter).Source = new Uri(fileNavigator.FileName);
                    MediaElement media = parameter as MediaElement;
                    if (media.DataContext is ContentViewItem)
                    {
                        ContentViewItem cv = (ContentViewItem)media.DataContext;
                        cv.Content = fileNavigator.FileName;
                    }
                }
                else if (parameter is BitmapImage)
                {
                    ((Image)parameter).Source = new BitmapImage(new Uri(fileNavigator.FileName));
                }
            }
        }
Ejemplo n.º 2
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            ContentViewItem cv = item as ContentViewItem;

            if (cv != null)
            {
                FrameworkElement fe = container as FrameworkElement;
                if (fe != null)
                {
                    DataTemplate dt = fe.FindResource(cv.TemplateKey) as DataTemplate;
                    if (dt != null)
                    {
                        return(dt);
                    }
                }
            }
            return(base.SelectTemplate(item, container));
        }