System.Windows.Controls.ItemsControlHelper.UpdateItemContainerStyle C# (CSharp) Method

UpdateItemContainerStyle() private method

Update the style of any generated items when the ItemContainerStyle has been changed.
Silverlight does not support setting a Style multiple times, so we only attempt to set styles on elements whose style hasn't already been set.
private UpdateItemContainerStyle ( System.Windows.Style itemContainerStyle ) : void
itemContainerStyle System.Windows.Style The ItemContainerStyle.
return void
        internal void UpdateItemContainerStyle(Style itemContainerStyle)
        {
            if (itemContainerStyle == null)
            {
                return;
            }

            Panel itemsHost = ItemsHost;
            if (itemsHost == null || itemsHost.Children == null)
            {
                return;
            }

            foreach (UIElement element in itemsHost.Children)
            {
                FrameworkElement obj = element as FrameworkElement;
                if (obj.Style == null)
                {
                    obj.Style = itemContainerStyle;
                }
            }
        }

Usage Example

Beispiel #1
0
 /// <summary>
 /// ItemContainerStyleProperty property changed handler.
 /// </summary>
 /// <param name="newValue">New value.</param>
 protected virtual void OnItemContainerStyleChanged(Style newValue)
 {
     ItemsControlHelper.UpdateItemContainerStyle(newValue);
 }