Click here to Skip to main content
15,888,351 members
Home / Discussions / WPF
   

WPF

 
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 
I created a UserControl with an event:

public partial class AssignedEmployeesControl : _BaseUserControl
{
    public event RoutedEventHandler AssignmentRemoved;
}


then I add the control to a data grid in the code behind:

private void addAssignedEmployeesColumn()
{
    // Assigned Employees Column
    DataGridTemplateColumn employeesColumn = new DataGridTemplateColumn();
    employeesColumn.Header = "Assigned Employees";
    employeesColumn.Width = new DataGridLength(1, DataGridLengthUnitType.Star); ;


    FrameworkElementFactory factory = new FrameworkElementFactory(typeof(AssignedEmployeesControl));

    factory.SetValue(AssignedEmployeesControl.EngineRefProperty, EngineRef);
    factory.SetValue(AssignedEmployeesControl.AssignmentShiftProperty, new Binding("Shift"));

    factory.AddHandler(AssignedEmployeesControl.AssignmentRemoved, new RoutedEventHandler(AssignmentRemoved));

    DataTemplate cellTemplate = new DataTemplate();
    cellTemplate.VisualTree = factory;

    employeesColumn.CellTemplate = cellTemplate;

    assignmentsGrid.Columns.Add(employeesColumn);
}


I want to handle the event as follows

private void AssignmentRemoved(object sender, RoutedEventArgs e)
{
}


The AddHandler line doesn't compile. I get

Argument 1: cannot convert from 'System.Windows.RoutedEventHandler' to 'System.Windows.RoutedEvent'	

The best overloaded method match for 'System.Windows.FrameworkElementFactory.AddHandler(System.Windows.RoutedEvent, System.Delegate)' has some invalid arguments

The event 'FMG.UI.WPF.Shared.Views.Controls.AssignedEmployeesControl.AssignmentRemoved' can only appear on the left hand side of += or -= (except when used from within the type 'FMG.UI.WPF.Shared.Views.Controls.AssignedEmployeesControl')


I don't understand what's going on here. What's the right way to wire up my event?

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

AnswerRe: WPF Programmatically Adding Control To Grid - Wire Event Pin
Richard MacCutchan16-Dec-14 21:39
mveRichard MacCutchan16-Dec-14 21:39 
GeneralRe: WPF Programmatically Adding Control To Grid - Wire Event Pin
Kevin Marois17-Dec-14 5:49
professionalKevin Marois17-Dec-14 5:49 
GeneralRe: WPF Programmatically Adding Control To Grid - Wire Event Pin
Richard MacCutchan17-Dec-14 6:26
mveRichard MacCutchan17-Dec-14 6:26 
GeneralRe: WPF Programmatically Adding Control To Grid - Wire Event Pin
Kevin Marois17-Dec-14 6:29
professionalKevin Marois17-Dec-14 6:29 
QuestionLinearGradientBrush issue Pin
SledgeHammer0115-Dec-14 7:37
SledgeHammer0115-Dec-14 7:37 
AnswerRe: LinearGradientBrush issue Pin
Mycroft Holmes16-Dec-14 13:55
professionalMycroft Holmes16-Dec-14 13:55 
QuestionUnable to Load viewmodel onto xamoutlookbar(Silverlight). Pin
micromortu11-Dec-14 9:34
micromortu11-Dec-14 9:34 
QuestionHide Controls In Assembly Pin
Kevin Marois10-Dec-14 15:41
professionalKevin Marois10-Dec-14 15:41 
QuestionUnable to modify and add records in Lightswitch Editable Grid Pin
sumB8-Dec-14 22:55
sumB8-Dec-14 22:55 
QuestionWPF DataGrid Add DataGridTemplateColumn At RunTime Pin
Kevin Marois26-Nov-14 13:02
professionalKevin Marois26-Nov-14 13:02 
AnswerRe: WPF DataGrid Add DataGridTemplateColumn At RunTime Pin
ferragus26-Nov-14 16:54
professionalferragus26-Nov-14 16:54 
Question"Smoothing" out a PolyLine? Pin
SledgeHammer0120-Nov-14 10:17
SledgeHammer0120-Nov-14 10:17 
AnswerRe: "Smoothing" out a PolyLine? Pin
den2k8820-Nov-14 10:37
professionalden2k8820-Nov-14 10:37 
GeneralRe: "Smoothing" out a PolyLine? Pin
SledgeHammer0120-Nov-14 11:01
SledgeHammer0120-Nov-14 11:01 
GeneralRe: "Smoothing" out a PolyLine? Pin
den2k8820-Nov-14 11:07
professionalden2k8820-Nov-14 11:07 
GeneralRe: "Smoothing" out a PolyLine? Pin
SledgeHammer0120-Nov-14 11:50
SledgeHammer0120-Nov-14 11:50 
QuestionTreeView Children Loading Indicator Pin
cjb11019-Nov-14 23:27
cjb11019-Nov-14 23:27 

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.