Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4088238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:57:24+00:00 2026-05-20T18:57:24+00:00

I’m fairly new to C# and WPF programing and right now this problem is

  • 0

I’m fairly new to C# and WPF programing and right now this problem is giving me headaches.

What the program should do: The program displays a welcome screen with a text box, where a customer can enter his name.
If the device comes near a Wireless Lan Access Points and connects successfully, a “Start” button on this main window should become visible.

What’s not working: Setting the button visibility inside the event handler. The new style does not get applied. Furthermore, if I try to call any other code after setting the visibility attribute/property(?) it won’t run (if I put a MessageBox.Show right before setting the visib. it will be shown, if I put it after setting the property, this code won’t even be reached any more).

The code:

This is the button Element:

<Button Height="72" HorizontalAlignment="Center" Margin="319,507,315,0"
        Name="buttonStart" VerticalAlignment="Top" Width="168" FontSize="32"
        Content="Los geht's" Click="buttonStart_Click" />

This is the event handler registration within the MainWindow.xaml.cs

public partial class MainWindow : Window, INetworkListManagerEvents
{
    private INetworkListManager nlm_;
    private IConnectionPoint nlmICP_;
    private int nlmCookie_ = 0;

    private void InitNetManager()
    {
        nlm_ = new NetworkListManager();
        IConnectionPointContainer icpc = (IConnectionPointContainer)nlm_;
        Guid tempGuide = typeof(INetworkListManagerEvents).GUID;
        icpc.FindConnectionPoint(ref tempGuide, out nlmICP_);
        nlmICP_.Advise(this, out nlmCookie_);
    }

And finally, the event handler:

    public void ConnectivityChanged(NLM_CONNECTIVITY newConnectivity)
    {
        if (newConnectivity == NLM_CONNECTIVITY.NLM_CONNECTIVITY_DISCONNECTED ||
            ((int)newConnectivity & (int)NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_NOTRAFFIC) != 0)
        {
            MessageBox.Show("Disconnected"); // this will code is reached
            buttonStart.Visibility = Visibility.Hidden; // this is not getting applied
            MessageBox.Show("Disconnected");  // this will code is not reached (stepped with debugger)
        }

        if ((((int)newConnectivity & (int)NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_LOCALNETWORK) != 0) ||
            (((int)newConnectivity & (int)NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_INTERNET) != 0))
        {
            MessageBox.Show("Connected"); // see comments above
            buttonStart.Visibility = Visibility.Visible;
        }
    }

That’s it – I hope you can help me.

Thank you very much in advance for your efforts!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:57:24+00:00Added an answer on May 20, 2026 at 6:57 pm

    Hum – now I feel bad for answering my own question, but my urge to solve this problem kept me googling and finally I found out, that I can only change my WPF elements from the UI thread, but the INetwork-Events are called within a different thread.

    So I solved it this way:

        public void ConnectivityChanged(NLM_CONNECTIVITY newConnectivity)
        {
            if (newConnectivity == NLM_CONNECTIVITY.NLM_CONNECTIVITY_DISCONNECTED ||
                ((int)newConnectivity & (int)NLM_CONNECTIVITY.NLM_CONNECTIVITY_IPV4_NOTRAFFIC) != 0)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(
                    delegate()
                    {
                        buttonStart.Visibility = Visibility.Hidden;
                    }
                ));
            }
            // ...
        }
    

    Thanks for your time though 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.