Can anyone tell me what is the c# equivalent of the following snippet of XAML ??
<my:DataGridTextColumn
Visibility="{Binding Path=DataColumns[21].IsVisible, Source={StaticResource viewmodel}, Converter={StaticResource vc}}"
Binding="{Binding SdDevDuration}"
/>
Its the visibility binding I cannot get right. DataGridTextColumn is not a FrameworkElement so no SetBinding method.
Thanks in advance,
Matt
I worked this out. For anyone who's interested you can use the BindingOperation.SetBinding method.
The full code is,
var newCol = new DataGridTextColumn();
newCol.Binding = new Binding("SdDevDuration");
var visiblityBinding = new Binding("IsVisible");
visiblityBinding.Source = col;
visiblityBinding.Converter = new VisibilityConverter();
BindingOperations.SetBinding(newCol, DataGridTextColumn.VisibilityProperty, visiblityBinding);
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