TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manoharan
NA
280
13.8k
How to select the individual image and then click the button
Sep 17 2014 3:07 AM
Hi,
How to select the individual image and then click the button,need to send the selected image value?
Each rectangle inside i added image control.when click the submit button,send the image value ,which image i select.How to select the image.Here image selection is not working.please help me.(wpf using mvvm)
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
}
Reply
Answers (
0
)
How to close the popup window using mvvm in wpf?
How to play 4k video in mediaelement wpf