none
How to convert from XAML binding to C#?

    Question

  • How would I convert this binding in C#?

    LabelsVisibility="{Binding Source={x:Reference ceShowPointsLabels}, Path=IsChecked}"

    Thursday, March 8, 2018 10:40 PM

Answers

  • Hi,

    Generally, bind in code behind like following code.

    Binding binding = new Binding("IsChecked");
    binding.Source = ceShowPointsLabels;
    BindingOperations.SetBinding(yourControl, YourControl.LabelsVisibilityProperty, binding);
    
    

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ttaylor29 Friday, March 9, 2018 6:02 PM
    Friday, March 9, 2018 1:45 AM
    Moderator

All replies

  • Hi,

    Generally, bind in code behind like following code.

    Binding binding = new Binding("IsChecked");
    binding.Source = ceShowPointsLabels;
    BindingOperations.SetBinding(yourControl, YourControl.LabelsVisibilityProperty, binding);
    
    

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by ttaylor29 Friday, March 9, 2018 6:02 PM
    Friday, March 9, 2018 1:45 AM
    Moderator
  • Thank you! This is what I needed.
    Friday, March 9, 2018 6:02 PM