I have a check box in my MainPage.xaml file setup like this:
<CheckBox x:Name="chkVwAll" Color="Black"/>
What I'm looking to do is use its properties (preferably the IsChecked property), in a sub-method I have in the MainPage.xaml.cs file and the code I have for that sub-method so far is this:
public static DataTable GetPasswrds()
{
DataTable pTbl = new DataTable();
using (SqlConnection c = new SqlConnection(App.ConnStr))
{
string query, tmp;
query = tmp = "";
if (chkVwAll.IsChecked == true)
{
// Will enter code here
}
}
return pTbl;
}
Before I even rebuild and run, I'm getting an error message that says:
An object reference is required for the non-static field, method, or property 'MainPage.chkVwAll'
Is there a way to fix all of this so It will read it properly and it will gain access to the checkbox and its properties?
that . When I type chkVwAll I get a red underline under that, so I know it can't find it. If this can be fixed through binding, how do I bind it so it can be seen? Or is there an easier way to fix this?