Esempio n. 1
0
        /// <summary>
        /// Fires when the value of the SelectedIndexProperty dependency property changes
        /// </summary>
        /// <param name="d">Dependency object containing the property that changed</param>
        /// <param name="e">Arguments passed to the change event</param>
        private static void OnSelectedIndexPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MediaItemDialog mid = d as MediaItemDialog;

            if (mid.SelectedIndex != -1)
            {
                MediaItem selectedMediaItem = mid.MediaItems[mid.SelectedIndex];

                Boolean modified = false;

                //refresh the size of the parts
                foreach (MediaItemPart part in selectedMediaItem.Parts)
                {
                    FileInfo fi = new FileInfo(part.Location.Value);

                    if (fi.Exists)
                    {
                        if (part.Size != fi.Length)
                        {
                            part.Size = fi.Length;
                            modified = true;
                        }
                    }
                }

                if (modified)
                    mid.OnSavedMediaItem(selectedMediaItem);

                mid.SelectedMediaItem = selectedMediaItem.Clone() as MediaItem;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Fires when the value of the SelectedMediaItemProperty dependency property changes
        /// </summary>
        /// <param name="d">Dependency object containing the property that changed</param>
        /// <param name="e">Arguments passed to the change event</param>
        private static void OnSelectedMediaItemPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MediaItemDialog mid = d as MediaItemDialog;

            FocusManager.SetFocusedElement(mid, mid.btnOK);
            mid.UpdateLayout();
            FocusManager.SetFocusedElement(mid, mid.SelectedMediaItemView.SelectedElement);
        }