Click here to Skip to main content
15,949,686 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Storing Data on Server or Client in SilverLight4 Pin
idreesbadshah14-Feb-12 23:56
idreesbadshah14-Feb-12 23:56 
GeneralRe: Storing Data on Server or Client in SilverLight4 Pin
Pete O'Hanlon15-Feb-12 1:35
mvePete O'Hanlon15-Feb-12 1:35 
GeneralRe: Storing Data on Server or Client in SilverLight4 Pin
idreesbadshah15-Feb-12 2:16
idreesbadshah15-Feb-12 2:16 
GeneralRe: Storing Data on Server or Client in SilverLight4 Pin
Pete O'Hanlon15-Feb-12 2:29
mvePete O'Hanlon15-Feb-12 2:29 
QuestionWPF Handling Events In MVVM Pin
Kevin Marois14-Feb-12 10:44
professionalKevin Marois14-Feb-12 10:44 
AnswerRe: WPF Handling Events In MVVM Pin
SledgeHammer0114-Feb-12 11:02
SledgeHammer0114-Feb-12 11:02 
GeneralRe: WPF Handling Events In MVVM Pin
Kevin Marois14-Feb-12 11:21
professionalKevin Marois14-Feb-12 11:21 
GeneralRe: WPF Handling Events In MVVM Pin
Kevin Marois14-Feb-12 11:53
professionalKevin Marois14-Feb-12 11:53 
Ok, I got most of it, but I still have something wrong.

My XAML:

<Window x:Class="Events.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:entities="clr-namespace:Events"
        xmlns:g="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        Title="MainWindow" Height="350" Width="525">
    
    <Window.Resources>
        <DataTemplate DataType="{x:Type entities:Customer}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding CustomerName}"/>
            </StackPanel>
        </DataTemplate>
    </Window.Resources>
    
    <Grid>

        <ListBox ItemsSource="{Binding Customers}">
            
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="ListBoxItem.MouseDoubleClick">
                    <g:EventToCommand Command="{Binding DoubleClickCommand}" PassEventArgsToCommand="True" />
                </i:EventTrigger>
            </i:Interaction.Triggers>

        </ListBox>

    </Grid>
    
</Window>


and my code behind

using System.Collections.ObjectModel;
using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;

namespace Events
{
    public class MainWindowViewModel : ViewModelBase
    {
        private ObservableCollection<Customer> _Customers = new ObservableCollection<Customer>();
        public ObservableCollection<Customer> Customers
        {
            get { return _Customers; }
            set
            {
                if (_Customers != value)
                {
                    _Customers = value;
                    RaisePropertyChanged("Customers");
                }
            }
        }

        private ICommand _DoubleClickCommand;
        public ICommand DoubleClickCommand
        {
            get
            {
                if (_DoubleClickCommand == null)
                {
                    _DoubleClickCommand = new RelayCommand(doubleClicked);
                }
                return _DoubleClickCommand;
            }
        }

        public MainWindowViewModel()
        {
            Customers.Add(new Customer { Id = 0, CustomerName = "Jack Smith"});
            Customers.Add(new Customer { Id = 1, CustomerName = "Pete Jones" });
            Customers.Add(new Customer { Id = 2, CustomerName = "William Jackson" });
        }

        private void doubleClicked()
        { 
            // Handle the double click
        }
    }
}



The doubleClicked() method is never called.

What am I missing???
Everything makes sense in someone's mind

GeneralRe: WPF Handling Events In MVVM Pin
SledgeHammer0114-Feb-12 11:56
SledgeHammer0114-Feb-12 11:56 
GeneralRe: WPF Handling Events In MVVM Pin
Kevin Marois14-Feb-12 12:01
professionalKevin Marois14-Feb-12 12:01 
GeneralRe: WPF Handling Events In MVVM Pin
SledgeHammer0114-Feb-12 12:05
SledgeHammer0114-Feb-12 12:05 
GeneralRe: WPF Handling Events In MVVM Pin
Kevin Marois14-Feb-12 12:20
professionalKevin Marois14-Feb-12 12:20 
AnswerRe: WPF Handling Events In MVVM Pin
Wes Aday14-Feb-12 11:40
professionalWes Aday14-Feb-12 11:40 
GeneralRe: WPF Handling Events In MVVM Pin
Kevin Marois14-Feb-12 11:49
professionalKevin Marois14-Feb-12 11:49 
GeneralRe: WPF Handling Events In MVVM Pin
Wes Aday14-Feb-12 11:57
professionalWes Aday14-Feb-12 11:57 
AnswerRe: WPF Handling Events In MVVM Pin
El_Codero15-Feb-12 12:34
El_Codero15-Feb-12 12:34 
QuestionWPF ListBox As Hyperlinks Pin
Kevin Marois13-Feb-12 15:30
professionalKevin Marois13-Feb-12 15:30 
AnswerRe: WPF ListBox As Hyperlinks Pin
Abhinav S13-Feb-12 19:53
Abhinav S13-Feb-12 19:53 
QuestionDrag two columns in Datagrid Pin
Defender-NF12-Feb-12 22:49
Defender-NF12-Feb-12 22:49 
QuestionWPF Binding Tree Node Expanded Pin
Kevin Marois12-Feb-12 7:31
professionalKevin Marois12-Feb-12 7:31 
AnswerRe: WPF Binding Tree Node Expanded Pin
SledgeHammer0112-Feb-12 10:21
SledgeHammer0112-Feb-12 10:21 
GeneralRe: WPF Binding Tree Node Expanded Pin
Kevin Marois13-Feb-12 15:30
professionalKevin Marois13-Feb-12 15:30 
QuestionHow can I find out that a UserControl is Rendered ? Pin
rdinca9-Feb-12 19:21
rdinca9-Feb-12 19:21 
AnswerRe: How can I find out that a UserControl is Rendered ? Pin
Abhinav S9-Feb-12 20:27
Abhinav S9-Feb-12 20:27 
GeneralRe: How can I find out that a UserControl is Rendered ? Pin
rdinca9-Feb-12 20:40
rdinca9-Feb-12 20:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.