summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2659.xaml.cs
blob: b7fa774fec32d802157e47059dc176f3f556bf73 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;

using Xamarin.Forms;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

namespace Xamarin.Forms.Controls
{
#if APP
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 2659, "", PlatformAffected.Android | PlatformAffected.iOS)]
	public partial class Issue2659 : ContentPage
	{
		public Issue2659 ()
		{
			try {
			InitializeComponent ();
			}catch (Exception e){
				System.Diagnostics.Debug.WriteLine (e.Message);
			}
		}

		internal void OnSetStyleButtonClicked(object sender, EventArgs args)
		{
			Style style = (Style)Resources["buttonStyle"];
			SetButtonStyle(style);
		}

		internal void OnUnsetStyleButtonClicked(object sender, EventArgs args)
		{
			SetButtonStyle (null);
		}

		internal void OnSetLocalButtonClicked(object sender, EventArgs args)
		{
			EnumerateButtons ((Button button) => {
				button.TextColor = Color.Red;
				button.FontAttributes = FontAttributes.Bold;
			});
		}

		internal void OnClearLocalButtonClicked(object sender, EventArgs args)
		{
			EnumerateButtons ((Button button) => {
				button.ClearValue (Button.TextColorProperty);
				button.ClearValue (Button.FontAttributesProperty);
			});
		}

		void SetButtonStyle(Style style)
		{
			EnumerateButtons (button => {
				button.Style = style;
			});
		}

		void EnumerateButtons(Action<Button> action)
		{
			foreach (View view in stackLayout.Children)
				action ((Button)view);
		}
	}
#endif
}