forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxViewRenderer.cs
37 lines (32 loc) · 984 Bytes
/
BoxViewRenderer.cs
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 Windows.UI.Xaml;
using Windows.UI.Xaml.Automation.Peers;
using Windows.UI.Xaml.Shapes;
namespace Xamarin.Forms.Platform.UWP
{
public class BoxViewRenderer : ViewRenderer<BoxView, Windows.UI.Xaml.Shapes.Rectangle>
{
protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
{
if (Control == null)
{
var rect = new Windows.UI.Xaml.Shapes.Rectangle();
rect.DataContext = Element;
rect.SetBinding(Shape.FillProperty, new Windows.UI.Xaml.Data.Binding { Converter = new ColorConverter(), Path = new PropertyPath("Color") });
SetNativeControl(rect);
}
}
}
protected override AutomationPeer OnCreateAutomationPeer()
{
// We need an automation peer so we can interact with this in automated tests
if (Control == null)
{
return new FrameworkElementAutomationPeer(this);
}
return new FrameworkElementAutomationPeer(Control);
}
}
}