Microsoft Silverlight 2.0 Beta 2 – Setting Initial Focus on Silverlight Control (Textbox)

(The initial discussion was for Silverlight 2.0 Beta 1)

Step #1

Create a dummy textbox for your initial SL XAML and set the following properties as follows:

Opacity="0" IsReadOnly="True" TabIndex="0"

Step #2

In the ‘loaded’ event of your initial SL …

Microsoft Silverlight 2.0 Beta 2 – InvalidOperationException occurred

Private WithEvents mylogonService As NewsrLogon.IwcfLogonServiceClient

Error:

Could not find default endpoint element that references contract
‘SilverlightApplication.srLogon.IwcfLogonService’ in the ServiceModel
client configuration section. This might be because no configuration file was
found for your application, or because no endpoint element matching …

Microsoft Silverlight 2.0 Beta 2 – How to navigate between xaml pages

Add the following to the app.xaml.vb:

 Dim mainUI As Grid = New Grid()

In Private Sub Application_Startup

 Me.RootVisual = mainUI

Add sub:

 Public Sub GoToPage(ByVal nextPg As UserControl)
      Dim app As App = CType(Application.Current, App)
      ' Remove the displayed page
      

Microsoft Silverlight – Resize controls in a canvas within the web browser

Using the ‘Canvas.RenderTransform’ in your base Silverlight XAML, along with some resizing logic in the base Silverlight .vb class, the controls within your browser will resize as you change the size of the browser.

In this scenario, the App.xaml Application_Startup …

Microsoft Silverlight – Error Logging to Isolated Storage

Isolated storage location is under

C:Users*username*AppDataLocalLowMicrosoftSilverlightis

To handle error logging in Silverlight, create a clsIsolatedStorage.vb

Imports System.IO
Imports System.Xml
Imports System.IO.IsolatedStorage
Imports MyApplication.clsApplicationGlobal
    Public Class clsIsolatedStorage
        Shared Sub ErrorHandler(ByVal mMode As String, ByVal Procedure As String, ByVal e As Exception)
            

Microsoft Silverlight – Error Handling in Silverlight

If you have an unhandled error sometimes Silverlight will just disappear from IE and leave a blank screen. In the App.xaml.vb under Application_UnhandledException add

e.Handled = True 

SAMPLE:

Private Sub Application_UnhandledException(ByVal sender As Object, ByVal e As ApplicationUnhandledExceptionEventArgs) Handles Me.UnhandledException
    

Microsoft Silverlight – Create a global variable to keep track of which page you are on

This is my example of creating a global variable that keeps track of which page I am on.

Created a class clsApplicationGlobal.vb

Public NotInheritable Class clsApplicationGlobal
   Public Shared HoldThePage As String
End Class

In each form, I put the following …