Click here to Skip to main content
15,892,059 members
Home / Discussions / WPF
   

WPF

 
QuestionSelectionChanged Event is not firing on View Load in MVVM Pin
Ashfaque Hussain29-Dec-14 20:15
Ashfaque Hussain29-Dec-14 20:15 
QuestionSilverlight? A future? Pin
Sean McPoland26-Dec-14 23:46
Sean McPoland26-Dec-14 23:46 
AnswerRe: Silverlight? A future? Pin
Richard MacCutchan26-Dec-14 23:57
mveRichard MacCutchan26-Dec-14 23:57 
AnswerRe: Silverlight? A future? Pin
Pete O'Hanlon27-Dec-14 2:03
mvePete O'Hanlon27-Dec-14 2:03 
QuestionWhat are those automation peer in WPF? Pin
Super Lloyd22-Dec-14 0:55
Super Lloyd22-Dec-14 0:55 
AnswerRe: What are those automation peer in WPF? Pin
Pete O'Hanlon22-Dec-14 1:32
mvePete O'Hanlon22-Dec-14 1:32 
AnswerRe: What are those automation peer in WPF? Pin
syed shanu23-Dec-14 17:42
professionalsyed shanu23-Dec-14 17:42 
QuestionRouted Event No Responding Pin
Kevin Marois18-Dec-14 9:20
professionalKevin Marois18-Dec-14 9:20 
[UPDATE]
Figured it out. Was binding to the event instead of the Handler
[UPDATE]


I created a user control with this event:

public partial class AssignedEmployeesControl : _BaseUserControl
{
    public static readonly RoutedEvent AssignmentRemovedEvent =
        EventManager.RegisterRoutedEvent("AssignmentRemoved",
        RoutingStrategy.Bubble, typeof(RoutedEventHandler),
        typeof(AssignedEmployeesControl));

    public event RoutedEventHandler AssignmentRemoved
    {
        add { AddHandler(AssignmentRemovedEvent, value); }
        remove { RemoveHandler(AssignmentRemovedEvent, value); }
    }

    protected void OnAssignmentRemoved()
    {
        RaiseEvent(new RoutedEventArgs(AssignmentRemovedEvent));
    }


I then add my control to a DataGrid in another control

<DataGridTemplateColumn Header="Assigned Employees"
                        Width="*">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>

            <vc:AssignedEmployeesControl EngineRef="{Binding 
                                    ElementName=employeeJobAssignmentsView, Path=EngineRef}"
                                    AssignmentShift="{Binding Shift}">

                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="AssignmentRemovedEvent">
                        <i:InvokeCommandAction 
                           Command="{Binding ElementName=employeeJobAssignmentsView, 
                           Path=AssignmentRemovedCommand}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>

            </vc:AssignedEmployeesControl>

        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


I then have a command to catch the event:

private ICommand _AssignmentRemovedCommand;
public ICommand AssignmentRemovedCommand
{
    get
    {
        if (_AssignmentRemovedCommand == null)
            _AssignmentRemovedCommand = new RelayCommand(p =>
                assignmentRemovedExecuted(), p => assignmentRemovedCanExecute());
        return _AssignmentRemovedCommand;
    }
}

private bool assignmentRemovedCanExecute()
{
    return true;
}
private void assignmentRemovedExecuted()
{
}


When I run it, my control calls OnAssignmentRemoved, but the host control's assignmentRemovedExecuted method never fires.

I get no compilation errors or ouput methods. I get no response at all.

Can anyone see what's wrong?

Thanks
If it's not broken, fix it until it is


modified 18-Dec-14 16:01pm.

QuestionBest way to stroke a path with TWO colors? Pin
SledgeHammer0117-Dec-14 11:17
SledgeHammer0117-Dec-14 11:17 
SuggestionRe: Best way to stroke a path with TWO colors? Pin
Matt T Heffron17-Dec-14 11:39
professionalMatt T Heffron17-Dec-14 11:39 
GeneralRe: Best way to stroke a path with TWO colors? Pin
SledgeHammer0117-Dec-14 12:06
SledgeHammer0117-Dec-14 12:06 
QuestionWPF DataGrid Date Format Pin
Kevin Marois17-Dec-14 7:21
professionalKevin Marois17-Dec-14 7:21 
GeneralRe: WPF DataGrid Date Format Pin
PIEBALDconsult17-Dec-14 8:12
mvePIEBALDconsult17-Dec-14 8:12 
GeneralRe: WPF DataGrid Date Format Pin
Kevin Marois17-Dec-14 8:21
professionalKevin Marois17-Dec-14 8:21 
GeneralRe: WPF DataGrid Date Format Pin
Richard MacCutchan17-Dec-14 9:38
mveRichard MacCutchan17-Dec-14 9:38 
GeneralRe: WPF DataGrid Date Format Pin
Kevin Marois17-Dec-14 9:42
professionalKevin Marois17-Dec-14 9:42 
GeneralRe: WPF DataGrid Date Format Pin
Maciej Los17-Dec-14 11:14
mveMaciej Los17-Dec-14 11:14 
GeneralRe: WPF DataGrid Date Format Pin
Kevin Marois17-Dec-14 11:16
professionalKevin Marois17-Dec-14 11:16 
GeneralRe: WPF DataGrid Date Format Pin
Maciej Los17-Dec-14 11:19
mveMaciej Los17-Dec-14 11:19 
AnswerRe: WPF DataGrid Date Format Pin
Pete O'Hanlon17-Dec-14 11:38
mvePete O'Hanlon17-Dec-14 11:38 
GeneralRe: WPF DataGrid Date Format Pin
Kevin Marois17-Dec-14 11:40
professionalKevin Marois17-Dec-14 11:40 
GeneralRe: WPF DataGrid Date Format Pin
Pete O'Hanlon17-Dec-14 11:41
mvePete O'Hanlon17-Dec-14 11:41 
GeneralRe: WPF DataGrid Date Format Pin
Kevin Marois17-Dec-14 11:42
professionalKevin Marois17-Dec-14 11:42 
QuestionWPF Programmatically Adding Control To Grid - Wire Event Pin
Kevin Marois16-Dec-14 13:02
professionalKevin Marois16-Dec-14 13:02 
AnswerRe: WPF Programmatically Adding Control To Grid - Wire Event Pin
Richard MacCutchan16-Dec-14 21:39
mveRichard MacCutchan16-Dec-14 21:39 

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.