Remove binding to FrameworkElementFactory

Posted by Damien on Stack Overflow See other posts from Stack Overflow or by Damien
Published on 2010-05-31T02:55:20Z Indexed on 2010/05/31 3:02 UTC
Read the original article Hit count: 280

Filed under:

I am currently creating a datatemplate to display data in a listview control in a specific manner and bound to the data. This works fine. But I need to be able to remove the bindings when the screen is closed and control is being disposed. How can I do this?

I am thinking of just passing null as the second parameter of SetBinding and not sure if this will fix the issue. Also I have tried BindingOperation.ClearBindings, but I have a FrameworkElementFactory object and not a DependancyObject. Any help would be appricaited.

//Create a Element Factory object to save the elements that make 
//up the DataTemplate 
cellTemplateFactory = new FrameworkElementFactory(typeof(TextBlock));

//Set the binding to the text property of the textblock element
var binding = new Binding(dispColumn.BindingField)
{
    TargetNullValue = string.Empty,
    Mode = BindingMode.OneTime
};

© Stack Overflow or respective owner

Related posts about wpf-binding