This is a migrated thread and some comments may be shown as answers.

Binding Toggle button group IsEnabled to DataTable in WPF

1 Answer 351 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Sohrab
Top achievements
Rank 1
Sohrab asked on 15 Dec 2017, 08:31 AM
I have a datatble with 2 columns:
1. Name
2. IsEnabled
I want to bind each toggle button's IsEnabled to DataTable
for example if a toggle button's content is "Test" and there is row in
datatable with {Test,True}, this radio button's IsEnabled marks as True.

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 19 Dec 2017, 09:05 AM
Hello Sohrab,

You can use the indexers of the table and its rows in XAML. For example:
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("IsEnabled", typeof(bool));
         
dt.Rows.Add("Button 1", true);
dt.Rows.Add("Button 2", false);
 
this.DataContext = dt;

<StackPanel>
    <telerik:RadToggleButton Content="{Binding Rows[0][Name]}" IsEnabled="{Binding Rows[0][IsEnabled]}" />
    <telerik:RadToggleButton Content="{Binding Rows[1][Name]}" IsEnabled="{Binding Rows[1][IsEnabled]}" />
</StackPanel>

I hope that helps.

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Buttons
Asked by
Sohrab
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or