Ejemplo n.º 1
0
        /// <summary>
        /// Обновить кнопки верхней панели.
        /// </summary>
        /// <param name="elements">Коллекция кнопок.</param>
        private void UpdateTopBarButtons(OneCommandBarElementsCollection elements)
        {
            if (TopBarButtonPanel == null)
            {
                return;
            }
            try
            {
                TopBarButtonPanel.Children.Clear();
                if (elements == null)
                {
                    return;
                }

                var content = Content as FrameworkElement;
                var binding = new Binding()
                {
                    Mode = BindingMode.TwoWay, Path = new PropertyPath("DataContext"), Source = content
                };
                TopBarButtonPanel.SetBinding(FrameworkElement.DataContextProperty, binding);

                for (int i = 0; i < elements.Count; i++)
                {
                    TopBarButtonPanel.Children.Add((UIElement)elements[i]);
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Задает коллекцию кнопок верхней панели.
 /// </summary>
 public static void SetTopBarButtons(DependencyObject obj, OneCommandBarElementsCollection value)
 {
     obj.SetValue(TopBarButtonsProperty, value);
 }
Ejemplo n.º 3
0
 protected BaseOneCommandBar()
 {
     this.DefaultStyleKey = typeof(BaseOneCommandBar);
     PrimaryCommands      = new OneCommandBarElementsCollection();
 }