Reputation:
I can declare a checkbox in XAML like so
<CheckBox Content="Accepted" Height="71" Name="checkBox" />
When this screen loads I want to check the data associated with the screen and set it if the box is checked, or it its not checked.
public TripDetails()
{
string yesString = "YES";
if (String.ReferenceEquals(meeting.accepted, yesString))
{
// set the checkbox
}
this.DataContext = this;
InitializeComponent();
}
What I cannot understand is how to set the checkbox declared in the XAML from within my cooresponding xaml.cs file.
Could somebody please advise what should go where my // set the checkbox is.
Many Thanks, -Code
Upvotes: 0
Views: 369
Reputation: 22198
Unless I'm missing something...since you've named the CheckBox "checkBox
", it should just be
this.checkBox.IsChecked = !this.checkBox.IsChecked;
Upvotes: 1