If I write the event handler like this:
CheckBox whatever = FindViewById<CheckBox> (Resource.Id.checkBox1);
whatever.Click += (s, e) =>
{
if (!whatever.Checked)
{
//do stuff
}
}
an exception is thrown when the handler is called. If I create another CheckBox object for the same view with a different name- like this:
CheckBox whatever = FindViewById<CheckBox> (Resource.Id.checkBox1);
whatever.Click += (s, e) =>
{
CheckBox whatever2 = FindViewById<CheckBox> (Resource.Id.CheckBox1);
if (!whatever2.Checked)
{
//do stuff
}
}
there are no issues. Why is the duplicate object required?
In what method you assign the whatever control?
I always declare my controls inside OnResume event.