summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1742.cs
blob: d46bee5efa2a25a96c5bdc860fc279432d21c382 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

namespace Xamarin.Forms.Controls
{
	[Preserve (AllMembers=true)]
	[Issue (IssueTracker.Github, 1742, "Invisible Button still fires Clicked event", PlatformAffected.WinPhone)]
	public class Issue1742 : ContentPage
	{
		public Issue1742 ()
		{
			 var listView = new ListView
            {
                RowHeight = 40
            };
            var invisibleButton = new Button
            {
                IsVisible = false,
                Text = "INVISIBLE button"
            };
            var visibleButton = new Button
            {
                IsVisible = true,
                Text = "Visible button"
            };

            invisibleButton.Clicked += Button_Clicked;
            visibleButton.Clicked += Button_Clicked;
            listView.ItemTapped += ListView_ItemTapped;

            listView.ItemsSource = new string[] { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = { listView, visibleButton, invisibleButton }
			};

		}

		void ListView_ItemTapped(object sender, ItemTappedEventArgs args)
        {
            DisplayAlert("Alert", "List item tapped", "OK", "Cancel");
        }

		void Button_Clicked(object sender, EventArgs args)
        {
            DisplayAlert("Alert", ((Button)sender).Text + " clicked", "OK", "Cancel");
        }
	}
}