My UserControl code looks like below:
public partial class TriggerListAdd : UserControl
{
public TriggerListAdd()
{
//GetOutputFromInput = (s) => { return s + " " + s; };
Rows = new ObservableCollection<Row>();
Rows.CollectionChanged += RowCollectionChanged;
LoadRows();
InitializeComponent();
}
// ....
public DependencyProperty GetOutputFromInputProperty = DependencyProperty.Register("GetOutputFromInput", typeof(Func<string, string>), typeof(TriggerListAdd));
public Func<string, string> GetOutputFromInput { get; set; }
// ....
}
What I try to achieve is something like:
public MainWindow()
{
TriggerListAddControl.GetOutputFromInput = GetOutputFromInputDefinition;
InitializeComponent();
}
or
<customControl:TriggerListAdd x:Name="TriggerListAddControl" Margin="10,10,10,10" GetOutputFromInput="GetOutputFromInputDefinition"/>
where GetOutputFromInputDefinition
is a delegate defined in parent window.
Second method compiles but throw exception after running and first method says TriggerListAddControl
is not an object.
Do you know how can I define and pass some delegate to user control from parent window?
Commented line in user control's constructor is doing the same but I like to pass it from the parent which have references to some external service that will be called there.