DISQUS

DISQUS Hello! fortes.com is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Jump to original thread »
Author

BindableRun

Started by Fortes · 11 months ago

A useful feature that was left out of the first version of WPF is the ability to databind the value of Run.Text. I was still around when this feature was (unfortunately) cut — but don’t despair! It’s not actually that hard to write yourself.
We’ll do this by c ... Continue reading »

11 comments

  • So how come it was cut, given it's quite straightforward? I've ended up having writing this thing (well, something very like it) a couple of times now on real projects, and it's always perplexed me that it didn't work like this out of the box.

    Given that so many of the properties are DPs on most elements, it seems almost perverse that an exception was made in this case.
  • You know how it is in software, trade-offs have to be made. In this case it was the test cost (lots of tricky cases when you bring in databinding). Given how easy it is to implement, we chose to cut this in order to gain other (harder for a developer to add, but easier to test) features.
  • I had the same thoughts as Ian when I read this post. I wrote a similar class earlier this year. It seems so simple, that's what makes you wonder why it's not in the framework.
  • Your post has helped me on the way to solving a rather knotty problem. I have tried to implement two-way binding with no success using FrameworkPropertyMetadataOptions.BindsTwoWayByDefault when registering the BoundTextProperty. Any ideas? Thanks so much.
  • Hey Robert,
    Can you please share a reduced repro of your sample? Setting BindsTwoWayByDefault to true when registering the DP should be enough to make that DP two way data bound by default. I'm not aware of any gotchas or bugs in this scenario.
    Thanks!
    Bea
  • Great! I've been looking for something like that. Thanks for the tip!

    Laurent
  • Bea,
    Thanks so much for your comment and for your wonderful, indispensable blog.

    Two way binding does work as expected. When I set the BoundText procedurally, all was well.

    The problem was that I had placed the BindableRun in a Paragraph in a FlowDocument in a RichTextBox, thinking that, magically, the BindableRun would receive text input from the RichTextBox. I just have to figure out how to route the input.
  • I get this error "{"Collection was modified; enumeration operation may not execute."}" when i use the BindableRun element more than once in my flow document - if i use only use it keeps quiet - any clues. ???
  • I have the same question as Robert Zurer. Anyone have a sample of working 2-way binding example? Each of my BindableRun tags is in a Paragraph. I'm styling a ListBox like this:


















    Looks great and binds great, but none of the changes make it back to the Binding Source.

    Thanks.
  • I think we have a solution to the "Collection was modified" issue:

    http://code.logos.com/blog/2008/01/data_binding...
  • Thanks for sharing the BindableRun.

    Is there anyone who created a two-way binding successfully?

Add New Comment

Comments are closed for this post.
Returning? Login