Simple WPF ViewModel implementaion with VisualBasic.NET
This is my trial for applying View-ViewModel concept in WPF Windows application. I do not have a Model for this sample so omitting that word
This is the XAML code which I used. Here I tried to do text binding with a TextBox and Command binding with a Button.
File 1: Window1.xaml
<Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=System.Core" Title="Window1" Height="300" Width="300" Name="Window1"> <Grid> <Button Margin="121,129,82,110" Name="Button1" Command="{Binding ClickCommand}">Button</Button> <TextBox Height="23" Margin="76,0,82,63" Name="TextBox1" VerticalAlignment="Bottom" Text="{Binding mytext}" /> </Grid> </Window>
File 2: Window1.xaml.vb
Class Window1
Private Sub Window1_Loaded(ByVal sender As System.Object,
ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
Dim vm As New ViewModel
vm.mytext = "test"
Window1.DataContext = vm
End Sub
End ClassAnd here is the VB.NET code:
File 3: ViewModel.vb
Imports System.ComponentModel Public Class ViewModel Implements INotifyPropertyChanged Public _mytext As String Public Property mytext() As String Get Return _mytext End Get Set(ByVal value As String) _mytext = value End Set End Property Public Property ClickCommand() As ICommand Get Return New ClickCommando(Me) End Get Set(ByVal value As ICommand) End Set End Property Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged End Class Public Class ClickCommando Implements ICommand Private _vm As ViewModel Public Sub Execute(ByVal parameter As Object) Implements ICommand.Execute MessageBox.Show(_vm.mytext) End Sub Public Function CanExecute(ByVal parameter As Object) As Boolean Implements ICommand.CanExecute Return True End Function Public Event CanExecuteChanged As EventHandler Implements ICommand.CanExecuteChanged Public Sub New(ByVal vm As ViewModel) _vm = vm End Sub End Class
Related posts:
Free eBook: The Complete Windows 7 Shortcuts
You can download it from here.
Related posts:
Silverlight for Mobile?
Silverlight for mobile enables developers to reuse their existing desktop code, content and skills, and leverages the flexible .NET programming model.
Microsoft Silverlight powers rich application experiences wherever the Web works including mobile devices. Silverlight provides a homogenous platform for developers to target a large number of devices as well as deliver rich interactive applications with scalable vector graphics user interfaces and mobile-optimized media.
- Which handsets will support Silverlight for mobile?
- Silverlight for mobile will start shipping on Nokia S60 and Windows Mobile devices first.
- What are the main features & benefits of Silverlight for mobile?
- Microsoft Silverlight is a cross-browser, cross-platform, and cross-device plug-in for delivering the next generation of .NET based media experiences and rich interactive applications for the Web. On mobile devices, Silverlight provides a homogenous platform for developers to target a large number of devices as well as deliver rich interactive applications with scalable vector graphics UI and mobile-optimized media. Further, Silverlight for mobile enables developers to reuse their existing desktop code, content and skills, and leverages the flexible .NET programming model.
- Will Silverlight for mobile plug-in on WM be any different from the one on S60?
- Silverlight provides a consistent experience across the Web and mobile devices. The same Silverlight applications will work on both Windows Mobile and Nokia S60 devices.
- How can I build applications with Silverlight for mobile?
- There is no difference in how you build Silverlight applications across Web and mobile devices. Developers and designers are supported by our world-class tools with Visual Studio and Expression Studio.
- How can I learn more about Silverlight for mobile?
- Silverlight for mobile is currently under development. Microsoft plan to release the final version in 2009.
- How does Silverlight for mobile ensure consistency across devices and platforms? How will my apps work and look the same way across different screen sizes, processor speeds and input mechanisms?
- Silverlight for mobile provides a consistent set of APIs across devices. The same Silverlight application therefore works across different devices and platforms. Developers also could easily optimize their applications for the form factor they are targeting.
- How does Silverlight for mobile integrate with the standards-based Web?
- There is no difference in how you build Silverlight applications across Web and mobile devices. Developers and designers are supported by our world-class tools with Visual Studio and Expression Studio.
- How is Silverlight for mobile different from Silverlight on desktop?
- The goal of Silverlight is to provide a consistent experience across desktop and mobile devices. Developers will be able to easily optimize Silverlight applications for mobile form factors or run existing Silverlight applications on mobile phones.
- What version of Silverlight is being made available on mobile initially?
- Silverlight for mobile will be based on Silverlight 2.
- Where can I find Silverlight for mobile and associated SDK for download?
- Silverlight for mobile is in private testing today. We haven’t announced any further details around availability at this time.
Read more here.
Related posts:
C# typeof equivalent in Visual Basic
Visual Basic.NET equivalent of C#’s typeof is GetType and NOT TypeOf
Related posts:
Windows 7 Contest - Saptha Mozhi - Get Windows 7 DVD
Related posts:
Community Tech Day @ Kochi – Jan 30 2010
Register here - http://www.communitytechdays.com/

Related posts:
MCTS – How to write the exam?
I know there are people who like to get certified but do now know the process. Here it is:
· You do not need to schedule the exam in advance as there won’t be any crowd when you are ready. If you are lucky, you may be able do the exam same day itself.
· There will be an average of 50-60 multiple choice questions. For some exams there will be simulation questions too
· Price is Rs. 2500/- (50 USD) per exam as of now.
· You will become an MCP if you take at least one exam. You may need to write one or more exams to get MCTS. When the number of exams grow, you will get certified as MCITP, MCPD, MCAD etc.
Here are my suggestions for some exams based on streams. Pick your specific exams from http://www.microsoft.com/learning/mcp/mcts/
Related posts:
What’s new in SharePoint 2010
- New Design/UI (Eg: Ribbon control)
- Silverlight WebPart
- Improvement in browser compatibility
- Improved Central Administration UI
- Edit your pages directly
- Rich Theming
- Visio support
- New SharePoint designer (2010)
- Faster Search
SharePoint 2010 will be available ONLY for 64 bit hardware
Hardware requirements for SharePoint 2010 are:
- 64 bit Hardware
- 64 bit OS (Windows Server 2008)
- 64 bit SQL Server
Related posts:
What’s new in Silverlight 4.0?
Not going in to details. Just bulleted points.
- Printing Support
- Improved Databinding
- Out-of-browser applicaitons – Can make the silverlight app make use of system resources
- Improved Media support – Eg: Webcam and Mic
- Introduction of new Controls (eg: RichTextBox)
- MES (Managed Extensibility Framework) support
- User defined context menus
- Access to Clipboard
- Mouse-wheel support
- Interop with COM
- Enhanced DataGrid
- Support for Google Chrome
Related posts:























