示例#1
0
 internal static void SyncColumnProperty <T>(AvaloniaObject column, AvaloniaObject content, AvaloniaProperty <T> contentProperty, AvaloniaProperty <T> columnProperty)
 {
     if (!column.IsSet(columnProperty))
     {
         content.ClearValue(contentProperty);
     }
     else
     {
         content.SetValue(contentProperty, column.GetValue(columnProperty));
     }
 }
示例#2
0
 /// <remarks>
 /// This method reflects Grid.SharedScopeProperty state by setting / clearing
 /// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty
 /// is a collection of SharedSizeState objects for the scope.
 /// </remarks>
 internal static void OnIsSharedSizeScopePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
 {
     if ((bool)e.NewValue)
     {
         SharedSizeScope sharedStatesCollection = new SharedSizeScope();
         d.SetValue(PrivateSharedSizeScopeProperty, sharedStatesCollection);
     }
     else
     {
         d.ClearValue(PrivateSharedSizeScopeProperty);
     }
 }
示例#3
0
        /// <summary>
        /// Removes the specified view from the region.
        /// </summary>
        /// <param name="view">The view to remove.</param>
        public virtual void Remove(object view)
        {
            ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view);

            this.ItemMetadataCollection.Remove(itemMetadata);

            AvaloniaObject dependencyObject = view as AvaloniaObject;

            if (dependencyObject != null && Regions.RegionManager.GetRegionManager(dependencyObject) == this.RegionManager)
            {
                dependencyObject.ClearValue(Regions.RegionManager.RegionManagerProperty);
            }
        }
示例#4
0
        public static object UpdateDependencyColor(this AvaloniaObject depo, AvaloniaProperty dp, Color newColor)
        {
            if (!newColor.IsDefault)
            {
                depo.SetValue(dp, newColor.ToBrush());
            }
            else
            {
                depo.ClearValue(dp);
            }

            return(depo.GetValue(dp));
        }
 private static void ClearChildViews(IRegion region)
 {
     foreach (var view in region.Views)
     {
         AvaloniaObject dependencyObject = view as AvaloniaObject;
         if (dependencyObject != null)
         {
             if (GetClearChildViews(dependencyObject))
             {
                 dependencyObject.ClearValue(RegionManager.RegionManagerProperty);
             }
         }
     }
 }
示例#6
0
 /// <summary>
 /// <see cref="PropertyMetadata.PropertyChangedCallback"/>
 /// </summary>
 /// <remarks>
 /// This method reflects Grid.SharedScopeProperty state by setting / clearing
 /// dynamic property PrivateSharedSizeScopeProperty. Value of PrivateSharedSizeScopeProperty
 /// is a collection of SharedSizeState objects for the scope.
 /// Also PrivateSharedSizeScopeProperty is FrameworkPropertyMetadataOptions.Inherits property. So that all children
 /// elements belonging to a certain scope can easily access SharedSizeState collection. As well
 /// as been norified about enter / exit a scope.
 /// </remarks>
 internal static void OnIsSharedSizeScopePropertyChanged(AvaloniaObject d, AvaloniaPropertyChangedEventArgs e)
 {
     //  is it possible to optimize here something like this:
     //  if ((bool)d.GetValue(Grid.IsSharedSizeScopeProperty) == (d.GetLocalValue(PrivateSharedSizeScopeProperty) != null)
     //  { /* do nothing */ }
     if ((bool)e.NewValue)
     {
         SharedSizeScope sharedStatesCollection = new SharedSizeScope();
         d.SetValue(PrivateSharedSizeScopeProperty, sharedStatesCollection);
     }
     else
     {
         d.ClearValue(PrivateSharedSizeScopeProperty);
     }
 }