R – Silverlight Button Click Event

silverlightsilverlight-2.0vb.net

I have a silverlight page with a textblock and button on it. Like this:

<TextBlock x:Name="txbNote" Margin="50,50" Text="Hello"/>        
<Button x:Name="btnCheck" Height="40"  Click="btnCheck_Click" ClickMode="Press" Margin="50,50,50,50" Content="Check Service"/>

Here is the handler for the click event:

Private Sub btnCheck_Click(ByVal sender As Object, ByVal e As EventArgs) 'Handles btnCheck.Click
  txbNote.Text = "I Was Clicked"
End Sub

It works… but…
Why doesn't this work?

<Button x:Name="btnCheck" Height="40"  Click="btnCheck_Click" ClickMode="Press" Margin="50,50,50,50" Content="Check Service"/>
<TextBlock x:Name="txbNote" Margin="50,50" Text="Hello"/>        

The only change is the relative position of the textblock and button. The button's click event (and every other event I tried) just doesn't fire unless the textblock is before the button in the xaml.

Best Answer

You may need to post more code as this could be an issue with the surrounding tags, such as the container that these controls are in.

If you're unable to paste it all to StackOverflow, use www.dpaste.com or www.pastebin.com.

Related Topic