Say I have the following code:
ContentControl c = new ContentControl();
c.SetBinding (ContentControl.Content, new Binding());
c.DataContext = "Test";
object test = c.Content;
At this point, c.Content will return null.
Is there a way to force the evaluation of the binding so that c.Content return “Test”?
Only one message can execute at a time on the UI thread, which is where this code is running. Data-binding happens at a specific priority in separate messages, so you’ll need to ensure that this code:
runs after those data binding messages are executed. You can do this by queuing a separate message with the same level of priority (or lower) as data binding: