Wednesday, May 16, 2012

Gadget Style WPF Application

I just made this from a Channel 9 Training Video.

XAML:
Type Here

Code Behind:
Class Window1

Private Sub Window1_MouseLeftButtonDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
Me.DragMove()
End Sub

Private Sub CloseButton_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles CloseButton.Click
Me.Close()
End Sub
End Class

Delete entire SharePoint List Items (VB.NET)


A small problem that i faced, was to delete an entire SPList Items.
Here is the solution.

'Get Context
Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
'Open Web
Dim wb As SPWeb = siteCollection.OpenWeb()
'Get List
Dim spl As SPList = wb.GetList(wb.Url.ToString + "/Lists/YourListNameToDeleteItems")
spl.AllowDeletion = True
Try
    While spl.Items.Count > 0
        spl.Items(0).Delete()
    End While
    spl.Update()
'"Update Delete for list items"
Catch ex As Exception
End Try