<p>I'm missing the boat on something here, kids.  This keeps rearing its head and I don't know what's going on with it, so I hope my homeys here can help.</p>

<p>When working in Silverlight, when I create bindings in my c# code, they never hold up when the application is running.  The declarative bindings from my xaml seem ok, but I'm doing something wrong when I create my bindings in C#.  I'm hoping that there is something blindingly obvious I'm missing.  Here's a typical binding that gets crushed:</p>

<pre><code>TextBlock tb = new TextBlock();
Binding b = new Binding("FontSize");
b.Source = this;
tb.SetBinding(TextBlock.FontSizeProperty, b);
</code></pre>

[{'answer_id': 72129, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>I\'ve just tried the exact code you just posted and it worked fine, with some changes. I believe the problem is the element you are using for the SetBinding call is not the textblock you want to bind. It should be:</p>\n\n<pre><code>TextBlock tb = new TextBlock();\nBinding b = new Binding("FontSize");\nb.Source = this;\ntb.SetBinding(TextBlock.FontSizeProperty, b);\n</code></pre>\n\n<p>Make sure you also have a FontSize public property of type double on "this". If "this" is a user control, I would recommend renaming the property so you don\'t hide the inherited member.</p>\n'}, {'answer_id': 2186878, 'author': 'MojoFilter', 'author_id': 93, 'author_profile': 'https://Stackoverflow.com/users/93', 'pm_score': 3, 'selected': True, 'text': "<p>It looks like as of Silverlight 3.1, at least, this is no longer an issue.  I can't reproduce it, at any rate.</p>\n"}]
['https://Stackoverflow.com/questions/71932', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/93/']