-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomRendererFull.Example.snippet
More file actions
51 lines (48 loc) · 1.73 KB
/
CustomRendererFull.Example.snippet
File metadata and controls
51 lines (48 loc) · 1.73 KB
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
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>CustomRendererFull.Example</Title>
<Author>DESKTOP-7I0PTHF</Author>
<Description />
<HelpUrl></HelpUrl>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Keywords>
<Keyword></Keyword>
</Keywords>
<Shortcut />
</Header>
<Snippet>
<References />
<Imports />
<Declarations />
<Code Language="CSharp" Kind="method body" Delimiter="$"><![CDATA[[assembly: ExportRenderer(typeof(SketchView /* forms element */), typeof(SketchViewRenderer /* forms renderer */))]
namespace XFDraw.Droid
{
class SketchViewRenderer : ViewRenderer<SketchView /* forms element */, PaintView /* native control */>
{
protected override void OnElementChanged(ElementChangedEventArgs<SketchView> e)
{
base.OnElementChanged(e);
if (Control == null) // better check here
{
var paintView = new PaintView(Forms.Context);
paintView.SetInkColor(Element.InkColor.ToAndroid());
SetNativeControl(paintView);
}
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == SketchView.InkColorProperty.PropertyName) // only if bindable property is changed
{
Control.SetInkColor(Element.InkColor.ToAndroid()); // do native change
}
}
}
}]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>