How to send the selected image value when i click the button in wpf using MVVM?

Posted by Vpmanoharan under WPF on 9/17/2014 | Points: 10 | Views : 1204 | Status : [Member] | Replies : 0
Hi,

I created Each rectangle with image control.I cannot able to select the image.How to select the image and send the image value,when i click button(after select image).Please help me.


SampleView.xaml:

<UserControl x:Class="GameDealModule.View.SampleView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="1241" >

<Grid Background="Gray" HorizontalAlignment="Center" VerticalAlignment="Center">
<Canvas HorizontalAlignment="Left" Height="600" Margin="29,10,0,0" VerticalAlignment="Top" Width="1241">

<Rectangle Height="209" Width="150" Canvas.Left="41" Stroke="Black" Canvas.Top="21"></Rectangle>

<Image Height="209" Width="150" Source="../Images/nature.png" Canvas.Left="41" Canvas.Top="21"></Image>



<Rectangle Height="209" Width="150" Canvas.Left="206" Stroke="Black" Canvas.Top="21" ></Rectangle>

<Image Height="209" Width="150" Source="../Images/flower.png" Canvas.Left="206" Canvas.Top="21"></Image>


<Button Content="Submit" Canvas.Left="372" Canvas.Top="533" Width="103" Height="37" Command="{Binding SubmitCommand}"/>
<Button Content="Close" Canvas.Left="489" Canvas.Top="533" Width="103" Height="37" Command="{Binding CloseCommand}"/>

</Canvas>
</Grid>
</UserControl>

SampleView.xaml.cs:
public partial class SampleView: UserControl
{
public SampleView()
{
InitializeComponent();
this.DataContext = new SampleViewModel();
}
}

SampleViewModel.cs:
public class SampleViewModel: INotifyPropertyChanged
{
public SampleViewModel()
{

this.SubmitCommand = new DelegateCommand<object>(this.OnSubmit, this.CanSubmit);

}
private bool CanSubmit(object arg)
{
return true;
}


private void OnSubmit(object arg)
{
string selectedimage="";

}
public ICommand SubmitCommand { get; private set; }


#region INotifyPropertyChanged Members

public event PropertyChangedEventHandler PropertyChanged;

private void NotifyPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}

#endregion
}




Responses

(No response found.)

Login to post response