{"id":1713,"date":"2010-11-29T08:41:00","date_gmt":"2010-11-29T08:41:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/2010\/11\/29\/using-visual-studio-to-build-vb-windows-phone-applications\/"},"modified":"2022-10-10T14:46:58","modified_gmt":"2022-10-10T21:46:58","slug":"using-visual-studio-to-build-vb-windows-phone-applications","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/using-visual-studio-to-build-vb-windows-phone-applications\/","title":{"rendered":"Using Visual Studio to build VB Windows Phone Applications"},"content":{"rendered":"<p>by Yang Xiao<\/p>\n<p>Today we are announcing the release to web (RTW) of <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=206790&amp;clcid=0x409\">Visual Basic for Windows Phone Developer Tools<\/a>. This walkthrough demonstrates how easy and convenient it is to develop a VB Windows Phone application using the newly released tools. You\u2019ll see that the many new IDE features in Visual Studio 2010, which help you navigate and write code, are now available for VB Windows Phone applications!<\/p>\n<p>You may have seen the <a href=\"https:\/\/learn.microsoft.com\/en-us\/archive\/blogs\/jasonz\/\">Tip Calculator application<\/a> on Jason Zander\u2019s blog. This post is a variation on that example, and shows how to create a tip calculator that calculates the tip and splits the bill among a group. We\u2019ll need a way to specify group size, percentage of tip we want to give, and bill amount. Now let\u2019s get started!<\/p>\n<p><b>First<\/b>, create a Windows Phone 7 application. After installing <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=206790&amp;clcid=0x409\">VB for Windows Phone Developer Tools<\/a>, when you create a new project you\u2019ll see new Windows Phone application templates under the new \u201cSilverlight for Windows Phone\u201d node. The tip calculator we\u2019re writing only has one page, so we\u2019ll select the simplest template &#8211; Windows Phone Application, as shown in figure 1:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5123.clip_image0024_thumb_0B24C1FB.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200114\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5123.clip_image0024_thumb_0B24C1FB.jpg\" alt=\"Windows Phone Application\" width=\"554\" height=\"385\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5123.clip_image0024_thumb_0B24C1FB.jpg 554w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5123.clip_image0024_thumb_0B24C1FB-300x208.jpg 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/a>\nFig 1. Create a VB Windows Phone 7 Application<\/p>\n<p><b>Second<\/b>, add controls to select group size, tip percentage and bill amount. Similar to other Silverlight applications, we can add controls through the designer surface, by handcrafting XAML, or in code. We\u2019ll demonstrate a bit of each. The tip calculator\u2019s UI looks like this, shown in Fig 2.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7673.clip_image0044_thumb_246C799B.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200115\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7673.clip_image0044_thumb_246C799B.jpg\" alt=\"clip_image004[4]\" width=\"554\" height=\"469\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7673.clip_image0044_thumb_246C799B.jpg 554w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7673.clip_image0044_thumb_246C799B-300x254.jpg 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/a><\/p>\n<p>Fig 2. Tip Calculator UI Design<\/p>\n<p>Here\u2019s the XAML for the content panel which draws the above UI. As you can see, I use nested StackPanels to organize the controls, whose Orientation property take care of the location of containing text boxes, text blocks and buttons, making layout super easy to manage. The top level StackPanel contains five parts: a sharedByPanel to specify the group size, a tipPanel to specify the tip percentage, a StackPanel to enter bill amount, a StackPanel to display the calculated total tip, and a StackPanel to display the calculated total payment (bill + tip) for each person in the group.<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">Grid<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> x<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">:<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\">Name<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;ContentPanel&#8221;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Grid.Row<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;1&#8243;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Margin<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;12,0,12,0&#8243;&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Orientation<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Vertical&#8221;&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBlock<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Text<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Shared by: &#8220;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Style<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;{<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StaticResource<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> PhoneTextNormalStyle<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">}&#8221; \/&gt; <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 <\/span><span style=\"font-family: consolas; color: green; font-size: 9.5pt;\">&lt;!&#8211; StackPanel is purposely left blank here. Will add controls in code &#8211;&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Orientation<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Horizontal&#8221;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Name<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;sharedByPanel&#8221; &gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBlock<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Text<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Tip %: &#8220;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Style<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;{<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StaticResource<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> PhoneTextNormalStyle<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">}&#8221;\/&gt; <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: green; font-size: 9.5pt;\">&lt;!&#8211; StackPanel is purposely left blank here. Will add controls in code &#8211;&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Orientation<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Horizontal&#8221;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Name<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;tipPanel&#8221; &gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt; <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Orientation<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Horizontal&#8221;&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBlock<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Text<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Bill Amount: &#8220;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Style<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;{<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StaticResource<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> PhoneTextNormalStyle<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">}&#8221;\/&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBox<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> x<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">:<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\">Name<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;BillAmount&#8221;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Width<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;150&#8243;\/&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">Button<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> x<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">:<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\">Name<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;calcBtn&#8221;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Width<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;100&#8243;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Height<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;80&#8243;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> FontSize<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;13&#8243;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Content<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Run!&#8221;&gt;&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">Button<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Orientation<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Horizontal&#8221;&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBlock<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Text<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Total tips: &#8220;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Height<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;50&#8243;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Style<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;{<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StaticResource<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> PhoneTextNormalStyle<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">}&#8221;\/&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBlock<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> x<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">:<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\">Name<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\"> =&#8221;totalTip&#8221;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Style<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;{<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StaticResource<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> PhoneTextNormalStyle<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">}&#8221;\/&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Orientation<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Horizontal&#8221;&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBlock<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Text<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;Each pays: &#8220;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Height<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;50&#8243;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Style<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;{<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StaticResource<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> PhoneTextNormalStyle<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">}&#8221;\/&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">TextBlock<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> x<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">:<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\">Name<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;eachPays&#8221;<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> Style<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">=&#8221;{<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StaticResource<\/span><span style=\"font-family: consolas; color: red; font-size: 9.5pt;\"> PhoneTextNormalStyle<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">}&#8221;\/&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">StackPanel<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">Grid<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt;<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&lt;\/<\/span><span style=\"font-family: consolas; color: #a31515; font-size: 9.5pt;\">Grid<\/span><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">&gt; <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>You can easily drag controls such as TextBlocks, Textboxes and Buttons from the Toolbox to the design surface, as shown in Fig 3.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/0310.clip_image0064_thumb_7AE4C035.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200116\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/0310.clip_image0064_thumb_7AE4C035.jpg\" alt=\"draggable elements\" width=\"554\" height=\"469\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/0310.clip_image0064_thumb_7AE4C035.jpg 554w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/0310.clip_image0064_thumb_7AE4C035-300x254.jpg 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/a><\/p>\n<p>Fig 3. Drag controls from the Toolbox to Design Surface<\/p>\n<p>Nested StackPanels can be conveniently added wherever necessary in MainPage.xaml file directly. The Visual Studio editor\u2019s IntelliSense makes XAML editing user friendly. See Fig 4 for an example of XAML intelliSense on the orientation property for a StackPanel.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/6560.clip_image0084_thumb_5D02E9DC.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200117\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/6560.clip_image0084_thumb_5D02E9DC.jpg\" alt=\"clip_image008\" width=\"554\" height=\"469\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/6560.clip_image0084_thumb_5D02E9DC.jpg 554w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/6560.clip_image0084_thumb_5D02E9DC-300x254.jpg 300w\" sizes=\"(max-width: 554px) 100vw, 554px\" \/><\/a><\/p>\n<p>Fig 4. XAML IntelliSense<\/p>\n<p>To make the UI more interesting, I\u2019m going to draw a person icon to indicate the group size, as shown in Fig 5. The green color indicates how many people are sharing the bill. If the user clicks the 4<sup>th<\/sup> icon, then the first 4 person icons will turn green. This has been implemented through adding code in MainPage.xaml.vb.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/3326.clip_image0104_thumb_65B2A68E.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200118\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/3326.clip_image0104_thumb_65B2A68E.jpg\" alt=\"clip_image010\" width=\"214\" height=\"78\" \/><\/a><\/p>\n<p>Fig 5. Use the Person Icon to Indicate the Group Size<\/p>\n<p>The person icon is implemented as a button with two ellipses, which allows me to use Fill property to change color. Each person icon is also hooked up with an event handler that processes the color change for all the icons before itself. This requires that each icon knows its position and is able to identify the icons before it. To achieve this, I use an inherited class PersonBtn from Button, adding Id to indicate its position.<\/p>\n<p>One enhancement you\u2019ve probably noticed in Visual Studio 2010 is that we <b>removed the line continuation character <\/b>(in 95% of cases)! This was a long requested feature from VB developers, and it works in VB Windows Phone applications as well! Furthermore with <strong>Auto-implemented Properties <\/strong>(highlighted below), you can declare a property and its default value in one line!<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">Public<\/span><span style=\"font-family: consolas; font-size: 9.5pt;\"> <span style=\"color: blue;\">Class<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Inherits<\/span> <span style=\"color: #2b91af;\">Button<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"background: yellow; color: blue;\">Property<\/span><span style=\"background: yellow;\"> Id <span style=\"color: blue;\">As<\/span> <span style=\"color: blue;\">Integer<\/span><\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Property<\/span> Head <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">Ellipse<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Property<\/span> Body <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">Ellipse<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Dim<\/span> headSize <span style=\"color: blue;\">As<\/span> <span style=\"color: blue;\">Integer<\/span> = 20 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Dim<\/span> bodyWidth <span style=\"color: blue;\">As<\/span> <span style=\"color: blue;\">Integer<\/span> = 30 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Dim<\/span> bodyHeight <span style=\"color: blue;\">As<\/span> <span style=\"color: blue;\">Integer<\/span> = 40 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Public<\/span> <span style=\"color: blue;\">Sub<\/span> <span style=\"color: blue;\">New<\/span>(<span style=\"color: blue;\">ByVal<\/span> i <span style=\"color: blue;\">As<\/span> <span style=\"color: blue;\">Integer<\/span>) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">MyBase<\/span>.New() <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Id = i <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 AddControl() <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">Sub<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Private<\/span> <span style=\"color: blue;\">Sub<\/span> AddControl() <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: green;\">&#8216;button<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Me<\/span>.Width = 80 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Me<\/span>.Height = 100 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Me<\/span>.BorderThickness = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">Thickness<\/span>(0) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: green;\">&#8216;person<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Head = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">Ellipse<\/span> <span style=\"color: blue;\">With<\/span> {.Fill = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">SolidColorBrush<\/span>(<span style=\"color: #2b91af;\">Colors<\/span>.White), .Height = headSize, .Width = headSize} <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Body = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">Ellipse<\/span> <span style=\"color: blue;\">With<\/span> {.Fill = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">SolidColorBrush<\/span>(<span style=\"color: #2b91af;\">Colors<\/span>.White), .Height = bodyHeight, .Width = bodyWidth} <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Dim<\/span> personStackPanel = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">StackPanel<\/span> <span style=\"color: blue;\">With<\/span> {.Orientation = <span style=\"color: #2b91af;\">Orientation<\/span>.Vertical} <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 personStackPanel.Children.Add(Head) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 personStackPanel.Children.Add(Body) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Me<\/span>.Content = personStackPanel <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">Sub<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Public<\/span> <span style=\"color: blue;\">Sub<\/span> ChangeColor(<span style=\"color: blue;\">ByVal<\/span> c <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">Color<\/span>) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Head.Fill = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">SolidColorBrush<\/span>(c) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Body.Fill = <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">SolidColorBrush<\/span>(c) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">Sub<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">End<\/span><span style=\"font-family: consolas; font-size: 9.5pt;\"> <span style=\"color: blue;\">Class <\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Now that we have PersonBtn, I can add multiple instances of it on the UI, as shown in code below. The first highlighted line uses a VB <b>collection initializer<\/b> to conveniently define an array of user-defined types and assign values in the same statement. The icons are added to the containing StackPanel by calling sharedByPanel.Children.Add method. The second highlighted line adds a universal event handler to each PersonBtn to specify the group size, and changes the corresponding person icon color to green.<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; background: yellow; color: blue; font-size: 9.5pt;\">Dim<\/span><span style=\"font-family: consolas; background: yellow; font-size: 9.5pt;\"> personArray <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span>()= {<span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span>(1), <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span>(2), <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span>(3), <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span>(4), <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span>(5)}<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">For<\/span> <span style=\"color: blue;\">Each<\/span> p <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">PersonBtn<\/span> <span style=\"color: blue;\">In<\/span> personArray <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sharedByPanel.Children.Add(p) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"background: yellow; color: blue;\">AddHandler<\/span><span style=\"background: yellow;\"> (p.GotFocus), <span style=\"color: blue;\">AddressOf<\/span> HandlePersonSelection<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: green;\">&#8216;set default<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">If<\/span> (p.Id = 1) <span style=\"color: blue;\">Then<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 p.ChangeColor(<span style=\"color: #2b91af;\">Colors<\/span>.Green) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Else<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 p.ChangeColor(<span style=\"color: #2b91af;\">Colors<\/span>.White) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">If<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Next <\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Private<\/span> <span style=\"color: blue;\">Sub<\/span> HandleTipSelection(<span style=\"color: blue;\">ByVal<\/span> sender <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">Button<\/span>, <span style=\"color: blue;\">ByVal<\/span> e <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">RoutedEventArgs<\/span>) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 percentTips = <span style=\"color: blue;\">DirectCast<\/span>(sender, <span style=\"color: #2b91af;\">PercentageBtn<\/span>).Ptg <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">DirectCast<\/span>(sender, <span style=\"color: #2b91af;\">PercentageBtn<\/span>).ChangeColor(<span style=\"color: #2b91af;\">Colors<\/span>.Green) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Dim<\/span> nonSelectedTipPercents = <span style=\"color: blue;\">From<\/span> t <span style=\"color: blue;\">In<\/span> tipPercentArray <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Where<\/span> t.Ptg &lt;&gt; percentTips <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">For<\/span> <span style=\"color: blue;\">Each<\/span> t <span style=\"color: blue;\">In<\/span> nonSelectedTipPercents <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 t.ChangeColor(<span style=\"color: #2b91af;\">Colors<\/span>.White) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Next<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">Sub<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><b>Next,<\/b> we\u2019ll add the remaining controls and logic to the code. The tip percentage icon is implemented in a similar manner, as shown in Fig 6. See attached solution for detailed code.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/0358.clip_image0124_thumb_19A6FA48.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200119\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/0358.clip_image0124_thumb_19A6FA48.jpg\" alt=\"clip_image012\" width=\"214\" height=\"59\" \/><\/a><\/p>\n<p>Fig 6. Tip Percentage<\/p>\n<p>There are a few tricks are worth mentioning when you write a Windows Phone app. For example, to enter the bill amount, the default keyboard setting is English characters and users can click the number button to switch to numeric input. However in code, you can change default keyboard setting and save users a click. Here\u2019s how to do it through the TextBox\u2019s InputScope property:<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0 <span style=\"color: blue;\">Dim<\/span> DigitKeyboard <span style=\"color: blue;\">As<\/span> <span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">InputScope<\/span>() <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 DigitKeyboard.Names.Add(<span style=\"color: blue;\">New<\/span> <span style=\"color: #2b91af;\">InputScopeName<\/span> <span style=\"color: blue;\">With<\/span> {.NameValue = <span style=\"color: #2b91af;\">InputScopeNameValue<\/span>.Digits}) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 BillAmount.InputScope = DigitKeyboard <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Also, you can use the string format to easily change numbers to the desired currency format in just one line. Here\u2019s an example:<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; color: blue; font-size: 9.5pt;\">Private<\/span><span style=\"font-family: consolas; font-size: 9.5pt;\"> <span style=\"color: blue;\">Sub<\/span> calcBtn_Click(<span style=\"color: blue;\">ByVal<\/span> sender <span style=\"color: blue;\">As<\/span> System.<span style=\"color: #2b91af;\">Object<\/span>, <span style=\"color: blue;\">ByVal<\/span> e <span style=\"color: blue;\">As<\/span> System.Windows.<span style=\"color: #2b91af;\">RoutedEventArgs<\/span>) <span style=\"color: blue;\">Handles<\/span> calcBtn.Click <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: green;\">&#8216;calcualte and show updates<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">If<\/span> (<span style=\"color: blue;\">Not<\/span> <span style=\"color: blue;\">String<\/span>.IsNullOrEmpty(BillAmount.Text)) <span style=\"color: blue;\">Then<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Try<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 totalBill = <span style=\"color: blue;\">CDbl<\/span>(BillAmount.Text) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 totalTips = totalBill * (percentTips \/ 100) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 payPerPerson = (totalBill + totalTips) \/ sharedBy <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"background: yellow;\">totalTip.Text = totalTips.ToString(<span style=\"color: #a31515;\">&#8220;C&#8221;<\/span>, <span style=\"color: blue;\">New<\/span> System.Globalization.<span style=\"color: #2b91af;\">CultureInfo<\/span>(<span style=\"color: #a31515;\">&#8220;en-US&#8221;<\/span>))<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 eachPays.Text = payPerPerson.ToString(<span style=\"color: #a31515;\">&#8220;C&#8221;<\/span>, <span style=\"color: blue;\">New<\/span> System.Globalization.<span style=\"color: #2b91af;\">CultureInfo<\/span>(<span style=\"color: #a31515;\">&#8220;en-US&#8221;<\/span>)) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">Catch<\/span> ex <span style=\"color: blue;\">As<\/span> <span style=\"color: #2b91af;\">InvalidCastException<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: #2b91af;\">MessageBox<\/span>.Show(<span style=\"color: #a31515;\">&#8220;Please enter a valid $ amount!&#8221;<\/span>) <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">Try<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">If<\/span> <\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: consolas; font-size: 9.5pt;\">\u00a0\u00a0\u00a0 <span style=\"color: blue;\">End<\/span> <span style=\"color: blue;\">Sub <\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>Now we\u2019re done coding both the UI and the application logic! Let\u2019s hit F5 and run it. If you don\u2019t have a Windows Phone 7 physically connected to your computer, Windows Phone Developer Tools will launch the Emulator. This is also the default setting. To see how this tip calculator runs in the Emulator, please see Fig 6. (I removed the button borders to make them look nicer. J)<\/p>\n<p>Windows Phone 7 applications provide the same full debugging experience as other VB Silverlight applications. You can set breakpoints, step into, over and out function calls, and use all the debug windows such as Watch, Autos, Locals, Immediate, and Threads.<\/p>\n<p>As an exercise for yourself \u2013 the current application only allows sharing among group size of 5. Add UI and logic to remove this restriction!<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1401.clip_image0144_thumb_6DA634F1.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200120\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1401.clip_image0144_thumb_6DA634F1.jpg\" alt=\"tip calculator\" width=\"326\" height=\"589\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1401.clip_image0144_thumb_6DA634F1.jpg 326w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1401.clip_image0144_thumb_6DA634F1-166x300.jpg 166w\" sizes=\"(max-width: 326px) 100vw, 326px\" \/><\/a><\/p>\n<p>Fig 7. Tip Calculator Running in the Windows Phone Emulator<\/p>\n<p>&nbsp;<\/p>\n<h2><b>Visual Studio 2010 IDE Tips &amp; Tricks<\/b><\/h2>\n<p>At the end, I want to highlight a few new IDE features in VS 2010. These features are also available in Windows Phone application development, and can help improve your code navigation and editing experience.<\/p>\n<p><b>Navigate To (Ctrl + ,)<\/b><\/p>\n<p>Activate this command from the Edit menu (Edit-&gt;Navigate To), or using the keyboard (Ctrl+,). \u201cNavigate To\u201d helps quickly navigate to functions, type definitions and files. It supports Pascal Casing and multiple-string search. See Fig 8.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5611.clip_image0164_thumb_4C72ECBD.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200121\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5611.clip_image0164_thumb_4C72ECBD.jpg\" alt=\"edit menu\" width=\"580\" height=\"416\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5611.clip_image0164_thumb_4C72ECBD.jpg 580w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5611.clip_image0164_thumb_4C72ECBD-300x215.jpg 300w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/a><\/p>\n<p>Fig 8. Navigate To, for functions, type definitions, and files<\/p>\n<p><b>Generate From Usage (Ctrl + .)<\/b><\/p>\n<p>Generate types and method stubs on the go! You don\u2019t have to define everything before you implement your logic. This also helps in a collaboration environment where your team members can implement dependent components. See example in Fig 10.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1882.clip_image0184_thumb_3CFF3F14.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200122\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1882.clip_image0184_thumb_3CFF3F14.jpg\" alt=\"Fig 10\" width=\"320\" height=\"147\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1882.clip_image0184_thumb_3CFF3F14.jpg 320w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/1882.clip_image0184_thumb_3CFF3F14-300x138.jpg 300w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/a><\/p>\n<p>Fig 10. Ctrl + . to Bring up Generate From Usage Smart Tag for Undeclared Type Test<\/p>\n<p>Selecting \u201cGenerate Class Test\u201d in Fig 10 will create a new file Test.vb , containing a newly generated class . Selecting \u201cGenerate new type\u2026\u201d will bring up the following Generate From Usage Dialog, which provides further customization of the new type being created. See Fig 11.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7455.clip_image0204_thumb_43C36D43.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200123\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7455.clip_image0204_thumb_43C36D43.jpg\" alt=\"usage dialog\" width=\"303\" height=\"326\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7455.clip_image0204_thumb_43C36D43.jpg 303w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/7455.clip_image0204_thumb_43C36D43-279x300.jpg 279w\" sizes=\"(max-width: 303px) 100vw, 303px\" \/><\/a><\/p>\n<p>Fig 11. Generate From Usage Dialog<\/p>\n<p><b>Intellisense Consume First Mode (Ctrl + Shift + Space)<\/b><\/p>\n<p>Disable aggressive matching from IntelliSense. This comes up most frequently in situations like above, when you reference a symbol name before it\u2019s been defined. However with Consume First Mode enabled, when you\u2019re typing a new type that doesn\u2019t exist, IntelliSense will not get in your way anymore! See Fig 9.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5633.clip_image0224_thumb_099454CA.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-200124\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/5633.clip_image0224_thumb_099454CA.jpg\" alt=\"disable intellisense\" width=\"244\" height=\"181\" \/><\/a>\nFig 9. Intellisense Consume First Mode<\/p>\n<p><b>Box Selection and Multiline Editing (Hold Alt and drag mouse)<\/b><\/p>\n<p>You can now do box selection and edit multiple lines! See a video demo here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/box-selection-and-multi-line-editing\/\">http:\/\/blogs.msdn.com\/b\/visualstudio\/archive\/2009\/10\/26\/box-selection-and-multi-line-editing<\/a><\/p>\n<p>Now you have all the secret weapons. Have fun writing your own VB Windows Phone applications!<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2010\/11\/TipCalculator.zip\">TipCalculator<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>by Yang Xiao Today we are announcing the release to web (RTW) of Visual Basic for Windows Phone Developer Tools. This walkthrough demonstrates how easy and convenient it is to develop a VB Windows Phone application using the newly released tools. You\u2019ll see that the many new IDE features in Visual Studio 2010, which help [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[9,185,653,133],"class_list":["post-1713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","tag-debug","tag-node-js","tag-visual-basic","tag-xaml"],"acf":[],"blog_post_summary":"<p>by Yang Xiao Today we are announcing the release to web (RTW) of Visual Basic for Windows Phone Developer Tools. This walkthrough demonstrates how easy and convenient it is to develop a VB Windows Phone application using the newly released tools. You\u2019ll see that the many new IDE features in Visual Studio 2010, which help [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/1713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=1713"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/1713\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=1713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=1713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=1713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}