views:

134

answers:

1

We are using MVVM and want nothing in the View's C# file. We have a designer on staff, and don't want to teach them how to write C#.

We have a Textbox that has text inside of it. It seems necessary to have the OnTextChangedEvent be inside of our VM. (We are binding the text to a string in the VM but it isn't doing everything that we need it to do).

Basically we'd like to take this code and get rid of the codebehind by binding to the OnTextChangedCommand (or something) in our VM:

This is what we have:

    <TextBox 
    x:Name="MyTextBox"
    Text="{Binding Path=SomeVariable, Mode=TwoWay}"/>

And in the c# code-behind

MyTextBox.TextChanged += vm.OnTextChanged;

This is what we want:

    <TextBox 
    x:Name="MyTextBox"
    Text="{Binding Path=SomeVariable, Mode=TwoWay}"
    TextChanged="{Binding OnTextChanged}"/>

and nothing in the c# code-behind

A: 

You would need UpdateSourceTrigger capability (which is not available in Silverlight 2).

Check out this article about the work around if you are using SL 2.

markti
that's what it felt like the answer would be. Thanks!
thepaulpage
According to the article you link, the "UpdateSourceTrigger" is available in Silverlight 3. Is this not the case?
Richard B

related questions