Skip to main content

Microsoft Silverlight

Answered Question Popup in VB (NOT C#)RSS Feed

(0)

Kermit75
Kermit75

Member

Member

22 points

47 Posts

Popup in VB (NOT C#)

Hello!

I would like to use a popup control in my SL VB project.

All example code I have found is for C# only. :(
Example: http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.popup(VS.95).aspx

How do I write similar VB code?

Thanks a bunch! :D

 

ccoombs
ccoombs

Contributor

Contributor

5168 points

758 Posts

Answered Question

Re: Popup in VB (NOT C#)

If you can write VB code, you should be able to AT LEAST translate from C#, if not write in both languages.  There are only a few (very small) differences.  The code sample in the link you provided can be translated as follows:

 

    Private p As New Popup()

    Private Sub btnTest_Click() Handles btnTest.Click
        Dim border As New Border()
        border.BorderBrush = New SolidColorBrush(Colors.Black)
        border.BorderThickness = New Thickness(5.0)

        Dim panel1 As New StackPanel()
        panel1.Background = New SolidColorBrush(Colors.LightGray)

        Dim button1 As New Button()
        button1.Content = "Close"
        button1.Margin = New Thickness(5.0)
        AddHandler button1.Click, AddressOf button1_Click
        Dim textblock1 As New TextBlock()
        textblock1.Text = "The popup control"
        textblock1.Margin = New Thickness(5.0)
        panel1.Children.Add(textblock1)
        panel1.Children.Add(button1)
        border.Child = panel1

        ' Set the Child property of Popup to the border 
        ' which contains a stackpanel, textblock and button.
        p.Child = border

        ' Set where the popup will show up on the screen.
        p.VerticalOffset = 25
        p.HorizontalOffset = 25

        ' Open the popup.
        p.IsOpen = True
    End Sub

    Private Sub button1_Click()
        p.IsOpen = False
    End Sub
  

SieGoBoY
SieGoBoY

Member

Member

2 points

1 Posts

Re: Re: Popup in VB (NOT C#)

Thanks man!

 That saved my life, I am totally a beginner programmer and was struggling with this for ages! You rock.

cheers

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities