-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathGridRegionAdapter.cs
More file actions
37 lines (33 loc) · 993 Bytes
/
Copy pathGridRegionAdapter.cs
File metadata and controls
37 lines (33 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Avalonia.Controls;
using Prism.Navigation.Regions;
namespace SampleApp.Main.Core.RegionAdapters
{
public class GridRegionAdapter : RegionAdapterBase<Grid>
{
public GridRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory)
: base(regionBehaviorFactory)
{
}
protected override void Adapt(IRegion region, Grid regionTarget)
{
region.Views.CollectionChanged += (sender, e) =>
{
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
{
foreach (Control item in e.NewItems)
{
regionTarget.Children.Add(item);
}
}
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
{
foreach (Control item in e.OldItems)
{
regionTarget.Children.Remove(item);
}
}
};
}
protected override IRegion CreateRegion() => new SingleActiveRegion() { };
}
}