Skip to content

Commit 5ffa2ce

Browse files
committed
StatefulStackLayout implementation for XF UWP
1 parent 6eadc90 commit 5ffa2ce

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Plugin.InputKit.Platforms.UWP;
2+
using Plugin.InputKit.Shared.Layouts;
3+
using Windows.UI.Xaml.Controls;
4+
using Xamarin.Forms;
5+
using Xamarin.Forms.Platform.UWP;
6+
7+
[assembly: ExportRenderer(typeof(StatefulStackLayout), typeof(StatefulStackLayoutRenderer))]
8+
namespace Plugin.InputKit.Platforms.UWP
9+
{
10+
public class StatefulStackLayoutRenderer : VisualElementRenderer<StackLayout, StackPanel>
11+
{
12+
protected override void OnElementChanged(ElementChangedEventArgs<StackLayout> e)
13+
{
14+
base.OnElementChanged(e);
15+
if (Control != null)
16+
{
17+
Control.PointerPressed += Control_PointerPressed;
18+
Control.PointerReleased += Control_PointerReleased;
19+
}
20+
}
21+
22+
private void Control_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
23+
{
24+
VisualStateManager.GoToState(Element, "Pressed");
25+
}
26+
27+
private void Control_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
28+
{
29+
VisualStateManager.GoToState(Element, "Normal");
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)