Rand Random
Rand Random

Reputation: 7440

WPF intercept Binding Updates

I would like to know if there is a mechanism to intercept all Bindings, so that I can suppress the updating on a specific condition?

Pseudo Code:

public class Utils
{
    public void RegisterInterceptionOfBinding()
    {
        WpfBindingMechanism.OnSourceUpdating += SourceUpdating;
        WpfBindingMechanism.OnTargetUpdating += TargetUpdating;
    }

    private void SourceUpdating(object sender, SourceUpdatingEventArgs args)
    {
        if (DoSomeMagicConditionChecking)
        {
            args.Cancel = true;
        }
    }

    private void TargetUpdating(object sender, SourceUpdatingEventArgs args)
    {
        if (DoSomeMagicConditionChecking)
        {
            args.Cancel = true;
        }
    }
}

I am searching for a mechanism that works on ALL Bindings in the entire WPF Application.

Upvotes: 4

Views: 326

Answers (1)

TomSlick
TomSlick

Reputation: 735

You might be looking to use the TypeDescriptionProvider class.

Here is a forum post on MSDN that might answer your question:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/d8046807-ac1a-4d1f-81f2-6a2f93dab78a/intercept-binding-mechanism

Upvotes: 1

Related Questions