I have a style that I have to create in code-behind. It has a checkbox that looks like this..
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding Path=DataItem.IsChecked}"
>
</CheckBox>
How do I replicate this in code-behind?
Something like this:
CheckBox myCheckBox = new CheckBox();
myCheckBox.HorizontalAlignment = HorizontalAlignment.Center;
myCheckBox.VerticalAlignment = VerticalAlignment.Center;
myCheckBox.SetBinding(ToggleButton.IsCheckedProperty, "DataItem.IsChecked");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With