Extending TextBox throws RPC_E_WRONG_THREAD exception

0

I'm creating a DelayedTextbox. I did this by extending the TextBox and adding dependency properties (thanks to help on another question)

So I have a cs file that looks like this:

public class DelayedTextBox : TextBox
{
   public int Delay
    {
        get
        {
            return (int)GetValue(DelayProperty);
        }
        set
        {
            SetValue(DelayProperty, value);
        }
    }

    public static readonly DependencyProperty DelayProperty =
        DependencyProperty.Register(
            "Delay",
            typeof(int),
            typeof(DelayedTextBox),
            new PropertyMetadata(300));
}

Then in my xaml file I attempt to use the new control:

<h:DelayedTextBox Delay="300" />

Where Delay is one of the dependency properties.

When I run the code though, the first time DelayedTextBox.cs tries to access Delay it throws the following error:

System.Exception: 'The application called an interface that was marshalled for >a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))'

How can I properly extend the Textbox with my custom control?

xaml
uwp
uwp-xaml
asked on Stack Overflow Mar 10, 2018 by JT Smith • edited Mar 10, 2018 by JT Smith

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0