views:

12

answers:

1

I need Button.click from another class but doesn't work pickButton.PerformClick()?

[Category("Özel")]
[DefaultValue(null)]
public Button pickButton { get; set; }


protected override void OnKeyUp(KeyEventArgs e)
{
    base.OnKeyUp(e);
    if (e.Key == Key.F10)
    {
        if (pickButton != null)
        {
            //pickButton.PerformClick() ??
        }
    }
}
+1  A: 

PerformClick isn't available in Silverlight.

Why don't you extract the code from the pickButton click event and call that from both places:

protected override void OnKeyUp(KeyEventArgs e)
{
    base.OnKeyUp(e);
    if (e.Key == Key.F10)
    {
        if (pickButton != null)
        {
            DoStuff();
        }
    }
}

and:

private void pickButton_OnClick(object sender, RoutedEventArgs e)
{
    DoStuff();
}

Obviously DoStuff() is a placeholder to illustrate the concept.

ChrisF