Remove binding to FrameworkElementFactory
- by Damien
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
};