ccbVT wrote:
and this would be in my View Model class
public Product Product{ get; set; }
How I have it right now I don't seem to have a DataContext on the textbox(I do have it in my layOutRoot)). What I did was like in the video. I opened blend up and dragged my VieModelLocator onto the layoutroot and then I dragged the property from the product class onto a textbox I made.
Is your Product class a ViewModel? If so, it should derive from ViewModelBase.I was thinking it was the Domain class. I am trying to go through the MIX11 video and I would think that my Product class would be my Domain class like the Friend Class is in the video.
Then, your Name setter should look something like:If your textbox's Text property is bound to the Name property, the textbox should update when the Name property changes.set { if (Name == value) { return; } Name = value; RaisePropertyChanged(() => Name); }
Could you give more details?
- How have you set the DataContext for the textbox?
- What happens when the button is clicked?
and this would be in my View Model class
public Product Product{ get; set; }
How I have it right now I don't seem to have a DataContext on the textbox(I do have it in my layOutRoot)). What I did was like in the video. I opened blend up and dragged my VieModelLocator onto the layoutroot and then I dragged the property from the product class onto a textbox I made.
<TextBox Text="{Binding Product.Name, Mode=TwoWay}" Margin="257,211,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="80"/>
When I click the button I made a relay command that I grabbed off in some old book I had public RelayCommand AddAVendorCommand
{
get;
private set;
}
AddAVendorCommand = new RelayCommand(() => AddVendor()); // in constructor of ViewModel
Right now it just goes to the AddVendor method and I have a break point to see if what I put in the textbox show sup in the Product object.