Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
604
Binding field.Visibility in Code-Behind
posted

How can I bind field.Visibility property to the data in my business object, and do it in code-behind?

This blog

http://blogs.infragistics.com/blogs/josh_smith/archive/2008/06/06/binding-a-xamdatagrid-field-property.aspx

explains how to acheive it in xaml, but i'm looking for a way to implement the binding in code-behind.

  • 9836
    Verified Answer
    posted

    Hello,

    You can try to use the BindingOperations.SetBinding method in codebehind e.g.

    Field firstField = xamDataGrid1.FieldLayouts[0].Fields[0];

    Binding bin = new Binding();
    bin.Converter = new BooleanToVisibilityConverter();
    bin.Source = viewmodel;
    bin.Path = new PropertyPath("IsVisible");

    BindingOperations.SetBinding(firstField, Field.VisibilityProperty, bin);

    I hope this helps

    Vlad