Solved

Threading is not a member of windows... vb.net

Posted on 2014-10-28
2
725 Views
Last Modified: 2014-10-28
At line 22, I am getting two error notes:  

Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, DirectCast(Sub() element.Focus(),

Dispatcher: Dispacher is not declared. It may be inaccessible due to its protection level.
System.Windows.Threading: Threading is not a member of windows

Question: How can I fix this?

Please, in addition to description of the direction, give me the syntax for my use.


tabcontrol.IsSelected=true;
PutFocusOnControl(textBox1);
and define the method...

 private void PutFocusOnControl(Control element)
        {
            if (element != null)
                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input,
                    (System.Threading.ThreadStart)delegate
                    {
                        element.Focus();
                    });
        }

or:

                TabControl1.SelectedTab = tabChannels
                PutFocusOnControl(txtChannels_channel)

    Private Sub PutFocusOnControl(element As Control)
        If element IsNot Nothing Then
            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Input, DirectCast(Sub() element.Focus(), System.Threading.ThreadStart))
        End If
    End Sub

from:
http://stackoverflow.com/questions/3865370/unable-to-set-focus-on-controls-inside-tab-control-in-wpf

Open in new window

0
Comment
Question by:Mike Eghtebas
2 Comments
 
LVL 33

Accepted Solution

by:
it_saige earned 500 total points
ID: 40409232
Have you added a reference to WindowBase.dll?

http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher(v=vs.110).aspx

To add the reference:
1.  Right-click on your project and select 'Add Reference'Capture.JPG2.  Select the .NET tab.Capture.JPG3.  Locate and select 'WindowsBase'Capture.JPG4.  Press 'OK'.

Once you have the reference added then you may need to refer to Dispatcher by it's fully qualified name, e.g. -
System.Windows.Threading.Dispatcher.BeginInvoke(...)

Open in new window

Or you can add an Imports statement to the top of your code file, e.g. -
Imports System.Windows.Threading

Public Class SomeClass
...
...
End Class

Open in new window


-saige-
0
 
LVL 34

Author Closing Comment

by:Mike Eghtebas
ID: 40409254
Thank you.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question