Does anyone have any idea on how I could pass data from my view to my view model?
I took a look at the Mediator but I got no clue on how to implement it and also I haven't got the slightest clue on most of the examples given on the web...
I am trying to open a file dialog box and upon textchanged, it would automatically display an image. This is simple to do with direct events but it is so much complicated using MVVM... Below are my failed attempt...
Hotel.Model
|
Hotel.EntryViewModel
namespace Hotel.ViewModel.ViewModels
{
public class EntryViewModel : BaseViewModel
{
private readonly MainModel model;
private RelayCommand imageCommand;
public EntryViewModel()
{
model = new MainModel();
}
public void GetImage()
{
/*
* Problem lies here...
* How do I get the selected file path based on the textbox in my view
* How do I get the name of the Image Control created in my view
*/
model.ConvertImageData(entryFilePath, entryImage);
}
public ICommand OpenImageCommand
{
get
{
if (imageCommand == null)
{
imageCommand = new RelayCommand(param => GetImage());
}
return imageCommand;
}
}
}
}
View
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
Any response or help would be helpful and much appreciated as I am currently stuck here... It seems so much difficult to implement this MVVM...
Thank you for your time.
Martin CookPosted Feb 10, 2010, 7:57 AM
You can use an event trigger to begin a storyboard to fade in the image when the TextChanged routed event occurs, like so: -
Hope this helps.
Cheers,
Martin