Skip to content

Conversation

@anaisbetts
Copy link
Member

The main impetus for this PR is something like this:

this.OneWayBind(ViewModel, x => x.SomeModel.Text, x => x.SomeTextBox.Text);

The existing code will always attempt to set SomeTextBox.Text to null on startup because ViewModel is initially null in the View constructor, which WinRT will subsequently die on. This is because OneWayBind uses BindTo internally, which has the same bug.

However, when I dug into it, I realized BindTo was missing all kinds of things, and should have the same features. So let's do that

TODO:

  • - Write a test to simulate the WinRT failure, then verify it's fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems weird. Why not IObservable<TVProp> source; It doesn't require setting a default if all branches of the subsequent if statement set it before it's accessed, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying a new style, where I just use var everywhere. Bart De Smet taught me that one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, ok. Interesting. That crazy Bart character.

@haacked
Copy link
Contributor

haacked commented Mar 4, 2013

I'm not going to pretend I understand all of this. :) Perhaps my only comment is I really do think the public methods should validate the parameters passed in. NullReferenceException doesn't carry much information when someone accidentally calls the method wrong either directly or indirectly.

@anaisbetts
Copy link
Member Author

@haacked Yeah, you're probably right. Let's jump off that bridge later though :)

anaisbetts pushed a commit that referenced this pull request Mar 4, 2013
Rewrite BindTo to support Type Conversion and Binding Hooks
@anaisbetts anaisbetts merged commit 3292571 into master Mar 4, 2013
@anaisbetts anaisbetts deleted the rewrite-bindto branch March 4, 2013 22:41
@lock lock bot locked and limited conversation to collaborators Jun 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants