Ejemplo n.º 1
0
 /// <summary>
 ///     Detaches this instance from its associated object.
 /// </summary>
 public void Detach()
 {
     if (_applicationBar == null)
     {
         throw new InvalidOperationException(
                   "The BindableApplicationBarMenuItem is not attached to an IBindableApplicationBar.");
     }
     OriginalList.Remove(ApplicationBarItem);
     _applicationBar = null;
     _position       = -1;
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Attaches to the specified <see cref="IBindableApplicationBar" />.
        /// </summary>
        public void Attach(IBindableApplicationBar applicationBar, int position)
        {
            Should.NotBeNull(applicationBar, "applicationBar");
            if (_applicationBar != null)
            {
                throw new InvalidOperationException(
                          "The BindableApplicationBarMenuItem is already attached to an IBindableApplicationBar.");
            }
            var localValue = ReadLocalValue(DataContextProperty);

            if (localValue == DependencyProperty.UnsetValue)
            {
                SetBinding(DataContextProperty, new Binding("DataContext")
                {
                    Source = applicationBar
                });
            }
            _applicationBar = applicationBar;
            _position       = position;
            UpdateItem(IsVisible);
        }
 public static void SetApplicationBar(UIElement element, IBindableApplicationBar value)
 {
     element.SetValue(ApplicationBarProperty, value);
 }
 public void Detach()
 {
     if (_applicationBar == null)
         throw new InvalidOperationException(
             "The BindableApplicationBarMenuItem is not attached to an IBindableApplicationBar.");
     OriginalList.Remove(ApplicationBarItem);
     _applicationBar = null;
     _position = -1;
 }
 public void Attach(IBindableApplicationBar applicationBar, int position)
 {
     Should.NotBeNull(applicationBar, nameof(applicationBar));
     if (_applicationBar != null)
         throw new InvalidOperationException(
             "The BindableApplicationBarMenuItem is already attached to an IBindableApplicationBar.");
     var localValue = ReadLocalValue(DataContextProperty);
     if (localValue == DependencyProperty.UnsetValue)
         SetBinding(DataContextProperty, new System.Windows.Data.Binding("DataContext") { Source = applicationBar });
     _applicationBar = applicationBar;
     _position = position;
     UpdateItem(IsVisible);
 }
Ejemplo n.º 6
0
 public static void SetApplicationBar(UIElement element, IBindableApplicationBar value)
 {
     element.SetValue(ApplicationBarProperty, value);
 }