Hi, I'm wondering what the equivalence of an invoke is when working with any WPF control vs Windows.Forms.
For instance, in a typical windows forms application you could do the following.
CODE
//define a Control
private RichTextBox _tempBox;
//Create an accessor for it
private RichTextbox OurRTB
{
get { return _tempBox; }
set { _tempBox = value; }
}
//then if you needed to use it as an event you would invoke it sort like the following
private void InvokeTempBox()
{
_tempBox.Invoke(new EventHandler(delegate
{
_tempBox.AppenText("appending text \n");
}));
}
However, I have found out, since I have just started the jump from Win Forms to WPF this isn't quite a copy and paste solution. For instance using the same libs that worked in my WinForms, doesn't quite convert nicely in the WPF application.
This is because when you're create the object of a RichTextBox in a windows forms application you're using the class of System.Windows.Forms
but when you're creating the object of a RichTextBox on a WPF application you're using the
class of System.Windows.Controls
and there is no definition for an invoke in this class, so how is someone suppose to create an accessor correctly while working in a WPF application?
The exact error I get when I try to invoke a RichTextBox from the System.Windows.Controls class is the following below
CODE
Error 1 'System.Windows.Controls.RichTextBox'
does not contain a definition for 'Invoke'
and no extension method 'Invoke' accepting
a first argument of type 'System.Windows.Controls.RichTextBox'
And of course if I use a RichTextBox from System.Windows.Forms then I'm going to be getting ambiguous errors for using System.Windows.Controls, which is the class that is used for controls for WPF applications, and I then might as well be going back to a win form...
Thanks for answers in advance
This post has been edited by coden4fun: 28 Feb, 2009 - 10:50 PM