summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT.Tablet/FormsListViewItemPresenter.cs
blob: 1e308867abffc0a06fade992b421c768ddfb21bf (plain)
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
´╗┐using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;

namespace Xamarin.Forms.Platform.WinRT
{
	// This exists to work around the fact that when you set these bindings in XAML and compile on Win10
	// the resulting xbf file does not load correctly on Win8.1. MS has acknowledged the issue but has no fixed it.
	// This hacks around the problem.
	public class FormsListViewItemPresenter : ListViewItemPresenter
	{
		public FormsListViewItemPresenter()
		{
			var verticalContentAlignBinding = new Windows.UI.Xaml.Data.Binding
			{
				Path = new PropertyPath("VerticalContentAlignment"),
				RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent }
			};
			BindingOperations.SetBinding(this, VerticalContentAlignmentProperty, verticalContentAlignBinding);

			var paddingBinding = new Windows.UI.Xaml.Data.Binding
			{
				Path = new PropertyPath("Padding"),
				RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent }
			};
			BindingOperations.SetBinding(this, PaddingProperty, paddingBinding);

			var contentTransitionBinding = new Windows.UI.Xaml.Data.Binding
			{
				Path = new PropertyPath("ContentTransitions"),
				RelativeSource = new RelativeSource { Mode = RelativeSourceMode.TemplatedParent }
			};
			BindingOperations.SetBinding(this, ContentTransitionsProperty, contentTransitionBinding);
		}
	}
}