Exemple #1
0
        /// <summary>
        /// Invoked when the effective property value of the ItemsSource property changes.
        /// </summary>
        /// <param name="dependencyObject">The DependencyObject on which the property has changed value.</param>
        /// <param name="dependencyPropertyChangedEventArgs">Event data that is issued by any event that tracks changes to the effective value of this
        /// property.</param>
        static void OnItemsSourcePropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            // Extract the event arguments.
            DetailBar   detailBar = (DetailBar)dependencyObject;
            IEnumerable newValue  = (IEnumerable)dependencyPropertyChangedEventArgs.NewValue;

            // The ItemsSource can be cleared by setting the property to 'null' (and providing it's not data bound).  Otherwise this handler will set the
            // source of the internal collection to use the supplied collection.
            if (dependencyPropertyChangedEventArgs.NewValue == null && !BindingOperations.IsDataBound(dependencyObject, DetailBar.ItemsSourceProperty))
            {
                detailBar.items.ClearItemsSource();
            }
            else
            {
                detailBar.items.ItemsSource = newValue;
            }
        }
Exemple #2
0
        /// <summary>
        /// Handles the changing of the data context.
        /// </summary>
        /// <param name="sender">The object that originated the event.</param>
        /// <param name="dependencyPropertyChangedEventArgs">The event data.</param>
        void OnDataContextChanged(Object sender, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            // If the data context for this item is an ExplorerItem, we can set the common elements that appear in the DetailBar for all ExplorerItems.
            IExplorerItem iExplorerItem = dependencyPropertyChangedEventArgs.NewValue as IExplorerItem;

            if (iExplorerItem != null)
            {
                // This will set the image according to how much space is available in the DetailBar.
                this.SetImage();

                // Clear out whatever was previously in the DetailBar and present the item's name and type.
                this.commonMetadata.Clear();
                this.commonMetadata.Add(DetailBar.CreateMetadataText(iExplorerItem.Name, Brushes.Black, 13.33, new Thickness(0), TextAlignment.Left));
                this.commonMetadata.Add(
                    DetailBar.CreateMetadataText(iExplorerItem.TypeDescription, DetailBar.labelBrush, 12.0, new Thickness(0, 1, 0, 1), TextAlignment.Left));
            }
        }