|
using System;
using System.ComponentModel.Composition;
using System.Linq;
using System.Windows.Controls;
using Microsoft.Practices.Composite.Regions;
namespace MefBasic.Helper
{
[Export]
public class RegionManagerHelper
{
[Import]
private Lazy<IRegionManager> RegionManager { get; set; }
public void ActivateView<T>(string regionName)
{
var region = RegionManager.Value.Regions[regionName];
var view = region.Views.Cast<IView>().SingleOrDefault(v => v is T);
if(view!=null)
region.Activate(view);
}
public double ViewWidth(string regionName)
{
var region = RegionManager.Value.Regions[regionName];
return region.ActiveViews.Cast<UserControl>().Sum(activeView => activeView.ActualWidth);
}
public double ViewHeight(string regionName)
{
var region = RegionManager.Value.Regions[regionName];
return region.ActiveViews.Cast<UserControl>().Sum(activeView => activeView.ActualHeight);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.