Silverlight 4 (VB) Visual Basic Code Snippets

Jan 6th, 2012No Comments

Here are a few code examples that hopefully will help someone out. If you have some vb silverlight 4 code, feel free to post. Only post code and any helpful notes explaining the code as well. thanks.

””””loop thru silverlight 4 vb data grid rows and check for a particular value and do work if that value is found.

””””””””””””””””””””””””””””””””””””””””””””””’
””””””””””””””” Datagrid ””””””””””””””””””’
””””””””””””””””””””””””””””””””””””””””””””””’
Private Sub V2_CustomerDataGrid_LoadingRow(ByVal sender As Object, ByVal e As System.Windows.Controls.DataGridRowEventArgs) Handles V2_CustomerDataGrid.LoadingRow
Dim row As DataGridRow = e.Row
Dim c = TryCast(row.DataContext, v2_Customer)
If c IsNot Nothing AndAlso c.Status.Contains(“www.floodtechs.com”) Then
e.Row.Foreground = New SolidColorBrush(Colors.Green)
Else
e.Row.Foreground = New SolidColorBrush(Colors.Red)
End If
End Sub

Mold Damage Cleanup, Water Damage Restoration Jobs,
Water Damage Restoration, Fire Damage Clean up
Water Damage Clean up, Flood Damage Clean up

”””” this procedure will count the rows of data in a Silverlight data grid and then do work based on the results.
””””””””””””””””””””””””””””””””””””””””””””””’
””””””””””””””” Count ”””””””””””””””””””’
””””””””””””””””””””””””””””””””””””””””””””””’
Private Sub Customer_Itemsource_count()
Dim count As Integer = 0
For Each c As Entity In V2_CustomerDataGrid.ItemsSource
count += 1
Next
Dim finalcount As Integer = count
If count = 0 Then
LabelHeader.Content = “You have no new leads.”
Else
LabelHeader.Content = WebContext.Current.User.Name.ToString & “, you have ” & count & ” leads.”
End If
End Sub

””””’ this line of code will retrieve the desired cell in a selected data grid row.
””””””””””””””””””””””””””””””””””””””””””””””’
””””””””””””””” Dataform ””””””””””””””””””
””””””””””””””””””””””””””””””””””””””””””””””’
Dim custID As Guid = (CType(V2_CustomerDataGrid.SelectedItem, _
v2_Customer)).Cust_UUID

‘ silverlight 4 vb – visual basic dataform edit ended
Private Sub V2_CustomerDataform_EditEnded(ByVal sender As Object, ByVal e As System.Windows.Controls.DataFormEditEndedEventArgs) Handles V2_CustomerDataform.EditEnded
V2_CustomerDataform.CommitEdit()
‘use with water damage restoration, flood clean up database only. Note to Janet – dept controller.
Dim encoding As New System.Text.UTF8Encoding()
‘Dim custID As Integer = (CType(CustomerDataGrid1.SelectedItem, Customer)).CustID

‘If custID = 0 Then
‘ CType(CustomerDataGrid1.SelectedItem, Customer).SSMA_TimeStamp = encoding.GetBytes(DateTime.Now.ToString())
‘End If

If e.EditAction = DataFormEditAction.Commit Then
ContextCompany_UUID.SubmitChanges()
If CheckBox1.IsChecked = True And CheckBox1.IsEnabled = True Then
jobstarted()
MessageBox.Show(“Added Cust and Updated!”)
End If

End If
End Sub

”””’ silverlight 4 vb – visual basic data form content loaded
””””””””””””””””””””””””””””””””””””””””””””””’
””””””””””””””” Dataform ”””””””””””””””””””’
””””””””””””””””””””””””””””””””””””””””””””””’
Private Sub Dataform_Account_ContentLoaded(ByVal sender As Object, ByVal e As System.Windows.Controls.DataFormContentLoadEventArgs) Handles Dataform_Account.ContentLoaded
Dim count As Integer = 0
For Each c As Entity In Dataform_Account.ItemsSource
count += 1
Next
Dim finalcount As Integer = count

If finalcount > 0 Then
‘ MessageBox.Show(“greater”)
Dataform_Account.CommandButtonsVisibility = DataFormCommandButtonsVisibility.Edit Or DataFormCommandButtonsVisibility.Commit Or DataFormCommandButtonsVisibility.Cancel
‘ Tabcontrol1.SelectedItem = TabItemAcct
‘ Else

‘ MessageBox.Show(“Click the + button to enter your Company Info…”)
End If
End Sub

””””show sliverlight 4 vb registration window
””””””””””””””””””””””””””””””””””””””””””””””’
””””””””””””””” Login ”””””””””””””””””””’
””””””””””””””””””””””””””””””””””””””””””””””’
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button2.Click
Dim lrw As New LoginUI.LoginRegistrationWindow
lrw.Show()
End Sub

”””silverlight 4 vb tab control tab item. Do work when a particular tab item is selected.
””””””””””””””””””””””””””””””””””””””””””””””’
””””””””””””””” TabControl ”””””””””””””””””””’
””””””””””””””””””””””””””””””””””””””””””””””’

Private Sub Tabcontrol1_SelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles Tabcontrol1.SelectionChanged
If Tabcontrol1.SelectedItem.Equals(TabItem_Software) Then
Dim loadOpZZ = context_software_login.Load(Me.context_software_login.GetV2_Users_GuidQuery(a))
V2_UsersDataGrid.ItemsSource = loadOpZZ.Entities

End If
End Sub

‘ programmatically show a data grid cell’s contents in a text block.
””””””””””””””””””””””””””””””””””””””””””””””’
””””””””””””””” TextBlock ”””””””””””””””””””’
””””””””””””””””””””””””””””””””””””””””””””””’
Dim IdSelect As TextBlock = DirectCast(V2_UsersCompanyDataGrid.Columns(0).GetCellContent(DataGrid1.SelectedItem), TextBlock)

Questions or comments, please visit our website at www.floodtechs.com.

About author:

Water, Fire, Mold damage restoration, remediation and removal services.

All entries by

Leave a Reply

  • Facebook
  • Google+
  • LinkedIn
  • Twitter
  • YouTube
  • Pinterest