-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue6693ControlRenderer.cs
54 lines (46 loc) · 1.56 KB
/
Issue6693ControlRenderer.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Xamarin.Forms.ControlGallery.WPF.Renderers;
using Xamarin.Forms.Controls.Issues;
using Xamarin.Forms.Platform.WPF;
using WColor = System.Windows.Media.Color;
[assembly:ExportRenderer(typeof(Issue6693Control), typeof(Issue6693ControlRenderer))]
namespace Xamarin.Forms.ControlGallery.WPF.Renderers
{
public class Issue6693ControlRenderer:ViewRenderer<Issue6693Control,WIssue6693Control>
{
protected override void OnElementChanged(ElementChangedEventArgs<Issue6693Control> e)
{
base.OnElementChanged(e);
SetNativeControl(new WIssue6693Control());
}
}
public class WIssue6693Control : FrameworkElement
{
public WIssue6693Control()
{
}
protected override void OnRender(DrawingContext drawingContext)
{
drawingContext.DrawRectangle(Brushes.LightGray, new Pen(Brushes.Black, 1), new Rect(0,0,ActualWidth, ActualHeight));
var isEnabledText = IsEnabled ? "I'm enabled :)" : "I'm disabled :(";
drawingContext.DrawText(new FormattedText(isEnabledText,
System.Globalization.CultureInfo.CurrentCulture,
System.Windows.FlowDirection.LeftToRight, new Typeface("Arial"), 14, Brushes.Green), new System.Windows.Point(10,10));
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if(e.Property.Name == WIssue6693Control.IsEnabledProperty.Name)
{
InvalidateVisual();
}
}
}
}