Maximize productivity with
30% off* for a limited time
using BOOSTDEV30.
Includes 3- and 5-packs.
*Some exclusions may apply.New Product LaunchBoldDesk: Help desk ticketing software starts at $10 for 3 agents.
Try it for free.Hi David,
Query: how
to initialize data binding in C#
We have prepared a simple sample to bind the properties of
SfCheckBox in code behind. Please refer the below code.
Code snippet [C#]:
var binding = new Binding() { Source = viewModel, Path = "IsActive", Mode =
BindingMode.TwoWay };
SfCheckBox sfCheckBox = new SfCheckBox(); sfCheckBox.SetBinding(SfCheckBox.IsCheckedProperty, binding); |
Sample - https://www.syncfusion.com/downloads/support/forum/150675/ze/150675-sample-365345168.zip
Please get back to us if you need further assistance on this.
Regards,
Geetha R.
foreach(Model model in viewModel.Data)
{
var binding = new Binding()
{
Source = model,
Path = "IsChecked",
Mode = BindingMode.TwoWay
};
Binding textbinding = new Binding()
{
Source = model,
Path = "Name",
Mode = BindingMode.TwoWay
};
SfCheckBox sfCheckBox = new SfCheckBox();
sfCheckBox.SetBinding(SfCheckBox.TextProperty, textbinding);
sfCheckBox.SetBinding(SfCheckBox.IsCheckedProperty, binding);
layout.Children.Add(sfCheckBox);
} |