init
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Practices.Prism.Regions;
|
||||
|
||||
namespace DTS.Common
|
||||
{
|
||||
public class ViewerStackPanelRegionAdapter : RegionAdapterBase<StackPanel>
|
||||
{
|
||||
|
||||
public ViewerStackPanelRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)
|
||||
: base(regionBehaviorFactory)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Adapt(IRegion region, StackPanel regionTarget)
|
||||
{
|
||||
if (region == null) return;
|
||||
|
||||
region.Views.CollectionChanged += (sender, e) =>
|
||||
{
|
||||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
|
||||
foreach (UIElement element in e.NewItems)
|
||||
{
|
||||
regionTarget.Children.Add(element);
|
||||
}
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
|
||||
foreach (UIElement elementLoopVariable in e.OldItems)
|
||||
{
|
||||
var element = elementLoopVariable;
|
||||
|
||||
if (regionTarget.Children.Contains(element))
|
||||
{
|
||||
regionTarget.Children.Remove(element);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected override IRegion CreateRegion()
|
||||
{
|
||||
return new AllActiveRegion();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user