Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ItemsControlExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 using System.Text;
7 using System.Threading.Tasks;
8 using System.Windows;
9 using System.Windows.Controls;
10 using System.Windows.Media;
11 
12 namespace SiliconStudio.Presentation.Extensions
13 {
14  public static class ItemsControlExtensions
15  {
16  public static ItemsControl GetParentContainer(this ItemsControl itemsControl)
17  {
18  DependencyObject parent = VisualTreeHelper.GetParent(itemsControl);
19 
20  while (parent != null && (parent is ItemsControl) == false)
21  parent = VisualTreeHelper.GetParent(parent);
22 
23  return parent as ItemsControl;
24  }
25 
27  {
28  ItemContainerGenerator gen = itemsControl.ItemContainerGenerator;
29 
30  foreach (var item in gen.Items)
31  {
32  var container = gen.ContainerFromItem(item) as ItemsControl;
33  if (container != null)
34  yield return container;
35  }
36  }
37  }
38 }
static IEnumerable< ItemsControl > GetChildContainers(this ItemsControl itemsControl)
static ItemsControl GetParentContainer(this ItemsControl itemsControl)