<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Elegant Code &#187; xaml</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Betnovate Without Prescription</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinWidth&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinWidth}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinHeight&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinHeight}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderThickness&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> InputControlBorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontFamily&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontFamily}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontSize&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.HorizontalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.VerticalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.ZoomMode&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Padding&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxPaddingThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButtonStyle&quot;</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;/&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Pressed&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> FontFamily</span><span style="background:#ffffff;color:#0000ff">=&quot;Segoe UI Symbol&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;X&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;*&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;Auto&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Focused&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonVisible&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonCollapsed&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Let’s test what we have so far.&#160; Add an instance of our WatermarkTextBox control to the BlankPage.xaml.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5b472f91-aaa4-4de0-a251-52d2d2c82795" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Page</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Class</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTextBoxControl.BlankPage&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">x</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">local</span><span style="background:#ffffff;color:#0000ff">=&quot;using:WatermarkTextBoxControl&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">d</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">mc</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> mc</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Ignorable</span><span style="background:#ffffff;color:#0000ff">=&quot;d&quot;&gt;</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Page</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image5.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb5.png" width="275" height="60" /></a></p>  <p>Looks great.&#160; Just like the default Windows TextBox.&#160; Now we need to start adding our Watermark elements to it.&#160; Obviously we need a property for our Watermark.&#160; Your first thought maybe to define it as a type of string, but I want to support any element, not just text, so I will define it as a type of Object.&#160; This will allow me to nest controls inside of the Watermark property instead of being restricted to a simple string.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:db082020-3ed1-4025-b979-4d938ab172a9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;Watermark&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> Watermark</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>I also want to define a DataTemplate that will be used to define the ContentTemplate for the Watermark.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd631c4b-41c5-442b-8fb7-9704ba9c139b" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkTemplateProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000"> WatermarkTemplate</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkTemplateProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkTemplateProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Now we need to modify our control template to support our new Watermark property. We will do this by simply adding a ContentPresenter to our Template.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4431129a-2a62-4f39-abc1-6c7e0c47b874" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate price, coupon</b>, <b>Where to buy Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span></div> </div> </div>  <p>Oh, <b>effects of Betnovate</b>, <b>Is Betnovate safe</b>, and don’t forget the ContentTemplate that will define the default look for our watermark.&#160; This is placed at the top of the Generic.xaml.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baa07ca8-8bac-40b7-aece-36f27dedd0e5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>purchase Betnovate online no prescription</b>, <b>Online buy Betnovate without a prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Key</span><span style="background:#ffffff;color:#0000ff">=&quot;DefaultWatermarkTemplate&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentControl</span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">Binding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;Gray&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>And we need to set the default value in a style setter.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7175292-1fca-49aa-85ae-7ff859ab8ec2" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Buy Betnovate online cod</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DefaultWatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot; /&gt;</span></div> </div> </div>    <p>As you can see, I placed the ComtentPresenter after the ContentElement and before the DeleteButton elements.&#160; You may have also noticed that I set the visibility to Collapsed.&#160; This is because by default I want the Watermark hidden.&#160; So that means we need to add some code to show the watermark when the text box has no focus and it has no text.&#160; First we need to add some visual states to the VisualStateManager.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b482c41e-77da-4f54-ad99-4493ac8b1f73" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from canada</b>, <b>Betnovate without prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkStates&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkVisible&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkCollapsed&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Next we need to add some code to handle the GotFocus and LostFocus events of the TextBox.&#160; Start by adding event handlers for the events in the constructor.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e05e8b51-c571-48bc-9ee7-10b58950f385" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from mexico</b>, <b>Japan, craiglist, ebay, overseas, paypal</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.GotFocus += WatermarkTextBox_GotFocus;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.LostFocus += WatermarkTextBox_LostFocus;</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>Now add the code that does the heavy lifting.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:367568eb-5f40-4e4a-9861-50bab0c05329" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate brand name</b>, <b>Purchase Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_GotFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, <b>where can i buy cheapest Betnovate online</b>, <b>Canada, mexico, india</b>, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState();</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_LostFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> hasFocus = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//if our text is empty and our control doesn&#39;t have focus then show the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//otherwise the control eirther has text or has focus which in either case we need to hide the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">String</span><span style="background:#ffffff;color:#000000">.IsNullOrEmpty(Text) &amp;&amp; !hasFocus)</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkVisible&quot;</span><span style="background:#ffffff;color:#000000">); </span><span style="background:#ffffff;color:#008000">//TODO: create constants for our magic strings</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">else</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkCollapsed&quot;</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToVisualState(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> stateName, <b>herbal Betnovate</b>, <b>Taking Betnovate</b>, </span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> useTransitions = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">VisualStateManager</span><span style="background:#ffffff;color:#000000">.GoToState(</span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">, stateName, <b>rx free Betnovate</b>, <b>Order Betnovate online c.o.d</b>, useTransitions);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>One last thing is to make sure we set the visual state when the template is applied.&#160; So override the OnApplyTemplate method as follows.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d36c00a9-70e0-4692-9b7c-92d0a6de7deb" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate schedule</b>, <b>Betnovate dosage</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">override</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnApplyTemplate()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">base</span><span style="background:#ffffff;color:#000000">.OnApplyTemplate();</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//we need to set the initial state of the watermark</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>That should do it.&#160; Now let check it out in action. Be sure to provide a watermark for our control.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0630f9fd-701c-4d59-bcdb-4c659a352180" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate cost</b>, <b>Betnovate no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#ff0000"> Watermark</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb6.png" width="279" height="60" /></a></p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb7.png" width="279" height="63" /></a></p>  <h4>Yes, <b>Betnovate from mexico</b>, <b>Betnovate description</b>, we found a bug</h4>  <p>Everything seems to be working perfectly.&#160; Until you actually try to use a watermark that isn’t text.&#160; Try using this as your watermark.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c7fdd2-45ff-4ca5-86cb-5fe1adc8c10e" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>online buying Betnovate</b>, <b>Betnovate pics</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Orientation</span><span style="background:#ffffff;color:#0000ff">=&quot;Horizontal&quot;&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Image</span><span style="background:#ffffff;color:#ff0000"> Source</span><span style="background:#ffffff;color:#0000ff">=&quot;Images/PencilTool16.png&quot;</span><span style="background:#ffffff;color:#ff0000"> Stretch</span><span style="background:#ffffff;color:#0000ff">=&quot;None&quot;</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;4,0, <b>Betnovate interactions</b>, <b>Get Betnovate</b>, 0,0&quot; /&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>Now let’s see our results.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb8.png" width="275" height="60" /></a></p>  <p>Hey!&#160; Where is my watermark?&#160; Well there appears to be a bug with a ContentPresenter/ContentControl that will not display content when the ContentTemplate has been set and the Content is anything else except a string.&#160; This just so happens to be the exact same bug that exists in Silverlight.&#160; Interesting I know.&#160; So how do we fix it?&#160; We have to delete the usage of our Watermarktemplate until this gets fixed.</p>  <p>Change:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:715e6953-8e22-4e2e-8b8f-a4700760cfa9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>real brand Betnovate online</b>, <b>Betnovate steet value</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>To:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f626a1e-1d1c-489a-96cb-7f056392a0a8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>my Betnovate experience</b>, <b>Betnovate wiki</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>               <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>Now let’s see what happens.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image9.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb9.png" width="276" height="59" /></a></p>  <p>Now that’s much better.&#160; Let’s hope this is just a beta bug.</p>  <p><a href="http://brianlagunas.com/downloads/source/WatermarkTextBoxControl.zip" target="_blank">Download the source</a></p>, <b>low dose Betnovate</b>.  Order Betnovate from mexican pharmacy.  Online Betnovate without a prescription.  Betnovate long term.  Betnovate photos.  Betnovate samples.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4354'>Glucophage For Sale</a>. <a href='http://elegantcode.com/?p=4681'>Betnovate For Sale</a>. <a href='http://elegantcode.com/?p=4291'>Buy Vibramycin Without Prescription</a>. <a href='http://elegantcode.com/?p=4268'>Soma For Sale</a>. <a href='http://elegantcode.com/?p=4276'>Buy Viagra Without Prescription</a>. <a href='http://elegantcode.com/?p=4831'>Buying Glucophage online over the counter</a>. <a href='http://elegantcode.com/?p=4846'>Effects of Ketoconazole Cream</a>. <a href='http://elegantcode.com/?p=5014'>Order Quinine online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4232'>Japan, craiglist, ebay, overseas, paypal</a>. <a href='http://elegantcode.com/?p=4867'>Ordering Soma online</a>.<br />
<b>Trackbacks from:</b> <a href='http://home.officesnapshots.com/?p=250'>Buy Betnovate Without Prescription</a>. <a href='http://reversemortgagedaily.com/?p=14063'>Buy Betnovate Without Prescription</a>. <a href='http://social-blend.com/?p=1202'>Buy Betnovate Without Prescription</a>. <a href='http://www.quarterlives.com/?p=454'>Buy Betnovate Without Prescription</a>. <a href='http://4realz.net/?p=758'>Buy Betnovate Without Prescription</a>. <a href='http://blog.farmland.org/?p=3440'>Betnovate dosage</a>. <a href='http://linuxologist.com/?p=129'>Betnovate price, coupon</a>. <a href='http://www.themusclecarplace.com/?p=3456'>Betnovate no rx</a>. <a href='http://www.thegriffonnews.com/?p=10192'>Betnovate use</a>. <a href='http://www.greatgreengoods.com/?p=3270'>Kjøpe Betnovate på nett, köpa Betnovate online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vermox For Sale</title>
		<link>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:51:29 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[So far we have built an earthquake application Vermox For Sale, , mapped an address using geocoding, and even Prism-fied the Bing Maps WPF control.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can [...]]]></description>
			<content:encoded><![CDATA[<p> <p>So far we have built an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earthquake application</a> <b>Vermox For Sale</b>, , <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">mapped an address</a> using geocoding, and even <a href="http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/" target="_blank">Prism-fied the Bing Maps WPF control</a>.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can create this application.</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services. </p>  <p>For this application we will be using the Geocode Service and the Route Service.&#160; The Geocode service is used to match addresses, <b>Vermox dangers</b>, <b>Vermox coupon</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>Vermox dose</b>, <b>Vermox dosage</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; The Route service is used to generate routes and driving directions based on locations or waypoints.</p>  <p>Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>Vermox pharmacy</b>.  <b>Cheap Vermox</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>ordering Vermox online</b>.  <b>Vermox from mexico</b>, </p>  <p>Open up your App.xaml. You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca628505-dd3b-4d33-ae53-ad0ea17f81a9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy no prescription Vermox online</b>, <b>Buying Vermox online over the counter</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>We need to add the Geocode and Route service to our application.&#160; First, <b>where can i buy cheapest Vermox online</b>, <b>Low dose Vermox</b>, let’s start by adding the Geocode service.&#160; Right click the project and select “Add Service Reference”.&#160; Use the following address:</p>  <p><a href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name. I called mine BingServices.&#160; Now we need to add the Route service, <b>Vermox steet value</b>, <b>No prescription Vermox online</b>, but we don’t want to add a separate service reference.&#160; Ideally we would have a single service that contained both the Geocode and Route services.&#160; Luckily there is a trick we can use to do just that.&#160; Select the Project and click the “Show All Files” button at the top of the Solution Explorer.&#160; Expand the Service Reference folder and then expand the BingServices service.&#160; Look for a file called <strong>Reference.svcmap</strong>. Open the References.svcmap and locate the MetadataSource node.&#160; It will loko something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e1e98d3-82a4-419a-a32f-707e0559123c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox duration</b>, <b>Order Vermox online overnight delivery no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Simply add a new MetatdataSource as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7291104c-336c-4f44-9a3e-5843babcba3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox schedule</b>, <b>Where can i buy Vermox online</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">2</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see we added a new MetadataSource that points to the Route service and we gave it a SourceId of 2.&#160; Now right click the service and select “Update Service Reference”.&#160; This will generate a single service proxy for both the Geocode and Route services.&#160; Pretty slick huh?</p>  <p>The next step will be to create a ViewModel that will contain an ICommand that will execute the route calculation, <b>Vermox long term</b>, <b>Vermox price</b>, properties that will represent a “To” address and a “From” address.&#160; We will also need a property for the RouteResult and for the directions we generate.&#160; Lets first create our Direction object:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0230a924-5d25-4bed-880a-8b8cca1043e9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox samples</b>, <b>After Vermox</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">Direction</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Description { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">Location</span> Location { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> }</div> </div> </div>  <p>Now we will need a make-shift delegate command (do not use in production code):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:424be6fd-5bed-4501-ac25-33db908058c2" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>doses Vermox work</b>, <b>Is Vermox safe</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span> : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span> _execute;<br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span> execute)<br>     {<br>         _execute = execute;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke();<br>     }<br> }</div> </div> </div>  <p>Now on to the ViewModel itself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d9737cbe-bea9-4b93-af31-534d3ad53cb1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox pics</b>, <b>Vermox pictures</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">RouteViewModel</span>: <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> CalculateRouteCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _from = <span style="color:#a31515">&quot;Meridian, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> From<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _from; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _from = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;From&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _to = <span style="color:#a31515">&quot;Boise, <b>Vermox used for</b>, <b>Online buy Vermox without a prescription</b>, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> To<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _to; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _to = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;To&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">RouteResult</span> _routeResult;<br>     <span style="color:#0000ff">public</span> BingServices.<span style="color:#2b91af">RouteResult</span> RouteResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _routeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _routeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;RouteResult&quot;</span>);<br>         }<br>     }<br>     <br> <br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; _directions;<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; Directions<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _directions; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _directions = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;Directions&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> RouteViewModel()<br>     {<br>         CalculateRouteCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>(CalculateRoute);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute()<br>     {<br>         <span style="color:#0000ff">var</span> from = GeocodeAddress(From);<br>         <span style="color:#0000ff">var</span> to = GeocodeAddress(To);<br> <br>         CalculateRoute(from, to);<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">GeocodeResult</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br>         BingServices.<span style="color:#2b91af">GeocodeResult</span> result = <span style="color:#0000ff">null</span>;<br> <br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Query = address;<br>             result = client.Geocode(request).Results[0];<br>         }<br> <br>         <span style="color:#0000ff">return</span> result;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute(BingServices.<span style="color:#2b91af">GeocodeResult</span> from, <b>online buying Vermox hcl</b>, <b>Vermox reviews</b>, BingServices.<span style="color:#2b91af">GeocodeResult</span> to)<br>     {<br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">RouteServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IRouteService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">RouteRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Waypoints = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;BingServices.<span style="color:#2b91af">Waypoint</span>&gt;();<br>             request.Waypoints.Add(ConvertResultToWayPoint(from));<br>             request.Waypoints.Add(ConvertResultToWayPoint(to));<br> <br>             request.Options = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteOptions</span>();<br>             request.Options.RoutePathType = BingServices.<span style="color:#2b91af">RoutePathType</span>.Points;<br> <br>             RouteResult = client.CalculateRoute(request).Result;<br>         }<br> <br>         GetDirections();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GetDirections()<br>     {<br>         Directions = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt;();<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">ItineraryItem</span> item <span style="color:#0000ff">in</span> RouteResult.Legs[0].Itinerary)<br>         {<br>             <span style="color:#0000ff">var</span> direction = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Direction</span>();<br>             direction.Description = GetDirectionText(item);<br>             direction.Location = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(item.Location.Latitude, item.Location.Longitude);<br>             Directions.Add(direction);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">string</span> GetDirectionText(BingServices.<span style="color:#2b91af">ItineraryItem</span> item)<br>     {<br>         <span style="color:#0000ff">string</span> contentString = item.Text;<br>         <span style="color:#008000">//Remove tags from the string</span><br>         <span style="color:#2b91af">Regex</span> regex = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Regex</span>(<span style="color:#a31515">&quot;&lt;(.|&#92;n)*?&gt;&quot;</span>);<br>         contentString = regex.Replace(contentString, <b>purchase Vermox for sale</b>, <b>Vermox results</b>, <span style="color:#0000ff">string</span>.Empty);<br>         <span style="color:#0000ff">return</span> contentString;<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">Waypoint</span> ConvertResultToWayPoint(BingServices.<span style="color:#2b91af">GeocodeResult</span> result)<br>     {<br>         BingServices.<span style="color:#2b91af">Waypoint</span> waypoint = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">Waypoint</span>();<br>         waypoint.Description = result.DisplayName;<br>         waypoint.Location = result.Locations[0];<br>         <span style="color:#0000ff">return</span> waypoint;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>Let’s walk though the CalculateRoute Method.&#160; First we geocode the “From” and “To” properties the same way we did in the <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">geocoding post</a>.&#160; Once we have our From and To locations we use those results to generate a RouteRequest and send that request to the Route service.&#160; The service will generate a result and we set our RouteResult property accordingly.&#160; This property will be used in data binding shortly.&#160; Next we generate an ObservableCollection&lt;Direction&gt; by looping through all the ItineraryItems in the result.&#160; </p>  <p>Now that we have generate all of our data, <b>online buying Vermox</b>, <b>Vermox forum</b>, we need to create a View that supports and displays this data, but before we do that we need to create some attached properties.&#160; Why do you ask?&#160; Well because as it stands, <b>Vermox online cod</b>, <b>Vermox no prescription</b>, the Bing Maps WPF control is not data binding friendly.&#160; So we need to enable data binding with the use of attached properties.&#160; We will need an attached property for the Route result which will be responsible for drawing the route line on the map.&#160; We will also need one for the MapLayer that will be used to contain the route line.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55925f26-554d-4793-8b07-532984d855c6" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>order Vermox from United States pharmacy</b>, <b>Vermox australia, uk, us, usa</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> RouteResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteResult&quot;</span>, <span style="color:#0000ff">typeof</span>(BingServices.<span style="color:#2b91af">RouteResult</span>), <b>Vermox gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Vermox overnight</b>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingServices.<span style="color:#2b91af">RouteResult</span> GetRouteResult(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingServices.<span style="color:#2b91af">RouteResult</span>)target.GetValue(RouteResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteResult(<span style="color:#2b91af">DependencyObject</span> target, BingServices.<span style="color:#2b91af">RouteResult</span> value)<br>     {<br>         target.SetValue(RouteResultProperty, value);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteResultChanged((<span style="color:#2b91af">Map</span>)o, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.OldValue, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.NewValue);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">Map</span> map, BingServices.<span style="color:#2b91af">RouteResult</span> oldValue, BingServices.<span style="color:#2b91af">RouteResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">MapPolyline</span> routeLine = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapPolyline</span>();<br>         routeLine.Locations = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationCollection</span>();<br>         routeLine.Opacity = 0.65;<br>         routeLine.Stroke = <span style="color:#0000ff">new</span> <span style="color:#2b91af">SolidColorBrush</span>(<span style="color:#2b91af">Colors</span>.Blue);<br>         routeLine.StrokeThickness = 5.0;<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">Location</span> loc <span style="color:#0000ff">in</span> newValue.RoutePath.Points)<br>         {<br>             routeLine.Locations.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(loc.Latitude, loc.Longitude));<br>         }<br> <br>         <span style="color:#0000ff">var</span> routeLineLayer = GetRouteLineLayer(map);<br>         <span style="color:#0000ff">if</span> (routeLineLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             routeLineLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetRouteLineLayer(map, routeLineLayer);<br>         }<br> <br>         routeLineLayer.Children.Clear();<br>         routeLineLayer.Children.Add(routeLine);<br> <br>         <span style="color:#008000">//Set the map view</span><br>         <span style="color:#2b91af">LocationRect</span> rect = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationRect</span>(routeLine.Locations[0], routeLine.Locations[routeLine.Locations.Count - 1]);<br>         map.SetView(rect);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteResult</span><br> <br>     <span style="color:#0000ff">#region</span> RouteLineLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteLineLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteLineLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteLineLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(RouteLineLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(RouteLineLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteLineLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         <span style="color:#0000ff">if</span> (!map.Children.Contains(newValue))<br>             map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteLineLayer</span><br> }</div> </div> </div>  <p>The RouteResult property simply creates a MapPolyline, loops through all the points in the result and adds the locations to the route line.&#160; It then gets the RouteLineLayer and adds it to the map.&#160; Lastly, it sets the map’s view to best fit the route line.</p>  <p>Now we are ready for the View:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:393d6882-6c78-48e8-9046-d517df235427" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">core</span><span style="color:#0000ff">=&quot;clr-namespace:BingMapsCalculateRouteDemo.Core&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;RouteTemplate&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Ellipse</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Fill</span><span style="color:#0000ff">=&quot;Red&quot;</span><span style="color:#ff0000"> Opacity</span><span style="color:#0000ff">=&quot;0.8&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.Position</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Location}</span><span style="color:#0000ff">&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.PositionOrigin</span><span style="color:#0000ff">=&quot;Center&quot;</span><br>                     <span style="color:#ff0000"> Tag</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding}</span><span style="color:#0000ff">&quot;</span><br>                     <span style="color:#ff0000"> MouseEnter</span><span style="color:#0000ff">=&quot;Route_MouseEnter&quot;</span> <br>                     <span style="color:#ff0000"> MouseLeave</span><span style="color:#0000ff">=&quot;Route_MouseLeave&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;150&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> From}</span><span style="color:#0000ff">&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> To}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Get Route&quot;</span><span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CalculateRouteCommand}</span><span style="color:#0000ff">&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=&quot;AerialWithLabels&quot;</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> VerticalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> RouteResult}</span><span style="color:#0000ff">&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteLineLayer</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ElementName</span><span style="color:#0000ff">=RouteLineLayer}&quot;</span><br>                  <span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot; &gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;RouteLineLayer&quot; /&gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapItemsControl</span><span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Directions}</span><span style="color:#0000ff">&quot;</span><br>                                      <span style="color:#ff0000"> ItemTemplate</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> RouteTemplate}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br> <br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupLayer&quot;&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopup&quot;</span><span style="color:#ff0000"> Visibility</span><span style="color:#0000ff">=&quot;Collapsed&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;15&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupText&quot;</span><span style="color:#ff0000"> FontSize</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> FontWeight</span><span style="color:#0000ff">=&quot;Bold&quot;</span><span style="color:#ff0000"> TextWrapping</span><span style="color:#0000ff">=&quot;Wrap&quot; /&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Oh and don’t forget the code behind:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:14f2277a-a347-48e8-afd6-41465898d7fe" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">partial</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span><br> {<br>     <span style="color:#0000ff">public</span> MainWindow()<br>     {<br>         InitializeComponent();<br>         DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">RouteViewModel</span>();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseEnter(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         <span style="color:#2b91af">FrameworkElement</span> pin = sender <span style="color:#0000ff">as</span> <span style="color:#2b91af">FrameworkElement</span>;<br>         <span style="color:#2b91af">MapLayer</span>.SetPosition(ContentPopup, <span style="color:#2b91af">MapLayer</span>.GetPosition(pin));<br>         <span style="color:#2b91af">MapLayer</span>.SetPositionOffset(ContentPopup, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Point</span>(20, -15));<br> <br>         <span style="color:#0000ff">var</span> location = (<span style="color:#2b91af">Direction</span>)pin.Tag;<br> <br>         ContentPopupText.Text = location.Description;<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Visible;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseLeave(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Collapsed;<br>     }<br> }</div> </div> </div>  <p>Now let’s view the fruits of our labor at runtime.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/09/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/09/image_thumb.png" width="644" height="453" /></a></p>  <p>As you can see, given a “From” and “To” address, we can draw a route line and provide turn-by-turn directions as the user hovers over the direction pins.&#160; Pretty neat huh?&#160; And it wasn’t too difficult to pull off.&#160; As always you can <a href="http://www.brianlagunas.com/downloads/source/BingMapsCalculateRouteDemo.zip">Download the Source</a> and start playing.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4306'>Buy Biaxin Without Prescription</a>. <a href='http://elegantcode.com/?p=4228'>Aricept For Sale</a>. <a href='http://elegantcode.com/?p=4340'>Atarax For Sale</a>. <a href='http://elegantcode.com/?p=5052'>Lotrisone For Sale</a>. <a href='http://elegantcode.com/?p=4407'>Buy Nexium Without Prescription</a>. <a href='http://elegantcode.com/?p=4873'>Cafergot treatment</a>. <a href='http://elegantcode.com/?p=4780'>Canada, mexico, india</a>. <a href='http://elegantcode.com/?p=4202'>Online buying Celexa</a>. <a href='http://elegantcode.com/?p=4335'>Fast shipping Differin</a>. <a href='http://elegantcode.com/?p=4205'>Purchase Allopurinol online no prescription</a>.<br />
<b>Trackbacks from:</b> <a href='http://linuxologist.com/?p=193'>Vermox For Sale</a>. <a href='http://blog.farmland.org/?p=3110'>Vermox For Sale</a>. <a href='http://home.officesnapshots.com/?p=122'>Vermox For Sale</a>. <a href='http://reversemortgagedaily.com/?p=14171'>Vermox For Sale</a>. <a href='http://social-blend.com/?p=495'>Vermox For Sale</a>. <a href='http://www.themusclecarplace.com/?p=3175'>Vermox for sale</a>. <a href='http://www.thegriffonnews.com/?p=10415'>Ordering Vermox online</a>. <a href='http://www.quarterlives.com/?p=743'>Order Vermox online c.o.d</a>. <a href='http://tayloegray.com/?p=351'>Vermox from mexico</a>. <a href='http://www.greatgreengoods.com/?p=3949'>Purchase Vermox for sale</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buy Female Pink Viagra Without Prescription</title>
		<link>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prism-fy-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 16:13:02 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[prism]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been playing around with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled [...]]]></description>
			<content:encoded><![CDATA[<p> <p>If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">playing</a> <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">around</a> with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled MapLayers at runtime using Prism.</p>  <p> <b>Buy Female Pink Viagra Without Prescription</b>, The concept is simple.&#160; We want a Bing Maps application that can be extended at runtime.&#160; By extended, I mean that I want the ability to add new elements/modules to the Map at runtime.&#160; The important thing about these elements/modules is that they can come from anywhere and they should be loosely coupled from the Map as well as other elements/modules that may exist on the Map.</p>  <p>Luckily for us this is extremely simple to accomplish.&#160; All we have to do is create a custom RegionAdapter, register it with our Prism application, and then apply it to our Bing Map control.&#160; So let’s start with the RegionAdapter.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8809704-1b89-4479-9f50-32a29a8ce6e3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapRegionAdapter</span> : <span style="color:#2b91af">RegionAdapterBase</span>&lt;<span style="color:#2b91af">Map</span>&gt;<br> {<br>     <span style="color:#0000ff">public</span> MapRegionAdapter(<span style="color:#2b91af">IRegionBehaviorFactory</span> regionBehaviorFactory)<br>         : <span style="color:#0000ff">base</span>(regionBehaviorFactory)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> Adapt(<span style="color:#2b91af">IRegion</span> region, <span style="color:#2b91af">Map</span> regionTarget)<br>     {<br>         region.Views.CollectionChanged += (s, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Add)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.NewItems)<br>                     regionTarget.Children.Add(element);<br>             }<br>             <span style="color:#0000ff">else</span> <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Remove)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.OldItems)<br>                     <span style="color:#0000ff">if</span> (regionTarget.Children.Contains(element))<br>                         regionTarget.Children.Remove(element);<br>             }<br>         };<br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">IRegion</span> CreateRegion()<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">AllActiveRegion</span>();<br>     }<br> }</div> </div> </div> </p>  <p>Now in the Bootstrapper we need to register our mapping.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fce11974-ec82-4641-ac5c-a37a9ff443df" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">RegionAdapterMappings</span> ConfigureRegionAdapterMappings()<br> {<br>     <span style="color:#2b91af">RegionAdapterMappings</span> mappings = <span style="color:#0000ff">base</span>.ConfigureRegionAdapterMappings();<br>     mappings.RegisterMapping(<span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Map</span>), Container.Resolve&lt;<span style="color:#2b91af">MapRegionAdapter</span>&gt;());<br>     <span style="color:#0000ff">return</span> mappings;<br> }</div> </div> </div> </p>  <p>Now we simply give the Map a region name. (this is actually all the shell has in it)</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a72303d9-120c-4bba-a39e-18ae1979a63a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>online Female Pink Viagra without a prescription</b>, <b>Female Pink Viagra forum</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> prism</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionManager.RegionName</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Static</span><span style="color:#ff0000"> inf</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionNames</span><span style="color:#0000ff">.MapRegion}&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40, <b>order Female Pink Viagra online overnight delivery no prescription</b>, <b>Low dose Female Pink Viagra</b>, -95&quot;</span><span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot; /&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div> </p>  <p>That is all there is to it.&#160; You can now start injecting modules onto the Map at runtime.&#160; Lets look at my two modules I am using as an example.&#160; Here is the structure of my application:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb13.png" width="305" height="190" /></a></p>  <ul>   <li>ModuleA will inject a MapPolygon in the Shape of Texas.</li>    <li>ModuleB is the Earthquake application we built in an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earlier post</a>.</li>    <li>Infrastructure is the project where shared code goes, in this case our MapRegionAdapter</li>    <li>BingMapsPrismfiedDemo is of course our shell project.</li> </ul>  <p>This is what the application looks like at runtime when both modules have been injected into it.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb14.png" width="644" height="334" /></a></p>  <p>Now I can easily add more layers to this map as I see fit.&#160; As always, <b>online buy Female Pink Viagra without a prescription</b>, <b>No prescription Female Pink Viagra online</b>, <a href="http://www.brianlagunas.com/downloads/source/BingMapsPrismfiedDemo.zip">Download the Source</a> and start playing.&#160; You may want to add MEF support as well.</p>.  Where can i find Female Pink Viagra online.  Effects of Female Pink Viagra.  Purchase Female Pink Viagra.  Female Pink Viagra over the counter.  Purchase Female Pink Viagra online.  Buy Female Pink Viagra without prescription.  Female Pink Viagra recreational.  Buy generic Female Pink Viagra.  Cheap Female Pink Viagra.  Female Pink Viagra no prescription.  Female Pink Viagra wiki.  Cheap Female Pink Viagra no rx.  Female Pink Viagra canada, mexico, india.  Buying Female Pink Viagra online over the counter.  Where to buy Female Pink Viagra.  Female Pink Viagra cost.  Female Pink Viagra from mexico.  Is Female Pink Viagra safe.  Buy Female Pink Viagra online cod.  Buy Female Pink Viagra from mexico.  Where can i order Female Pink Viagra without prescription.  Real brand Female Pink Viagra online.  Buy Female Pink Viagra from canada.  Female Pink Viagra overnight.  Female Pink Viagra use.  Order Female Pink Viagra from mexican pharmacy.  Female Pink Viagra street price.  Female Pink Viagra coupon.  Female Pink Viagra schedule.  Female Pink Viagra mg.  Female Pink Viagra interactions.  Taking Female Pink Viagra.  Female Pink Viagra used for.  Is Female Pink Viagra addictive.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4750'>Celebrex For Sale</a>. <a href='http://elegantcode.com/?p=4661'>Buy Methotrexate Without Prescription</a>. <a href='http://elegantcode.com/?p=4755'>Buy Zovirax Without Prescription</a>. <a href='http://elegantcode.com/?p=4311'>Buy Topamax Without Prescription</a>. <a href='http://elegantcode.com/?p=4476'>Modalert For Sale</a>. <a href='http://elegantcode.com/?p=4671'>Buy Quinine no prescription</a>. <a href='http://elegantcode.com/?p=4643'>Premarin duration</a>. <a href='http://elegantcode.com/?p=4340'>Purchase Atarax for sale</a>. <a href='http://elegantcode.com/?p=4732'>Abilify price</a>. <a href='http://elegantcode.com/?p=4373'>No prescription Topamax online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.thegriffonnews.com/?p=10565'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5050'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://changecamp.ca/?p=593'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://linuxologist.com/?p=450'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://blog.farmland.org/?p=1496'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.quarterlives.com/?p=930'>Female Pink Viagra brand name</a>. <a href='http://www.greatgreengoods.com/?p=3683'>Discount Female Pink Viagra</a>. <a href='http://www.macneilbmx.com/blog/?p=4935'>Female Pink Viagra pics</a>. <a href='http://social-blend.com/?p=671'>Female Pink Viagra results</a>. <a href='http://4realz.net/?p=847'>Female Pink Viagra pics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Buy Tindamax Without Prescription</title>
		<link>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-an-address-with-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:21:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[In my last post Buy Tindamax Without Prescription, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate [...]]]></description>
			<content:encoded><![CDATA[<p> <p>In my last <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">post</a> <b>Buy Tindamax Without Prescription</b>, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate maps and imagery, driving directions, distance calculations, and other location intelligence into your applications, business processes, and Web sites. </p>  <p>Let’s start with the Geocode Service which is used to match addresses, <b>buy cheap Tindamax</b>, <b>Purchase Tindamax for sale</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>my Tindamax experience</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; We will create a simple application that allows you to enter an address and place a pushpin at that location.&#160; First thing is first:</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165" target="_blank">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/" target="_blank">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services.&#160; Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>order Tindamax from United States pharmacy</b>.  <b>Online buying Tindamax</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>buy Tindamax without a prescription</b>.  <b>After Tindamax</b>, </p>  <p>Open up your App.xaml.&#160; You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c7fbbfb-a6ac-496d-a298-bddbd655ac65" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>discount Tindamax</b>, <b>Buy Tindamax no prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Now create a very simple UI that will accept an address and a button to perform the geocoding:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc9a874e-765b-4bc2-b82b-88a96f1ef84c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax treatment</b>, <b>Tindamax no rx</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>                  <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>The next thing we need to do is add a new Service Reference to the project and point to the following service:</p>  <p><a title="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc" href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name (I called mine BingMapsService) and just for fun, <b>buy Tindamax online cod</b>, <b>Generic Tindamax</b>, in the “Add Service Reference” dialog, click the “Advanced” button and click “Generate asynchronous operations”.</p>  <p>Next we need to create a ViewModel to support our View.&#160; This is a WPF application after all.&#160; This ViewModel will need a command for the button that will perform the geocoding, <b>Tindamax duration</b>, <b>Low dose Tindamax</b>, and a property that will represent the result of the service that the UI will use to map the address.&#160; It should resemble something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b09cd91-31d1-426f-a539-9fe004a3702a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax street price</b>, <b>Tindamax blogs</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">GeocodeViewModel</span> : <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> GeocodeAddressCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> _geocodeResult;<br>     <span style="color:#0000ff">public</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GeocodeResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _geocodeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _geocodeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> GeocodeViewModel()<br>     {<br>         GeocodeAddressCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>&lt;<span style="color:#2b91af">String</span>&gt;(GeocodeAddress);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>I want to point out that the DelegateCommand&lt;T&gt; is a very simple ICommand implementation and should NOT be used in production applications.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cac2fd6-5f40-4d30-b70e-39cf0eb39d77" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax wiki</b>, <b>Tindamax cost</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span>&lt;T&gt; : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span>&lt;T&gt; _execute;<br> <br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span>&lt;T&gt; execute)<br>     {<br>         _execute = execute;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke((T)parameter);<br>     }<br> }</div> </div> </div>  <p>Let’s hook our UI up to our command.&#160; it should look something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f154da3-e1a9-48e1-8dcd-53063e2268ec" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax overnight</b>, <b>Online buy Tindamax without a prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;</span> <br>                    <span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeAddressCommand}</span><span style="color:#0000ff">&quot;</span><br>                    <span style="color:#ff0000"> CommandParameter</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">, <b>where can i buy Tindamax online</b>, <b>Discount Tindamax</b>, </span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=</span>_<span style="color:#0000ff">txtAddress}&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Notice that we are using the text of the TextBox as the CommandParameter.&#160; Next, we need to implement the command:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0d2006e3-d7cf-483a-b57b-284d06ecffff" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax for sale</b>, <b>Tindamax used for</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br> {<br>     <span style="color:#0000ff">using</span> (BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>     {<br>         client.GeocodeCompleted += (o, <b>buy no prescription Tindamax online</b>, <b>Tindamax online cod</b>, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Error == <span style="color:#0000ff">null</span>)<br>             {<br>                 GeocodeResult = e.Result.Results[0];<br>             }<br>         };<br> <br>         BingMapsService.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeRequest</span>();<br>         request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>         request.Query = address;<br>         client.GeocodeAsync(request);<br>     }<br> }</div> </div> </div>  <p>In this command we are simply creating an instance of the service client, creating a GeocodeRequest, <b>Tindamax coupon</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, setting the credentials using the ApplicationId we have stored in the App.xaml, and then using the address as the Query for the request.&#160; When the call to the service is completed we are setting the GeocodeResult property to the first element in the results.</p>  <p>Now the tricky part.&#160; We want to place a Pushpin on the address that was entered and then move the map to that location.&#160; We also need to make sure that when another address is entered, <b>buying Tindamax online over the counter</b>, <b>Is Tindamax safe</b>, we clear any previous Pushpins that may exist on the map.&#160; We also have to be aware that other elements my be on the map and we don’t want to accidentally alter those elements.&#160; Oh and did I mention this was an MVVM application and this has to be done with just data binding. </p>  <p>The approach that I decided to go with is to use <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" target="_blank">Attached Properties</a>.&#160; So I created two attached properties; one for the GeocodeResult and another for a MapLayer that will be dedicated to the GeocodeResult.&#160; This will allow us to create a MapLayer that is specific to our GeocodeResut and not alter any other elements that may be on the map.&#160; Let’s check out the code.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3cc3f4e4-cbae-4ffe-93bf-4a10f2e36d08" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>herbal Tindamax</b>, <b>Tindamax price, coupon</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> GeocodeResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>, <b>buy Tindamax without a prescription</b>, <b>Buy Tindamax without prescription</b>, <span style="color:#0000ff">typeof</span>(BingMapsService.<span style="color:#2b91af">GeocodeResult</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <b>cheap Tindamax</b>, <b>Tindamax trusted pharmacy reviews</b>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GetGeocodeResult(<span style="color:#2b91af">Map</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)target.GetValue(GeocodeResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResult(<span style="color:#2b91af">Map</span> target, <b>ordering Tindamax online</b>, <b>Tindamax canada, mexico, india</b>, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> value)<br>     {<br>         target.SetValue(GeocodeResultProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultChanged((<span style="color:#2b91af">Map</span>)o, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.OldValue, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">Map</span> map, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> oldValue, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">Location</span> location = newValue.Locations.Select(x =&gt; <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(x.Latitude, x.Longitude)).First();<br> <br>         <span style="color:#2b91af">Pushpin</span> pin = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Pushpin</span>();<br>         pin.Location = location;<br>         pin.ToolTip = newValue.Address.FormattedAddress;<br> <br>         <span style="color:#0000ff">var</span> locationLayer = GetGeocodeResultLayer(map);<br>         <span style="color:#0000ff">if</span> (locationLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             locationLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetGeocodeResultLayer(map, locationLayer);<br>         }<br> <br>         locationLayer.Children.Clear();<br>         locationLayer.Children.Add(pin);<br> <br>         map.SetView(location, map.ZoomLevel);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResult</span><br> <br>     <span style="color:#0000ff">#region</span> GeocodeResultLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResultLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(GeocodeResultLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(GeocodeResultLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResultLayer</span><br> }</div> </div> </div>  <p>Notice that when the GeocodeResult changes we get the Location and create a pushpin for that location.&#160; We also set the tooltip to the FormattedAddress of the GeocodeResult.&#160; So when we hover over the pushpin we will see a nice little tooltip of the address.&#160; Next we try to get the GeocodeResultLayer from the map, if it is null this means it doesn’t exist on the map yet so we create one and assign it accordingly.&#160; We clear the layer child elemnts and then add out pushpin.&#160; The last thing we do is call the SetView method of the Map control passing in the location and the current ZoomLevel.</p>  <p>The final step is to use our AttachedProperty on the map.&#160; Be sure to create a namespace for the MapInteractivity class and define it as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72d6307a-aef3-4f70-8d47-8d4529fc74e0" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>          <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.GeocodeResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeResult}</span><span style="color:#0000ff">&quot;</span><br>          <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>One last thing.&#160; Be sure to remember to set your DataContext of your View to the ViewModel we have created:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f7d0b4f-e096-487d-8343-fb42c94c3360" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> MainWindow()<br> {<br>     InitializeComponent();<br>     DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">GeocodeViewModel</span>(); <br> }</div> </div> </div>  <p>That’s it.&#160; You now have an application the can map (geocode) an address using the Bing Maps WPF Control and the Geocoding SOAP Service.&#160; Oh and we are doing this all with MVVM and data binding which is my favorite part.&#160; Be sure to <a href="http://www.brianlagunas.com/downloads/source/bingmapsgeocodedemo.zip">Download the Source</a> and start playing around.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4746'>Buy Clindamycin Gel Without Prescription</a>. <a href='http://elegantcode.com/?p=4328'>Buy Plavix Without Prescription</a>. <a href='http://elegantcode.com/?p=4302'>Buy Phenergan Without Prescription</a>. <a href='http://elegantcode.com/?p=4460'>Buy Proscar Without Prescription</a>. <a href='http://elegantcode.com/?p=4607'>Triamterene For Sale</a>. <a href='http://elegantcode.com/?p=4751'>Diflucan street price</a>. <a href='http://elegantcode.com/?p=4372'>Nexium steet value</a>. <a href='http://elegantcode.com/?p=4475'>Metronidazole Gel from mexico</a>. <a href='http://elegantcode.com/?p=4399'>Herbal Periactin</a>. <a href='http://elegantcode.com/?p=4858'>Tramadol over the counter</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.macneilbmx.com/blog/?p=6683'>Buy Tindamax Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=3313'>Buy Tindamax Without Prescription</a>. <a href='http://www.thegriffonnews.com/?p=9133'>Buy Tindamax Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5330'>Buy Tindamax Without Prescription</a>. <a href='http://changecamp.ca/?p=592'>Buy Tindamax Without Prescription</a>. <a href='http://social-blend.com/?p=444'>Tindamax online cod</a>. <a href='http://blog.farmland.org/?p=3958'>Order Tindamax from mexican pharmacy</a>. <a href='http://4realz.net/?p=717'>Tindamax forum</a>. <a href='http://reversemortgagedaily.com/?p=14265'>Tindamax trusted pharmacy reviews</a>. <a href='http://linuxologist.com/?p=1542'>Tindamax online cod</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &#8211; dynamically compile and run event handlers within loose XAML using CodeDom</title>
		<link>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom</link>
		<comments>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:37:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[dynamic code]]></category>
		<category><![CDATA[wpd]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/</guid>
		<description><![CDATA[Last week I wrote a blog post showing how you can write inline code in XAML.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon re-tweeted that post with a link to one of his own posts on exploring new techniques for DLR script in XAML which also links [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a blog post showing how <a href="http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/" target="_blank">you can write inline code in XAML</a>.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon <a href="http://twitter.com/#!/rrelyea/status/15099827364827136" target="_blank">re-tweeted</a> that post with a link to one of his own posts on <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/11/14/exploring-new-techniques-for-dlr-script-in-xaml.aspx" target="_blank">exploring new techniques for DLR script in XAML</a> which also links to another one of his posts which shows different techniques for <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/06/03/xaml-events-in-compiled-and-uncompiled-scenarios.aspx" target="_blank">hooking up events in compiled and uncompiled scenarios</a> which in turn links to <a href="http://www.thinkbottomup.com.au/site/blog/Embedding_DLR_Scripts_in_XAML_Part_1" target="_blank">this post about embedding DLR scripts in XAML</a> written by Daniel Paull.&#160; Wow, that is a lot of linking.</p>  <p>Well, now that everyone has been given their respective credit, let’s continue.&#160; I wanted to take my last post a little further.&#160; In that post I simply created an event handler for a button click event using inline code in the x:Code directive.&#160; If you started to play with the sample code, you might have thought to yourself, “I wonder if I can load this XAML, event handler and all, from a file or database and have it still work.”.&#160; Well, if you tried it, you found the answer really quick.&#160; No!&#160; The reason is pretty simple; code must be compiled in order to execute.&#160; Therefore any code inside loose XAML will fail.&#160; Also, when using loose XAML, trying to hookup an event handler would crash your application because it is not allowed.</p>  <p>Oh, then it must not be possible? Wrong!&#160; Well, then how do you do it if the code must be compiled?&#160; Simple, we compile the code just before we run it.&#160; Say what?&#160; That’s right, let me introduce you to the <a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" target="_blank">CodeDom</a>.&#160; The CodeDom allows you to dynamically generate and compile code at runtime.&#160; Let’s get to it.</p>  <p>We need to attach event handlers to elements in loose XAML, and have them execute C# code.&#160; Each element has different events to handle, and each event will execute different code.&#160; This tells me that we need an object that contains two properties, one to specify the RoutedEvent to handle, and another to specify the c# code to execute.&#160; We also need a common event handler definition to execute whenever the RoutedEvent is invoked.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c257533-76d5-4e97-9754-1b389f8f52b5" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DynamicEvent</span><br> {<br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the routed event to execute.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The routed event.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">RoutedEvent</span> RoutedEvent { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the script to run when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The script.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Script { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Called when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br>     {<br>         <br>     }<br> }</div> </div> </div>  <p>That was simple enough.&#160; Now, in order to attach event handlers to elements in loose XAML, we need away to get around the “no event handlers allowed” limitation.&#160; To do this we can use an attached property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c6021e-2311-4633-85f8-8fcb27a9cb89" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> HandlerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;Handler&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(OnHandlerChanged));<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DynamicEvent</span> GetHandler(<span style="color:#2b91af">DependencyObject</span> obj)<br> {<br>     <span style="color:#0000ff">return</span> (<span style="color:#2b91af">DynamicEvent</span>)obj.GetValue(HandlerProperty);<br> }<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetHandler(<span style="color:#2b91af">DependencyObject</span> obj, <span style="color:#0000ff">bool</span> value)<br> {<br>     obj.SetValue(HandlerProperty, value);<br> }<br> <br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnHandlerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">UIElement</span> uie = o <span style="color:#0000ff">as</span> <span style="color:#2b91af">UIElement</span>;<br>     <span style="color:#0000ff">if</span> (uie == <span style="color:#0000ff">null</span>)<br>         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">Exception</span>(<span style="color:#a31515">&quot;Attempt to set EventHandler on non-UIElement Type&quot;</span>);<br> <br>     <span style="color:#2b91af">DynamicEvent</span> oldHandler = e.OldValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br>     <span style="color:#2b91af">DynamicEvent</span> newHandler = e.NewValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br> <br>     <span style="color:#008000">// unhook the old event</span><br>     <span style="color:#0000ff">if</span> (oldHandler != <span style="color:#0000ff">null</span>)<br>         uie.RemoveHandler(oldHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(oldHandler.OnEventExecuted));<br> <br>     <span style="color:#008000">// hook up the new</span><br>     <span style="color:#0000ff">if</span> (newHandler != <span style="color:#0000ff">null</span>)<br>         uie.AddHandler(newHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(newHandler.OnEventExecuted));<br> <br> }</div> </div> </div>  <p>This attached property allows use to attach an instance of our DynamicEvent class to our element.&#160; When the Handler attached property is set, we simple add our OnEventExecute event handler to the RoutedEvent specified in the RoutedEvent property.&#160; Now we have the basic framework needed to attach and event handler to any event on any element in loose XAML.&#160; Let’s see how to attach an event handler in XAML using this newly created DynamicEvent class.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c323adca-e880-4dd4-997e-958bccc70c3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Initial Text&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#ff0000"> RoutedEvent</span><span style="color:#0000ff">=&quot;Button.Click&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#ff0000"> xml</span><span style="color:#0000ff">:</span><span style="color:#ff0000">space</span><span style="color:#0000ff">=&quot;preserve&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>                         <span style="color:#808080">var button = sender as Button;</span><br>                         <span style="color:#808080">button.Content = &quot;Changed with Dynamic Code&quot;;</span><br>                         <span style="color:#808080">]]&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Button</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see I have added a handler for a Button’s Click event.&#160; I also provided a Script to execute when the event is invoked.&#160; Notice that we are preserving the whitespace in the script.&#160; Of course nothing will happen just yet.&#160; Now we need to take the script and compile it at run time.&#160; This is where the CodeDom comes in.</p>  <p>The steps necessary to compile code at run time go a little something like this:</p>  <ul>   <li>Create a CodeCompileUnit </li>    <li>Add our namespace and import statements </li>    <li>create our dynamic class </li>    <li>add a method that will execute the Script </li>    <li>compile the code </li>    <li>execute the code </li> </ul>  <p>All these steps must be performed when the ROutedEvent is invoked, which means the code must be compiled inside the OnEventExecuted event handler.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56b1a794-ec6b-4976-9f18-e819f5a52641" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">CodeCompileUnit</span> compileUnit = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeCompileUnit</span>();<br> <br>     <span style="color:#008000">//create our namesapce and import statements, then add it to the compile unit</span><br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = CreateNamespaceAndImports();<br>     compileUnit.Namespaces.Add(namespaces);<br> <br>     <span style="color:#008000">//create our target class and add it to the namespace</span><br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = CreateTargetClass();<br>     namespaces.Types.Add(targetClass);<br> <br>     <span style="color:#008000">//create the ExecuteScript method and then add it to our class</span><br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = CreateExecuteScriptMethod();<br>     targetClass.Members.Add(executeEventMethod);<br> <br>     <span style="color:#008000">//create our compiler parameters</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = CreateCompilerParameters();<br> <br>     <span style="color:#008000">//compile the assembly</span><br>     <span style="color:#0000ff">var</span> results = CompileAssembly(compileUnit, compilerParams);<br> <br>     <span style="color:#008000">//execute the code</span><br>     ExecuteCode(results, sender, e);<br> }</div> </div> </div>  <p>The first step is really easy.&#160; We simply need to create an instance of the CodeCompileUnit class.&#160; The CodeCompileUnit references the CodeDom object graph and has properties for storing attributes, namespaces, and assemblies.&#160; Next we need to create our namespace and import statements.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b89b170-e94b-4b3b-a8d8-8df82193e6d3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the namespace and imports.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;remarks&gt;</span><span style="color:#008000">I have only added three import statements as an example. You should add all import statements required to run your dynamic code</span><span style="color:#808080">&lt;/remarks&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeNamespace</span> CreateNamespaceAndImports()<br> {<br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespace</span>(<span style="color:#a31515">&quot;WPFCodeInjection&quot;</span>);<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows.Controls&quot;</span>));<br>     <span style="color:#0000ff">return</span> namespaces;<br> }</div> </div> </div>  <p>Once the namespace and import statement are created we need to add them to out CodeCompileUnit instance.&#160; Then we need to create our dynamic class.&#160; We need to make sure it is a public class:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a495da08-da32-46e0-ba99-c5fac5d189e1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the target class.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeTypeDeclaration</span> CreateTargetClass()<br> {<br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeTypeDeclaration</span>(<span style="color:#a31515">&quot;DynamicClass&quot;</span>);<br>     targetClass.TypeAttributes = <span style="color:#2b91af">TypeAttributes</span>.Public;<br>     <span style="color:#0000ff">return</span> targetClass;<br> }</div> </div> </div>  <p>When the dynamic class is created we add it to our namespace.&#160; Now we create a method. We give it a name of ExecuteScript and set its access modifier to public.&#160; We specify that it accepts two parameters.&#160; One being the sender which is of type object, and one that is the event args that is of type RoutedEventArgs.&#160; Lastly, we set the body of the method to the Script property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4cae0858-7130-4df1-b3b1-cf49063a4d50" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the ExecuteScript method.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#2b91af">CodeMemberMethod</span> CreateExecuteScriptMethod()<br> {<br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeMemberMethod</span>();<br>     executeEventMethod.Name = <span style="color:#a31515">&quot;ExecuteScript&quot;</span>;<br>     executeEventMethod.Attributes = <span style="color:#2b91af">MemberAttributes</span>.Public | <span style="color:#2b91af">MemberAttributes</span>.Final;<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Object&quot;</span>, <span style="color:#a31515">&quot;sender&quot;</span>));<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Windows.RoutedEventArgs&quot;</span>, <span style="color:#a31515">&quot;e&quot;</span>));<br>     executeEventMethod.Statements.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeSnippetStatement</span>(Script));<br>     <span style="color:#0000ff">return</span> executeEventMethod;<br> }</div> </div> </div>  <p>Now we have to create our compiler parameters.&#160; These include adding referencing to the necessary Dlls required to run your code.&#160; We also want to specify that we want to generate the code in memory.&#160; If you wanted to you could save the assembly to a file.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cebbac90-1864-436d-8248-de681876fa83" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the compiler parameters.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerParameters</span> CreateCompilerParameters()<br> {<br>     <span style="color:#008000">//add compiler parameters and assembly references</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CompilerParameters</span>();<br>     compilerParams.CompilerOptions = <span style="color:#a31515">&quot;/target:library /optimize&quot;</span>;<br>     compilerParams.GenerateExecutable = <span style="color:#0000ff">false</span>;<br>     compilerParams.GenerateInMemory = <span style="color:#0000ff">true</span>;<br> <br>     <span style="color:#008000">//you can add references individually if you want by providing the location of the assembly</span><br>     <span style="color:#008000">//compilerParams.ReferencedAssemblies.Add(&quot;System.dll&quot;);</span><br> <br>     <span style="color:#008000">//I am lazy so I will just loop through the assemblies that are already loaded and add those</span><br>     <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Assembly</span> assembly <span style="color:#0000ff">in</span> <span style="color:#2b91af">AppDomain</span>.CurrentDomain.GetAssemblies())<br>     {<br>         <span style="color:#0000ff">try</span><br>         {<br>             <span style="color:#0000ff">string</span> location = assembly.Location;<br>             <span style="color:#0000ff">if</span> (!<span style="color:#2b91af">String</span>.IsNullOrEmpty(location))<br>                 compilerParams.ReferencedAssemblies.Add(location);<br>         }<br>         <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">NotSupportedException</span>)<br>         {<br>             <span style="color:#008000">// this happens for dynamic assemblies, so just ignore it.                     </span><br>         }<br>     }<br> <br>     <span style="color:#0000ff">return</span> compilerParams;<br> }</div> </div> </div>  <p>Now we compile the code into an assembly.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b05d391c-e1d9-47c3-b9b3-2c147f47e7bb" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Compiles the assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compileUnit&quot;&gt;</span><span style="color:#008000">The compile unit.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compilerParams&quot;&gt;</span><span style="color:#008000">The compiler params.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerResults</span> CompileAssembly(<span style="color:#2b91af">CodeCompileUnit</span> compileUnit, <span style="color:#2b91af">CompilerParameters</span> compilerParams)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">CSharpCodeProvider</span> provider = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CSharpCodeProvider</span>())<br>     {<br>         <span style="color:#008000">// =============================================================================== //</span><br>         <span style="color:#008000">// if you want to see the actual complied source code uncomment //</span><br>         <span style="color:#008000">// =============================================================================== //</span><br> <br>         <span style="color:#008000">//StringBuilder source = new StringBuilder();</span><br>         <span style="color:#008000">//StringWriter sw = new StringWriter(source);</span><br>         <span style="color:#008000">//provider.GenerateCodeFromCompileUnit(compileUnit, sw, new CodeGeneratorOptions());</span><br>         <span style="color:#008000">//string sourceCode = source.ToString();</span><br> <br>         <span style="color:#0000ff">var</span> results = provider.CompileAssemblyFromDom(compilerParams, compileUnit);<br>         <span style="color:#0000ff">return</span> results;<br>     }<br> }</div> </div> </div>  <p>The last thing we need to do is run the code that was just compiled.&#160; We will need the help of reflection to accomplish this.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09c68e9b-98f4-4334-aa9f-ecf464569e54" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Executes the ExecuteScript method from the compiled CodeDom assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;results&quot;&gt;</span><span style="color:#008000">The results.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> ExecuteCode(<span style="color:#2b91af">CompilerResults</span> results, <span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">try</span><br>     {<br>         <span style="color:#2b91af">Assembly</span> executingAssembly = results.CompiledAssembly;<br>         <span style="color:#0000ff">if</span> (executingAssembly != <span style="color:#0000ff">null</span>)<br>         {<br>             <span style="color:#008000">//create an instance of our newly compiled assembly</span><br>             <span style="color:#0000ff">object</span> assemblyInstance = executingAssembly.CreateInstance(<span style="color:#a31515">&quot;WPFCodeInjection.DynamicClass&quot;</span>);<br> <br>             <span style="color:#008000">//get our ExecuteScript method and execute it.</span><br>             <span style="color:#2b91af">MethodInfo</span> info = assemblyInstance.GetType().GetMethod(<span style="color:#a31515">&quot;ExecuteScript&quot;</span>);<br>             info.Invoke(assemblyInstance, <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[] { sender, e });<br>         }<br>     }<br>     <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">Exception</span> ex)<br>     {<br>         <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Error: An exception occurred while executing the script&quot;</span>, ex);<br>     }<br> }</div> </div> </div>  <p>That is it.&#160; Now to test this out lets create a .txt file that contains our XAML that we define above and save it CodeSnippet.txt.&#160; In our MainWindow.xaml.cs, lets handle the Loaded event and load our CodeSnippet.txt using the XamlReader.Load method.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc56e72c-6fdc-4430-afb5-4498031c46f1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">void</span> MainWindow_Loaded(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">FileStream</span> fs = <span style="color:#0000ff">new</span> <span style="color:#2b91af">FileStream</span>(<span style="color:#a31515">@&quot;./CodeSnippet.txt&quot;</span>, <span style="color:#2b91af">FileMode</span>.Open))<br>     {<br>         <span style="color:#0000ff">this</span>.Content = <span style="color:#2b91af">XamlReader</span>.Load(fs);<br>     }<br> }</div> </div> </div>  <p>Run the application is this is what it should look like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb9.png" width="174" height="179" /></a></p>  <p>Now click the button and our C# code defined within the Script property will be dynamically compiled and executed changed the text of the button to this:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb10.png" width="184" height="179" /></a></p>  <p>This is a very simple example and is not intended to be a complete solution, but it does show some of the powerful capabilities you have using WPF, XAML, and the CodeDom.&#160; Like always <a href="http://brianlagunas.com/downloads/source/WpfCodeInjection.zip">download the source</a> and start playing around.&#160; See what kind of cool stuff you can do with it.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yes you can write Inline Code in XAML</title>
		<link>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yes-you-can-write-inline-code-in-xaml</link>
		<comments>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 21:11:51 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/</guid>
		<description><![CDATA[A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete it?”.&#160; Obviously I replied yes, you absolutely can delete the code-behind file from a XAML file and the application will still work.&#160; Then they replied, “That’s cool I guess, but what about the code that needs to execute, such as event handlers?”.&#160; Naturally I brought up the fact that using MVVM you don’t use event handlers, but as most developers do, they said, “Well what if I really needed it?”.&#160; My reply to that question was, “If you really had to, it is possible to write inline code inside the XAML file”.</p>  <p>They looked at me in amazement, “Really?”.&#160; Apparently that is a little known fact about WPF.&#160; Yes, it is absolutely possible to write inline code inside a XAML page without the need for a code-behind file, and everything will work as expected.&#160; I quickly realized that his was going somewhere I didn’t want it to go.&#160; I knew what was coming next; they asked me to show them how to do it. Uggg…</p>  <p>Okay here is the deal; what I am about to show you is not recommended.&#160; It goes against everything I have been teaching in the community, but if you are curious how to actually do this, it is quit simple.</p>    <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ddf41891-b77a-41c9-89aa-aeb2944933da" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--Define the button content --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;133&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Name</span><span style="color:#0000ff">=&quot;btnExitApp&quot;</span><span style="color:#ff0000"> Click</span><span style="color:#0000ff">=&quot;btnExitApp_Clicked&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Exit Application&quot;/&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--The C# implementation of the button&#39;s Click event handler. --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>             <span style="color:#808080">private void btnExitApp_Clicked(object sender, RoutedEventArgs e)</span><br>             <span style="color:#808080">{</span><br>                 <span style="color:#808080">// Get a handle to the current app and shut it down.</span><br>                 <span style="color:#808080">Application.Current.Shutdown();</span><br>             <span style="color:#808080">}</span><br>         <span style="color:#808080">]]&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div>    <p>As you can see the code snippet above is pretty simple.&#160; You will notice that the Button has a EventHandler defined called “btnExitApp_Clicked”.&#160; Since there is no code-behind (I deleted it) you may be expecting a compile error that says it cannot find the definition for the EventHandler.&#160; But wait, we do have the event handler defined within the &lt;x:Code&gt;….&lt;/x:Code&gt; tags.</p>  <p>The &lt;x:Code&gt;….&lt;/x:Code&gt; is a directive element defined in XAML.&#160; An x:Code directive element can contain inline programming code. The code that is defined inline can interact with the XAML on the same page.&#160; Notice that the code is inside the x:Code element and that the code must be surrounded by &lt;CDATA[...]]&gt; to escape the contents for XML, so that a XAML processor (interpreting either the XAML schema or the WPF schema) will not try to interpret the contents literally as XML.</p>  <p>That is all there really is to it.&#160; There are some limitations to using inline code, for more information you can check out the <a href="http://msdn.microsoft.com/en-us/library/aa970568.aspx" target="_blank">MSDN documentation</a>.&#160; Now, I don’t want to see this in any production code.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Simple WPF Loading Animation</title>
		<link>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-wpf-loading-animation</link>
		<comments>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 03:47:21 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/</guid>
		<description><![CDATA[Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could save myself some time by just using theirs.&#160; Well, after almost an hour searching, I found nothing.&#160; So much for being a timesaver.&#160; Now, don’t get me wrong, I found a couple of WPF animations out there, but none of them really fit what I needed.&#160; So I just decided to bite the bullet and create my own.&#160; After creating the animation I decided to share the fruits of my labor so that anyone else who is looking for the same thing I was, or something similar, wouldn’t have as much trouble as I did.</p>  <p>Here is what it looks like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="loadingAnimation" border="0" alt="loadingAnimation" src="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation_thumb.jpg" width="114" height="114" /></a> </p>  <p>Here is the source: <a href="http://brianlagunas.com/downloads/source/LoadingControl.zip">Download the Loading Animation Source</a></p>  <p>I hope it is useful to someone besides me.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Debugging XAML</title>
		<link>http://elegantcode.com/2009/04/14/debugging-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-xaml</link>
		<comments>http://elegantcode.com/2009/04/14/debugging-xaml/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 01:43:01 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/04/14/debugging-xaml/</guid>
		<description><![CDATA[Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths. Lets say I have the following code snippet: &#60;StatusBar&#62; &#60;StatusBarItem&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths.</p>  <p>Lets say I have the following code snippet:</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">       <span style="color: #0000ff">&lt;</span><span style="color: #800000">TextBlock</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;{Binding Messssage}&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>
  </div>
</div>

<p></p>

<p>As you can see my property Message is totally misspelled.&#160; If I were to run this application nothing would ever appear in my status bar, and I would not know why.&#160; I didn’t get any compile errors, and my view renders perfectly in my designer, so what the hell is going on.&#160; You might spend hours looking at your object’s property, stepping through the property changed events, or just saying XAML is a piece of crap and I give up.&#160; Well never fear, I am about to reveal the secret to debugging your XAML.</p>

<p>Look in your Output Window!</p>

<p><a href="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow.jpg" target="_blank"><img title="OutputWindow" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="79" alt="OutputWindow" src="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow-thumb.jpg" width="404" border="0" /></a> </p>

<p>Yes, the nearly always forgotten Output Window.&#160; As you can see, if you click on the image above, it tells me that I have a binding expression path error and gives the line number where the error occurred.&#160; So don’t spend hours stepping through code looking for a ghost.&#160; Just check your Output Window.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/04/14/debugging-xaml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WPF String.Format in XAML with the StringFormat attribute</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Elegant Code &#187; xaml</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Betnovate Without Prescription</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinWidth&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinWidth}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinHeight&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinHeight}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderThickness&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> InputControlBorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontFamily&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontFamily}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontSize&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.HorizontalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.VerticalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.ZoomMode&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Padding&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxPaddingThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButtonStyle&quot;</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;/&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Pressed&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> FontFamily</span><span style="background:#ffffff;color:#0000ff">=&quot;Segoe UI Symbol&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;X&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;*&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;Auto&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Focused&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonVisible&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonCollapsed&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Let’s test what we have so far.&#160; Add an instance of our WatermarkTextBox control to the BlankPage.xaml.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5b472f91-aaa4-4de0-a251-52d2d2c82795" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Page</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Class</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTextBoxControl.BlankPage&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">x</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">local</span><span style="background:#ffffff;color:#0000ff">=&quot;using:WatermarkTextBoxControl&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">d</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">mc</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> mc</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Ignorable</span><span style="background:#ffffff;color:#0000ff">=&quot;d&quot;&gt;</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Page</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image5.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb5.png" width="275" height="60" /></a></p>  <p>Looks great.&#160; Just like the default Windows TextBox.&#160; Now we need to start adding our Watermark elements to it.&#160; Obviously we need a property for our Watermark.&#160; Your first thought maybe to define it as a type of string, but I want to support any element, not just text, so I will define it as a type of Object.&#160; This will allow me to nest controls inside of the Watermark property instead of being restricted to a simple string.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:db082020-3ed1-4025-b979-4d938ab172a9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;Watermark&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> Watermark</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>I also want to define a DataTemplate that will be used to define the ContentTemplate for the Watermark.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd631c4b-41c5-442b-8fb7-9704ba9c139b" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkTemplateProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000"> WatermarkTemplate</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkTemplateProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkTemplateProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Now we need to modify our control template to support our new Watermark property. We will do this by simply adding a ContentPresenter to our Template.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4431129a-2a62-4f39-abc1-6c7e0c47b874" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate price, coupon</b>, <b>Where to buy Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span></div> </div> </div>  <p>Oh, <b>effects of Betnovate</b>, <b>Is Betnovate safe</b>, and don’t forget the ContentTemplate that will define the default look for our watermark.&#160; This is placed at the top of the Generic.xaml.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baa07ca8-8bac-40b7-aece-36f27dedd0e5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>purchase Betnovate online no prescription</b>, <b>Online buy Betnovate without a prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Key</span><span style="background:#ffffff;color:#0000ff">=&quot;DefaultWatermarkTemplate&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentControl</span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">Binding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;Gray&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>And we need to set the default value in a style setter.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7175292-1fca-49aa-85ae-7ff859ab8ec2" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Buy Betnovate online cod</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DefaultWatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot; /&gt;</span></div> </div> </div>    <p>As you can see, I placed the ComtentPresenter after the ContentElement and before the DeleteButton elements.&#160; You may have also noticed that I set the visibility to Collapsed.&#160; This is because by default I want the Watermark hidden.&#160; So that means we need to add some code to show the watermark when the text box has no focus and it has no text.&#160; First we need to add some visual states to the VisualStateManager.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b482c41e-77da-4f54-ad99-4493ac8b1f73" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from canada</b>, <b>Betnovate without prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkStates&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkVisible&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkCollapsed&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Next we need to add some code to handle the GotFocus and LostFocus events of the TextBox.&#160; Start by adding event handlers for the events in the constructor.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e05e8b51-c571-48bc-9ee7-10b58950f385" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from mexico</b>, <b>Japan, craiglist, ebay, overseas, paypal</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.GotFocus += WatermarkTextBox_GotFocus;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.LostFocus += WatermarkTextBox_LostFocus;</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>Now add the code that does the heavy lifting.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:367568eb-5f40-4e4a-9861-50bab0c05329" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate brand name</b>, <b>Purchase Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_GotFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, <b>where can i buy cheapest Betnovate online</b>, <b>Canada, mexico, india</b>, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState();</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_LostFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> hasFocus = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//if our text is empty and our control doesn&#39;t have focus then show the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//otherwise the control eirther has text or has focus which in either case we need to hide the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">String</span><span style="background:#ffffff;color:#000000">.IsNullOrEmpty(Text) &amp;&amp; !hasFocus)</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkVisible&quot;</span><span style="background:#ffffff;color:#000000">); </span><span style="background:#ffffff;color:#008000">//TODO: create constants for our magic strings</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">else</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkCollapsed&quot;</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToVisualState(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> stateName, <b>herbal Betnovate</b>, <b>Taking Betnovate</b>, </span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> useTransitions = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">VisualStateManager</span><span style="background:#ffffff;color:#000000">.GoToState(</span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">, stateName, <b>rx free Betnovate</b>, <b>Order Betnovate online c.o.d</b>, useTransitions);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>One last thing is to make sure we set the visual state when the template is applied.&#160; So override the OnApplyTemplate method as follows.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d36c00a9-70e0-4692-9b7c-92d0a6de7deb" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate schedule</b>, <b>Betnovate dosage</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">override</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnApplyTemplate()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">base</span><span style="background:#ffffff;color:#000000">.OnApplyTemplate();</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//we need to set the initial state of the watermark</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>That should do it.&#160; Now let check it out in action. Be sure to provide a watermark for our control.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0630f9fd-701c-4d59-bcdb-4c659a352180" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate cost</b>, <b>Betnovate no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#ff0000"> Watermark</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb6.png" width="279" height="60" /></a></p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb7.png" width="279" height="63" /></a></p>  <h4>Yes, <b>Betnovate from mexico</b>, <b>Betnovate description</b>, we found a bug</h4>  <p>Everything seems to be working perfectly.&#160; Until you actually try to use a watermark that isn’t text.&#160; Try using this as your watermark.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c7fdd2-45ff-4ca5-86cb-5fe1adc8c10e" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>online buying Betnovate</b>, <b>Betnovate pics</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Orientation</span><span style="background:#ffffff;color:#0000ff">=&quot;Horizontal&quot;&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Image</span><span style="background:#ffffff;color:#ff0000"> Source</span><span style="background:#ffffff;color:#0000ff">=&quot;Images/PencilTool16.png&quot;</span><span style="background:#ffffff;color:#ff0000"> Stretch</span><span style="background:#ffffff;color:#0000ff">=&quot;None&quot;</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;4,0, <b>Betnovate interactions</b>, <b>Get Betnovate</b>, 0,0&quot; /&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>Now let’s see our results.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb8.png" width="275" height="60" /></a></p>  <p>Hey!&#160; Where is my watermark?&#160; Well there appears to be a bug with a ContentPresenter/ContentControl that will not display content when the ContentTemplate has been set and the Content is anything else except a string.&#160; This just so happens to be the exact same bug that exists in Silverlight.&#160; Interesting I know.&#160; So how do we fix it?&#160; We have to delete the usage of our Watermarktemplate until this gets fixed.</p>  <p>Change:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:715e6953-8e22-4e2e-8b8f-a4700760cfa9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>real brand Betnovate online</b>, <b>Betnovate steet value</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>To:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f626a1e-1d1c-489a-96cb-7f056392a0a8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>my Betnovate experience</b>, <b>Betnovate wiki</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>               <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>Now let’s see what happens.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image9.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb9.png" width="276" height="59" /></a></p>  <p>Now that’s much better.&#160; Let’s hope this is just a beta bug.</p>  <p><a href="http://brianlagunas.com/downloads/source/WatermarkTextBoxControl.zip" target="_blank">Download the source</a></p>, <b>low dose Betnovate</b>.  Order Betnovate from mexican pharmacy.  Online Betnovate without a prescription.  Betnovate long term.  Betnovate photos.  Betnovate samples.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4354'>Glucophage For Sale</a>. <a href='http://elegantcode.com/?p=4681'>Betnovate For Sale</a>. <a href='http://elegantcode.com/?p=4291'>Buy Vibramycin Without Prescription</a>. <a href='http://elegantcode.com/?p=4268'>Soma For Sale</a>. <a href='http://elegantcode.com/?p=4276'>Buy Viagra Without Prescription</a>. <a href='http://elegantcode.com/?p=4831'>Buying Glucophage online over the counter</a>. <a href='http://elegantcode.com/?p=4846'>Effects of Ketoconazole Cream</a>. <a href='http://elegantcode.com/?p=5014'>Order Quinine online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4232'>Japan, craiglist, ebay, overseas, paypal</a>. <a href='http://elegantcode.com/?p=4867'>Ordering Soma online</a>.<br />
<b>Trackbacks from:</b> <a href='http://home.officesnapshots.com/?p=250'>Buy Betnovate Without Prescription</a>. <a href='http://reversemortgagedaily.com/?p=14063'>Buy Betnovate Without Prescription</a>. <a href='http://social-blend.com/?p=1202'>Buy Betnovate Without Prescription</a>. <a href='http://www.quarterlives.com/?p=454'>Buy Betnovate Without Prescription</a>. <a href='http://4realz.net/?p=758'>Buy Betnovate Without Prescription</a>. <a href='http://blog.farmland.org/?p=3440'>Betnovate dosage</a>. <a href='http://linuxologist.com/?p=129'>Betnovate price, coupon</a>. <a href='http://www.themusclecarplace.com/?p=3456'>Betnovate no rx</a>. <a href='http://www.thegriffonnews.com/?p=10192'>Betnovate use</a>. <a href='http://www.greatgreengoods.com/?p=3270'>Kjøpe Betnovate på nett, köpa Betnovate online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vermox For Sale</title>
		<link>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:51:29 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[So far we have built an earthquake application Vermox For Sale, , mapped an address using geocoding, and even Prism-fied the Bing Maps WPF control.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can [...]]]></description>
			<content:encoded><![CDATA[<p> <p>So far we have built an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earthquake application</a> <b>Vermox For Sale</b>, , <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">mapped an address</a> using geocoding, and even <a href="http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/" target="_blank">Prism-fied the Bing Maps WPF control</a>.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can create this application.</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services. </p>  <p>For this application we will be using the Geocode Service and the Route Service.&#160; The Geocode service is used to match addresses, <b>Vermox dangers</b>, <b>Vermox coupon</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>Vermox dose</b>, <b>Vermox dosage</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; The Route service is used to generate routes and driving directions based on locations or waypoints.</p>  <p>Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>Vermox pharmacy</b>.  <b>Cheap Vermox</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>ordering Vermox online</b>.  <b>Vermox from mexico</b>, </p>  <p>Open up your App.xaml. You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca628505-dd3b-4d33-ae53-ad0ea17f81a9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy no prescription Vermox online</b>, <b>Buying Vermox online over the counter</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>We need to add the Geocode and Route service to our application.&#160; First, <b>where can i buy cheapest Vermox online</b>, <b>Low dose Vermox</b>, let’s start by adding the Geocode service.&#160; Right click the project and select “Add Service Reference”.&#160; Use the following address:</p>  <p><a href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name. I called mine BingServices.&#160; Now we need to add the Route service, <b>Vermox steet value</b>, <b>No prescription Vermox online</b>, but we don’t want to add a separate service reference.&#160; Ideally we would have a single service that contained both the Geocode and Route services.&#160; Luckily there is a trick we can use to do just that.&#160; Select the Project and click the “Show All Files” button at the top of the Solution Explorer.&#160; Expand the Service Reference folder and then expand the BingServices service.&#160; Look for a file called <strong>Reference.svcmap</strong>. Open the References.svcmap and locate the MetadataSource node.&#160; It will loko something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e1e98d3-82a4-419a-a32f-707e0559123c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox duration</b>, <b>Order Vermox online overnight delivery no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Simply add a new MetatdataSource as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7291104c-336c-4f44-9a3e-5843babcba3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox schedule</b>, <b>Where can i buy Vermox online</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">2</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see we added a new MetadataSource that points to the Route service and we gave it a SourceId of 2.&#160; Now right click the service and select “Update Service Reference”.&#160; This will generate a single service proxy for both the Geocode and Route services.&#160; Pretty slick huh?</p>  <p>The next step will be to create a ViewModel that will contain an ICommand that will execute the route calculation, <b>Vermox long term</b>, <b>Vermox price</b>, properties that will represent a “To” address and a “From” address.&#160; We will also need a property for the RouteResult and for the directions we generate.&#160; Lets first create our Direction object:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0230a924-5d25-4bed-880a-8b8cca1043e9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox samples</b>, <b>After Vermox</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">Direction</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Description { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">Location</span> Location { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> }</div> </div> </div>  <p>Now we will need a make-shift delegate command (do not use in production code):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:424be6fd-5bed-4501-ac25-33db908058c2" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>doses Vermox work</b>, <b>Is Vermox safe</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span> : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span> _execute;<br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span> execute)<br>     {<br>         _execute = execute;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke();<br>     }<br> }</div> </div> </div>  <p>Now on to the ViewModel itself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d9737cbe-bea9-4b93-af31-534d3ad53cb1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox pics</b>, <b>Vermox pictures</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">RouteViewModel</span>: <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> CalculateRouteCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _from = <span style="color:#a31515">&quot;Meridian, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> From<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _from; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _from = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;From&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _to = <span style="color:#a31515">&quot;Boise, <b>Vermox used for</b>, <b>Online buy Vermox without a prescription</b>, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> To<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _to; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _to = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;To&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">RouteResult</span> _routeResult;<br>     <span style="color:#0000ff">public</span> BingServices.<span style="color:#2b91af">RouteResult</span> RouteResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _routeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _routeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;RouteResult&quot;</span>);<br>         }<br>     }<br>     <br> <br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; _directions;<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; Directions<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _directions; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _directions = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;Directions&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> RouteViewModel()<br>     {<br>         CalculateRouteCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>(CalculateRoute);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute()<br>     {<br>         <span style="color:#0000ff">var</span> from = GeocodeAddress(From);<br>         <span style="color:#0000ff">var</span> to = GeocodeAddress(To);<br> <br>         CalculateRoute(from, to);<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">GeocodeResult</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br>         BingServices.<span style="color:#2b91af">GeocodeResult</span> result = <span style="color:#0000ff">null</span>;<br> <br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Query = address;<br>             result = client.Geocode(request).Results[0];<br>         }<br> <br>         <span style="color:#0000ff">return</span> result;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute(BingServices.<span style="color:#2b91af">GeocodeResult</span> from, <b>online buying Vermox hcl</b>, <b>Vermox reviews</b>, BingServices.<span style="color:#2b91af">GeocodeResult</span> to)<br>     {<br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">RouteServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IRouteService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">RouteRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Waypoints = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;BingServices.<span style="color:#2b91af">Waypoint</span>&gt;();<br>             request.Waypoints.Add(ConvertResultToWayPoint(from));<br>             request.Waypoints.Add(ConvertResultToWayPoint(to));<br> <br>             request.Options = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteOptions</span>();<br>             request.Options.RoutePathType = BingServices.<span style="color:#2b91af">RoutePathType</span>.Points;<br> <br>             RouteResult = client.CalculateRoute(request).Result;<br>         }<br> <br>         GetDirections();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GetDirections()<br>     {<br>         Directions = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt;();<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">ItineraryItem</span> item <span style="color:#0000ff">in</span> RouteResult.Legs[0].Itinerary)<br>         {<br>             <span style="color:#0000ff">var</span> direction = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Direction</span>();<br>             direction.Description = GetDirectionText(item);<br>             direction.Location = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(item.Location.Latitude, item.Location.Longitude);<br>             Directions.Add(direction);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">string</span> GetDirectionText(BingServices.<span style="color:#2b91af">ItineraryItem</span> item)<br>     {<br>         <span style="color:#0000ff">string</span> contentString = item.Text;<br>         <span style="color:#008000">//Remove tags from the string</span><br>         <span style="color:#2b91af">Regex</span> regex = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Regex</span>(<span style="color:#a31515">&quot;&lt;(.|&#92;n)*?&gt;&quot;</span>);<br>         contentString = regex.Replace(contentString, <b>purchase Vermox for sale</b>, <b>Vermox results</b>, <span style="color:#0000ff">string</span>.Empty);<br>         <span style="color:#0000ff">return</span> contentString;<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">Waypoint</span> ConvertResultToWayPoint(BingServices.<span style="color:#2b91af">GeocodeResult</span> result)<br>     {<br>         BingServices.<span style="color:#2b91af">Waypoint</span> waypoint = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">Waypoint</span>();<br>         waypoint.Description = result.DisplayName;<br>         waypoint.Location = result.Locations[0];<br>         <span style="color:#0000ff">return</span> waypoint;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>Let’s walk though the CalculateRoute Method.&#160; First we geocode the “From” and “To” properties the same way we did in the <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">geocoding post</a>.&#160; Once we have our From and To locations we use those results to generate a RouteRequest and send that request to the Route service.&#160; The service will generate a result and we set our RouteResult property accordingly.&#160; This property will be used in data binding shortly.&#160; Next we generate an ObservableCollection&lt;Direction&gt; by looping through all the ItineraryItems in the result.&#160; </p>  <p>Now that we have generate all of our data, <b>online buying Vermox</b>, <b>Vermox forum</b>, we need to create a View that supports and displays this data, but before we do that we need to create some attached properties.&#160; Why do you ask?&#160; Well because as it stands, <b>Vermox online cod</b>, <b>Vermox no prescription</b>, the Bing Maps WPF control is not data binding friendly.&#160; So we need to enable data binding with the use of attached properties.&#160; We will need an attached property for the Route result which will be responsible for drawing the route line on the map.&#160; We will also need one for the MapLayer that will be used to contain the route line.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55925f26-554d-4793-8b07-532984d855c6" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>order Vermox from United States pharmacy</b>, <b>Vermox australia, uk, us, usa</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> RouteResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteResult&quot;</span>, <span style="color:#0000ff">typeof</span>(BingServices.<span style="color:#2b91af">RouteResult</span>), <b>Vermox gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Vermox overnight</b>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingServices.<span style="color:#2b91af">RouteResult</span> GetRouteResult(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingServices.<span style="color:#2b91af">RouteResult</span>)target.GetValue(RouteResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteResult(<span style="color:#2b91af">DependencyObject</span> target, BingServices.<span style="color:#2b91af">RouteResult</span> value)<br>     {<br>         target.SetValue(RouteResultProperty, value);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteResultChanged((<span style="color:#2b91af">Map</span>)o, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.OldValue, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.NewValue);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">Map</span> map, BingServices.<span style="color:#2b91af">RouteResult</span> oldValue, BingServices.<span style="color:#2b91af">RouteResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">MapPolyline</span> routeLine = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapPolyline</span>();<br>         routeLine.Locations = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationCollection</span>();<br>         routeLine.Opacity = 0.65;<br>         routeLine.Stroke = <span style="color:#0000ff">new</span> <span style="color:#2b91af">SolidColorBrush</span>(<span style="color:#2b91af">Colors</span>.Blue);<br>         routeLine.StrokeThickness = 5.0;<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">Location</span> loc <span style="color:#0000ff">in</span> newValue.RoutePath.Points)<br>         {<br>             routeLine.Locations.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(loc.Latitude, loc.Longitude));<br>         }<br> <br>         <span style="color:#0000ff">var</span> routeLineLayer = GetRouteLineLayer(map);<br>         <span style="color:#0000ff">if</span> (routeLineLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             routeLineLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetRouteLineLayer(map, routeLineLayer);<br>         }<br> <br>         routeLineLayer.Children.Clear();<br>         routeLineLayer.Children.Add(routeLine);<br> <br>         <span style="color:#008000">//Set the map view</span><br>         <span style="color:#2b91af">LocationRect</span> rect = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationRect</span>(routeLine.Locations[0], routeLine.Locations[routeLine.Locations.Count - 1]);<br>         map.SetView(rect);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteResult</span><br> <br>     <span style="color:#0000ff">#region</span> RouteLineLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteLineLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteLineLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteLineLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(RouteLineLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(RouteLineLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteLineLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         <span style="color:#0000ff">if</span> (!map.Children.Contains(newValue))<br>             map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteLineLayer</span><br> }</div> </div> </div>  <p>The RouteResult property simply creates a MapPolyline, loops through all the points in the result and adds the locations to the route line.&#160; It then gets the RouteLineLayer and adds it to the map.&#160; Lastly, it sets the map’s view to best fit the route line.</p>  <p>Now we are ready for the View:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:393d6882-6c78-48e8-9046-d517df235427" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">core</span><span style="color:#0000ff">=&quot;clr-namespace:BingMapsCalculateRouteDemo.Core&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;RouteTemplate&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Ellipse</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Fill</span><span style="color:#0000ff">=&quot;Red&quot;</span><span style="color:#ff0000"> Opacity</span><span style="color:#0000ff">=&quot;0.8&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.Position</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Location}</span><span style="color:#0000ff">&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.PositionOrigin</span><span style="color:#0000ff">=&quot;Center&quot;</span><br>                     <span style="color:#ff0000"> Tag</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding}</span><span style="color:#0000ff">&quot;</span><br>                     <span style="color:#ff0000"> MouseEnter</span><span style="color:#0000ff">=&quot;Route_MouseEnter&quot;</span> <br>                     <span style="color:#ff0000"> MouseLeave</span><span style="color:#0000ff">=&quot;Route_MouseLeave&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;150&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> From}</span><span style="color:#0000ff">&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> To}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Get Route&quot;</span><span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CalculateRouteCommand}</span><span style="color:#0000ff">&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=&quot;AerialWithLabels&quot;</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> VerticalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> RouteResult}</span><span style="color:#0000ff">&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteLineLayer</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ElementName</span><span style="color:#0000ff">=RouteLineLayer}&quot;</span><br>                  <span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot; &gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;RouteLineLayer&quot; /&gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapItemsControl</span><span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Directions}</span><span style="color:#0000ff">&quot;</span><br>                                      <span style="color:#ff0000"> ItemTemplate</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> RouteTemplate}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br> <br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupLayer&quot;&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopup&quot;</span><span style="color:#ff0000"> Visibility</span><span style="color:#0000ff">=&quot;Collapsed&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;15&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupText&quot;</span><span style="color:#ff0000"> FontSize</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> FontWeight</span><span style="color:#0000ff">=&quot;Bold&quot;</span><span style="color:#ff0000"> TextWrapping</span><span style="color:#0000ff">=&quot;Wrap&quot; /&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Oh and don’t forget the code behind:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:14f2277a-a347-48e8-afd6-41465898d7fe" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">partial</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span><br> {<br>     <span style="color:#0000ff">public</span> MainWindow()<br>     {<br>         InitializeComponent();<br>         DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">RouteViewModel</span>();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseEnter(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         <span style="color:#2b91af">FrameworkElement</span> pin = sender <span style="color:#0000ff">as</span> <span style="color:#2b91af">FrameworkElement</span>;<br>         <span style="color:#2b91af">MapLayer</span>.SetPosition(ContentPopup, <span style="color:#2b91af">MapLayer</span>.GetPosition(pin));<br>         <span style="color:#2b91af">MapLayer</span>.SetPositionOffset(ContentPopup, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Point</span>(20, -15));<br> <br>         <span style="color:#0000ff">var</span> location = (<span style="color:#2b91af">Direction</span>)pin.Tag;<br> <br>         ContentPopupText.Text = location.Description;<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Visible;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseLeave(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Collapsed;<br>     }<br> }</div> </div> </div>  <p>Now let’s view the fruits of our labor at runtime.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/09/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/09/image_thumb.png" width="644" height="453" /></a></p>  <p>As you can see, given a “From” and “To” address, we can draw a route line and provide turn-by-turn directions as the user hovers over the direction pins.&#160; Pretty neat huh?&#160; And it wasn’t too difficult to pull off.&#160; As always you can <a href="http://www.brianlagunas.com/downloads/source/BingMapsCalculateRouteDemo.zip">Download the Source</a> and start playing.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4306'>Buy Biaxin Without Prescription</a>. <a href='http://elegantcode.com/?p=4228'>Aricept For Sale</a>. <a href='http://elegantcode.com/?p=4340'>Atarax For Sale</a>. <a href='http://elegantcode.com/?p=5052'>Lotrisone For Sale</a>. <a href='http://elegantcode.com/?p=4407'>Buy Nexium Without Prescription</a>. <a href='http://elegantcode.com/?p=4873'>Cafergot treatment</a>. <a href='http://elegantcode.com/?p=4780'>Canada, mexico, india</a>. <a href='http://elegantcode.com/?p=4202'>Online buying Celexa</a>. <a href='http://elegantcode.com/?p=4335'>Fast shipping Differin</a>. <a href='http://elegantcode.com/?p=4205'>Purchase Allopurinol online no prescription</a>.<br />
<b>Trackbacks from:</b> <a href='http://linuxologist.com/?p=193'>Vermox For Sale</a>. <a href='http://blog.farmland.org/?p=3110'>Vermox For Sale</a>. <a href='http://home.officesnapshots.com/?p=122'>Vermox For Sale</a>. <a href='http://reversemortgagedaily.com/?p=14171'>Vermox For Sale</a>. <a href='http://social-blend.com/?p=495'>Vermox For Sale</a>. <a href='http://www.themusclecarplace.com/?p=3175'>Vermox for sale</a>. <a href='http://www.thegriffonnews.com/?p=10415'>Ordering Vermox online</a>. <a href='http://www.quarterlives.com/?p=743'>Order Vermox online c.o.d</a>. <a href='http://tayloegray.com/?p=351'>Vermox from mexico</a>. <a href='http://www.greatgreengoods.com/?p=3949'>Purchase Vermox for sale</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buy Female Pink Viagra Without Prescription</title>
		<link>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prism-fy-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 16:13:02 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[prism]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been playing around with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled [...]]]></description>
			<content:encoded><![CDATA[<p> <p>If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">playing</a> <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">around</a> with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled MapLayers at runtime using Prism.</p>  <p> <b>Buy Female Pink Viagra Without Prescription</b>, The concept is simple.&#160; We want a Bing Maps application that can be extended at runtime.&#160; By extended, I mean that I want the ability to add new elements/modules to the Map at runtime.&#160; The important thing about these elements/modules is that they can come from anywhere and they should be loosely coupled from the Map as well as other elements/modules that may exist on the Map.</p>  <p>Luckily for us this is extremely simple to accomplish.&#160; All we have to do is create a custom RegionAdapter, register it with our Prism application, and then apply it to our Bing Map control.&#160; So let’s start with the RegionAdapter.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8809704-1b89-4479-9f50-32a29a8ce6e3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapRegionAdapter</span> : <span style="color:#2b91af">RegionAdapterBase</span>&lt;<span style="color:#2b91af">Map</span>&gt;<br> {<br>     <span style="color:#0000ff">public</span> MapRegionAdapter(<span style="color:#2b91af">IRegionBehaviorFactory</span> regionBehaviorFactory)<br>         : <span style="color:#0000ff">base</span>(regionBehaviorFactory)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> Adapt(<span style="color:#2b91af">IRegion</span> region, <span style="color:#2b91af">Map</span> regionTarget)<br>     {<br>         region.Views.CollectionChanged += (s, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Add)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.NewItems)<br>                     regionTarget.Children.Add(element);<br>             }<br>             <span style="color:#0000ff">else</span> <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Remove)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.OldItems)<br>                     <span style="color:#0000ff">if</span> (regionTarget.Children.Contains(element))<br>                         regionTarget.Children.Remove(element);<br>             }<br>         };<br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">IRegion</span> CreateRegion()<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">AllActiveRegion</span>();<br>     }<br> }</div> </div> </div> </p>  <p>Now in the Bootstrapper we need to register our mapping.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fce11974-ec82-4641-ac5c-a37a9ff443df" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">RegionAdapterMappings</span> ConfigureRegionAdapterMappings()<br> {<br>     <span style="color:#2b91af">RegionAdapterMappings</span> mappings = <span style="color:#0000ff">base</span>.ConfigureRegionAdapterMappings();<br>     mappings.RegisterMapping(<span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Map</span>), Container.Resolve&lt;<span style="color:#2b91af">MapRegionAdapter</span>&gt;());<br>     <span style="color:#0000ff">return</span> mappings;<br> }</div> </div> </div> </p>  <p>Now we simply give the Map a region name. (this is actually all the shell has in it)</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a72303d9-120c-4bba-a39e-18ae1979a63a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>online Female Pink Viagra without a prescription</b>, <b>Female Pink Viagra forum</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> prism</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionManager.RegionName</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Static</span><span style="color:#ff0000"> inf</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionNames</span><span style="color:#0000ff">.MapRegion}&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40, <b>order Female Pink Viagra online overnight delivery no prescription</b>, <b>Low dose Female Pink Viagra</b>, -95&quot;</span><span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot; /&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div> </p>  <p>That is all there is to it.&#160; You can now start injecting modules onto the Map at runtime.&#160; Lets look at my two modules I am using as an example.&#160; Here is the structure of my application:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb13.png" width="305" height="190" /></a></p>  <ul>   <li>ModuleA will inject a MapPolygon in the Shape of Texas.</li>    <li>ModuleB is the Earthquake application we built in an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earlier post</a>.</li>    <li>Infrastructure is the project where shared code goes, in this case our MapRegionAdapter</li>    <li>BingMapsPrismfiedDemo is of course our shell project.</li> </ul>  <p>This is what the application looks like at runtime when both modules have been injected into it.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb14.png" width="644" height="334" /></a></p>  <p>Now I can easily add more layers to this map as I see fit.&#160; As always, <b>online buy Female Pink Viagra without a prescription</b>, <b>No prescription Female Pink Viagra online</b>, <a href="http://www.brianlagunas.com/downloads/source/BingMapsPrismfiedDemo.zip">Download the Source</a> and start playing.&#160; You may want to add MEF support as well.</p>.  Where can i find Female Pink Viagra online.  Effects of Female Pink Viagra.  Purchase Female Pink Viagra.  Female Pink Viagra over the counter.  Purchase Female Pink Viagra online.  Buy Female Pink Viagra without prescription.  Female Pink Viagra recreational.  Buy generic Female Pink Viagra.  Cheap Female Pink Viagra.  Female Pink Viagra no prescription.  Female Pink Viagra wiki.  Cheap Female Pink Viagra no rx.  Female Pink Viagra canada, mexico, india.  Buying Female Pink Viagra online over the counter.  Where to buy Female Pink Viagra.  Female Pink Viagra cost.  Female Pink Viagra from mexico.  Is Female Pink Viagra safe.  Buy Female Pink Viagra online cod.  Buy Female Pink Viagra from mexico.  Where can i order Female Pink Viagra without prescription.  Real brand Female Pink Viagra online.  Buy Female Pink Viagra from canada.  Female Pink Viagra overnight.  Female Pink Viagra use.  Order Female Pink Viagra from mexican pharmacy.  Female Pink Viagra street price.  Female Pink Viagra coupon.  Female Pink Viagra schedule.  Female Pink Viagra mg.  Female Pink Viagra interactions.  Taking Female Pink Viagra.  Female Pink Viagra used for.  Is Female Pink Viagra addictive.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4750'>Celebrex For Sale</a>. <a href='http://elegantcode.com/?p=4661'>Buy Methotrexate Without Prescription</a>. <a href='http://elegantcode.com/?p=4755'>Buy Zovirax Without Prescription</a>. <a href='http://elegantcode.com/?p=4311'>Buy Topamax Without Prescription</a>. <a href='http://elegantcode.com/?p=4476'>Modalert For Sale</a>. <a href='http://elegantcode.com/?p=4671'>Buy Quinine no prescription</a>. <a href='http://elegantcode.com/?p=4643'>Premarin duration</a>. <a href='http://elegantcode.com/?p=4340'>Purchase Atarax for sale</a>. <a href='http://elegantcode.com/?p=4732'>Abilify price</a>. <a href='http://elegantcode.com/?p=4373'>No prescription Topamax online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.thegriffonnews.com/?p=10565'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5050'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://changecamp.ca/?p=593'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://linuxologist.com/?p=450'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://blog.farmland.org/?p=1496'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.quarterlives.com/?p=930'>Female Pink Viagra brand name</a>. <a href='http://www.greatgreengoods.com/?p=3683'>Discount Female Pink Viagra</a>. <a href='http://www.macneilbmx.com/blog/?p=4935'>Female Pink Viagra pics</a>. <a href='http://social-blend.com/?p=671'>Female Pink Viagra results</a>. <a href='http://4realz.net/?p=847'>Female Pink Viagra pics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Buy Tindamax Without Prescription</title>
		<link>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-an-address-with-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:21:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[In my last post Buy Tindamax Without Prescription, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate [...]]]></description>
			<content:encoded><![CDATA[<p> <p>In my last <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">post</a> <b>Buy Tindamax Without Prescription</b>, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate maps and imagery, driving directions, distance calculations, and other location intelligence into your applications, business processes, and Web sites. </p>  <p>Let’s start with the Geocode Service which is used to match addresses, <b>buy cheap Tindamax</b>, <b>Purchase Tindamax for sale</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>my Tindamax experience</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; We will create a simple application that allows you to enter an address and place a pushpin at that location.&#160; First thing is first:</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165" target="_blank">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/" target="_blank">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services.&#160; Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>order Tindamax from United States pharmacy</b>.  <b>Online buying Tindamax</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>buy Tindamax without a prescription</b>.  <b>After Tindamax</b>, </p>  <p>Open up your App.xaml.&#160; You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c7fbbfb-a6ac-496d-a298-bddbd655ac65" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>discount Tindamax</b>, <b>Buy Tindamax no prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Now create a very simple UI that will accept an address and a button to perform the geocoding:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc9a874e-765b-4bc2-b82b-88a96f1ef84c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax treatment</b>, <b>Tindamax no rx</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>                  <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>The next thing we need to do is add a new Service Reference to the project and point to the following service:</p>  <p><a title="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc" href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name (I called mine BingMapsService) and just for fun, <b>buy Tindamax online cod</b>, <b>Generic Tindamax</b>, in the “Add Service Reference” dialog, click the “Advanced” button and click “Generate asynchronous operations”.</p>  <p>Next we need to create a ViewModel to support our View.&#160; This is a WPF application after all.&#160; This ViewModel will need a command for the button that will perform the geocoding, <b>Tindamax duration</b>, <b>Low dose Tindamax</b>, and a property that will represent the result of the service that the UI will use to map the address.&#160; It should resemble something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b09cd91-31d1-426f-a539-9fe004a3702a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax street price</b>, <b>Tindamax blogs</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">GeocodeViewModel</span> : <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> GeocodeAddressCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> _geocodeResult;<br>     <span style="color:#0000ff">public</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GeocodeResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _geocodeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _geocodeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> GeocodeViewModel()<br>     {<br>         GeocodeAddressCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>&lt;<span style="color:#2b91af">String</span>&gt;(GeocodeAddress);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>I want to point out that the DelegateCommand&lt;T&gt; is a very simple ICommand implementation and should NOT be used in production applications.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cac2fd6-5f40-4d30-b70e-39cf0eb39d77" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax wiki</b>, <b>Tindamax cost</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span>&lt;T&gt; : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span>&lt;T&gt; _execute;<br> <br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span>&lt;T&gt; execute)<br>     {<br>         _execute = execute;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke((T)parameter);<br>     }<br> }</div> </div> </div>  <p>Let’s hook our UI up to our command.&#160; it should look something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f154da3-e1a9-48e1-8dcd-53063e2268ec" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax overnight</b>, <b>Online buy Tindamax without a prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;</span> <br>                    <span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeAddressCommand}</span><span style="color:#0000ff">&quot;</span><br>                    <span style="color:#ff0000"> CommandParameter</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">, <b>where can i buy Tindamax online</b>, <b>Discount Tindamax</b>, </span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=</span>_<span style="color:#0000ff">txtAddress}&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Notice that we are using the text of the TextBox as the CommandParameter.&#160; Next, we need to implement the command:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0d2006e3-d7cf-483a-b57b-284d06ecffff" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax for sale</b>, <b>Tindamax used for</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br> {<br>     <span style="color:#0000ff">using</span> (BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>     {<br>         client.GeocodeCompleted += (o, <b>buy no prescription Tindamax online</b>, <b>Tindamax online cod</b>, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Error == <span style="color:#0000ff">null</span>)<br>             {<br>                 GeocodeResult = e.Result.Results[0];<br>             }<br>         };<br> <br>         BingMapsService.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeRequest</span>();<br>         request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>         request.Query = address;<br>         client.GeocodeAsync(request);<br>     }<br> }</div> </div> </div>  <p>In this command we are simply creating an instance of the service client, creating a GeocodeRequest, <b>Tindamax coupon</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, setting the credentials using the ApplicationId we have stored in the App.xaml, and then using the address as the Query for the request.&#160; When the call to the service is completed we are setting the GeocodeResult property to the first element in the results.</p>  <p>Now the tricky part.&#160; We want to place a Pushpin on the address that was entered and then move the map to that location.&#160; We also need to make sure that when another address is entered, <b>buying Tindamax online over the counter</b>, <b>Is Tindamax safe</b>, we clear any previous Pushpins that may exist on the map.&#160; We also have to be aware that other elements my be on the map and we don’t want to accidentally alter those elements.&#160; Oh and did I mention this was an MVVM application and this has to be done with just data binding. </p>  <p>The approach that I decided to go with is to use <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" target="_blank">Attached Properties</a>.&#160; So I created two attached properties; one for the GeocodeResult and another for a MapLayer that will be dedicated to the GeocodeResult.&#160; This will allow us to create a MapLayer that is specific to our GeocodeResut and not alter any other elements that may be on the map.&#160; Let’s check out the code.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3cc3f4e4-cbae-4ffe-93bf-4a10f2e36d08" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>herbal Tindamax</b>, <b>Tindamax price, coupon</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> GeocodeResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>, <b>buy Tindamax without a prescription</b>, <b>Buy Tindamax without prescription</b>, <span style="color:#0000ff">typeof</span>(BingMapsService.<span style="color:#2b91af">GeocodeResult</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <b>cheap Tindamax</b>, <b>Tindamax trusted pharmacy reviews</b>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GetGeocodeResult(<span style="color:#2b91af">Map</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)target.GetValue(GeocodeResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResult(<span style="color:#2b91af">Map</span> target, <b>ordering Tindamax online</b>, <b>Tindamax canada, mexico, india</b>, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> value)<br>     {<br>         target.SetValue(GeocodeResultProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultChanged((<span style="color:#2b91af">Map</span>)o, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.OldValue, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">Map</span> map, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> oldValue, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">Location</span> location = newValue.Locations.Select(x =&gt; <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(x.Latitude, x.Longitude)).First();<br> <br>         <span style="color:#2b91af">Pushpin</span> pin = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Pushpin</span>();<br>         pin.Location = location;<br>         pin.ToolTip = newValue.Address.FormattedAddress;<br> <br>         <span style="color:#0000ff">var</span> locationLayer = GetGeocodeResultLayer(map);<br>         <span style="color:#0000ff">if</span> (locationLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             locationLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetGeocodeResultLayer(map, locationLayer);<br>         }<br> <br>         locationLayer.Children.Clear();<br>         locationLayer.Children.Add(pin);<br> <br>         map.SetView(location, map.ZoomLevel);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResult</span><br> <br>     <span style="color:#0000ff">#region</span> GeocodeResultLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResultLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(GeocodeResultLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(GeocodeResultLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResultLayer</span><br> }</div> </div> </div>  <p>Notice that when the GeocodeResult changes we get the Location and create a pushpin for that location.&#160; We also set the tooltip to the FormattedAddress of the GeocodeResult.&#160; So when we hover over the pushpin we will see a nice little tooltip of the address.&#160; Next we try to get the GeocodeResultLayer from the map, if it is null this means it doesn’t exist on the map yet so we create one and assign it accordingly.&#160; We clear the layer child elemnts and then add out pushpin.&#160; The last thing we do is call the SetView method of the Map control passing in the location and the current ZoomLevel.</p>  <p>The final step is to use our AttachedProperty on the map.&#160; Be sure to create a namespace for the MapInteractivity class and define it as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72d6307a-aef3-4f70-8d47-8d4529fc74e0" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>          <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.GeocodeResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeResult}</span><span style="color:#0000ff">&quot;</span><br>          <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>One last thing.&#160; Be sure to remember to set your DataContext of your View to the ViewModel we have created:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f7d0b4f-e096-487d-8343-fb42c94c3360" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> MainWindow()<br> {<br>     InitializeComponent();<br>     DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">GeocodeViewModel</span>(); <br> }</div> </div> </div>  <p>That’s it.&#160; You now have an application the can map (geocode) an address using the Bing Maps WPF Control and the Geocoding SOAP Service.&#160; Oh and we are doing this all with MVVM and data binding which is my favorite part.&#160; Be sure to <a href="http://www.brianlagunas.com/downloads/source/bingmapsgeocodedemo.zip">Download the Source</a> and start playing around.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4746'>Buy Clindamycin Gel Without Prescription</a>. <a href='http://elegantcode.com/?p=4328'>Buy Plavix Without Prescription</a>. <a href='http://elegantcode.com/?p=4302'>Buy Phenergan Without Prescription</a>. <a href='http://elegantcode.com/?p=4460'>Buy Proscar Without Prescription</a>. <a href='http://elegantcode.com/?p=4607'>Triamterene For Sale</a>. <a href='http://elegantcode.com/?p=4751'>Diflucan street price</a>. <a href='http://elegantcode.com/?p=4372'>Nexium steet value</a>. <a href='http://elegantcode.com/?p=4475'>Metronidazole Gel from mexico</a>. <a href='http://elegantcode.com/?p=4399'>Herbal Periactin</a>. <a href='http://elegantcode.com/?p=4858'>Tramadol over the counter</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.macneilbmx.com/blog/?p=6683'>Buy Tindamax Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=3313'>Buy Tindamax Without Prescription</a>. <a href='http://www.thegriffonnews.com/?p=9133'>Buy Tindamax Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5330'>Buy Tindamax Without Prescription</a>. <a href='http://changecamp.ca/?p=592'>Buy Tindamax Without Prescription</a>. <a href='http://social-blend.com/?p=444'>Tindamax online cod</a>. <a href='http://blog.farmland.org/?p=3958'>Order Tindamax from mexican pharmacy</a>. <a href='http://4realz.net/?p=717'>Tindamax forum</a>. <a href='http://reversemortgagedaily.com/?p=14265'>Tindamax trusted pharmacy reviews</a>. <a href='http://linuxologist.com/?p=1542'>Tindamax online cod</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &#8211; dynamically compile and run event handlers within loose XAML using CodeDom</title>
		<link>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom</link>
		<comments>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:37:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[dynamic code]]></category>
		<category><![CDATA[wpd]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/</guid>
		<description><![CDATA[Last week I wrote a blog post showing how you can write inline code in XAML.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon re-tweeted that post with a link to one of his own posts on exploring new techniques for DLR script in XAML which also links [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a blog post showing how <a href="http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/" target="_blank">you can write inline code in XAML</a>.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon <a href="http://twitter.com/#!/rrelyea/status/15099827364827136" target="_blank">re-tweeted</a> that post with a link to one of his own posts on <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/11/14/exploring-new-techniques-for-dlr-script-in-xaml.aspx" target="_blank">exploring new techniques for DLR script in XAML</a> which also links to another one of his posts which shows different techniques for <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/06/03/xaml-events-in-compiled-and-uncompiled-scenarios.aspx" target="_blank">hooking up events in compiled and uncompiled scenarios</a> which in turn links to <a href="http://www.thinkbottomup.com.au/site/blog/Embedding_DLR_Scripts_in_XAML_Part_1" target="_blank">this post about embedding DLR scripts in XAML</a> written by Daniel Paull.&#160; Wow, that is a lot of linking.</p>  <p>Well, now that everyone has been given their respective credit, let’s continue.&#160; I wanted to take my last post a little further.&#160; In that post I simply created an event handler for a button click event using inline code in the x:Code directive.&#160; If you started to play with the sample code, you might have thought to yourself, “I wonder if I can load this XAML, event handler and all, from a file or database and have it still work.”.&#160; Well, if you tried it, you found the answer really quick.&#160; No!&#160; The reason is pretty simple; code must be compiled in order to execute.&#160; Therefore any code inside loose XAML will fail.&#160; Also, when using loose XAML, trying to hookup an event handler would crash your application because it is not allowed.</p>  <p>Oh, then it must not be possible? Wrong!&#160; Well, then how do you do it if the code must be compiled?&#160; Simple, we compile the code just before we run it.&#160; Say what?&#160; That’s right, let me introduce you to the <a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" target="_blank">CodeDom</a>.&#160; The CodeDom allows you to dynamically generate and compile code at runtime.&#160; Let’s get to it.</p>  <p>We need to attach event handlers to elements in loose XAML, and have them execute C# code.&#160; Each element has different events to handle, and each event will execute different code.&#160; This tells me that we need an object that contains two properties, one to specify the RoutedEvent to handle, and another to specify the c# code to execute.&#160; We also need a common event handler definition to execute whenever the RoutedEvent is invoked.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c257533-76d5-4e97-9754-1b389f8f52b5" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DynamicEvent</span><br> {<br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the routed event to execute.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The routed event.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">RoutedEvent</span> RoutedEvent { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the script to run when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The script.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Script { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Called when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br>     {<br>         <br>     }<br> }</div> </div> </div>  <p>That was simple enough.&#160; Now, in order to attach event handlers to elements in loose XAML, we need away to get around the “no event handlers allowed” limitation.&#160; To do this we can use an attached property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c6021e-2311-4633-85f8-8fcb27a9cb89" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> HandlerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;Handler&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(OnHandlerChanged));<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DynamicEvent</span> GetHandler(<span style="color:#2b91af">DependencyObject</span> obj)<br> {<br>     <span style="color:#0000ff">return</span> (<span style="color:#2b91af">DynamicEvent</span>)obj.GetValue(HandlerProperty);<br> }<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetHandler(<span style="color:#2b91af">DependencyObject</span> obj, <span style="color:#0000ff">bool</span> value)<br> {<br>     obj.SetValue(HandlerProperty, value);<br> }<br> <br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnHandlerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">UIElement</span> uie = o <span style="color:#0000ff">as</span> <span style="color:#2b91af">UIElement</span>;<br>     <span style="color:#0000ff">if</span> (uie == <span style="color:#0000ff">null</span>)<br>         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">Exception</span>(<span style="color:#a31515">&quot;Attempt to set EventHandler on non-UIElement Type&quot;</span>);<br> <br>     <span style="color:#2b91af">DynamicEvent</span> oldHandler = e.OldValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br>     <span style="color:#2b91af">DynamicEvent</span> newHandler = e.NewValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br> <br>     <span style="color:#008000">// unhook the old event</span><br>     <span style="color:#0000ff">if</span> (oldHandler != <span style="color:#0000ff">null</span>)<br>         uie.RemoveHandler(oldHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(oldHandler.OnEventExecuted));<br> <br>     <span style="color:#008000">// hook up the new</span><br>     <span style="color:#0000ff">if</span> (newHandler != <span style="color:#0000ff">null</span>)<br>         uie.AddHandler(newHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(newHandler.OnEventExecuted));<br> <br> }</div> </div> </div>  <p>This attached property allows use to attach an instance of our DynamicEvent class to our element.&#160; When the Handler attached property is set, we simple add our OnEventExecute event handler to the RoutedEvent specified in the RoutedEvent property.&#160; Now we have the basic framework needed to attach and event handler to any event on any element in loose XAML.&#160; Let’s see how to attach an event handler in XAML using this newly created DynamicEvent class.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c323adca-e880-4dd4-997e-958bccc70c3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Initial Text&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#ff0000"> RoutedEvent</span><span style="color:#0000ff">=&quot;Button.Click&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#ff0000"> xml</span><span style="color:#0000ff">:</span><span style="color:#ff0000">space</span><span style="color:#0000ff">=&quot;preserve&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>                         <span style="color:#808080">var button = sender as Button;</span><br>                         <span style="color:#808080">button.Content = &quot;Changed with Dynamic Code&quot;;</span><br>                         <span style="color:#808080">]]&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Button</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see I have added a handler for a Button’s Click event.&#160; I also provided a Script to execute when the event is invoked.&#160; Notice that we are preserving the whitespace in the script.&#160; Of course nothing will happen just yet.&#160; Now we need to take the script and compile it at run time.&#160; This is where the CodeDom comes in.</p>  <p>The steps necessary to compile code at run time go a little something like this:</p>  <ul>   <li>Create a CodeCompileUnit </li>    <li>Add our namespace and import statements </li>    <li>create our dynamic class </li>    <li>add a method that will execute the Script </li>    <li>compile the code </li>    <li>execute the code </li> </ul>  <p>All these steps must be performed when the ROutedEvent is invoked, which means the code must be compiled inside the OnEventExecuted event handler.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56b1a794-ec6b-4976-9f18-e819f5a52641" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">CodeCompileUnit</span> compileUnit = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeCompileUnit</span>();<br> <br>     <span style="color:#008000">//create our namesapce and import statements, then add it to the compile unit</span><br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = CreateNamespaceAndImports();<br>     compileUnit.Namespaces.Add(namespaces);<br> <br>     <span style="color:#008000">//create our target class and add it to the namespace</span><br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = CreateTargetClass();<br>     namespaces.Types.Add(targetClass);<br> <br>     <span style="color:#008000">//create the ExecuteScript method and then add it to our class</span><br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = CreateExecuteScriptMethod();<br>     targetClass.Members.Add(executeEventMethod);<br> <br>     <span style="color:#008000">//create our compiler parameters</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = CreateCompilerParameters();<br> <br>     <span style="color:#008000">//compile the assembly</span><br>     <span style="color:#0000ff">var</span> results = CompileAssembly(compileUnit, compilerParams);<br> <br>     <span style="color:#008000">//execute the code</span><br>     ExecuteCode(results, sender, e);<br> }</div> </div> </div>  <p>The first step is really easy.&#160; We simply need to create an instance of the CodeCompileUnit class.&#160; The CodeCompileUnit references the CodeDom object graph and has properties for storing attributes, namespaces, and assemblies.&#160; Next we need to create our namespace and import statements.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b89b170-e94b-4b3b-a8d8-8df82193e6d3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the namespace and imports.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;remarks&gt;</span><span style="color:#008000">I have only added three import statements as an example. You should add all import statements required to run your dynamic code</span><span style="color:#808080">&lt;/remarks&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeNamespace</span> CreateNamespaceAndImports()<br> {<br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespace</span>(<span style="color:#a31515">&quot;WPFCodeInjection&quot;</span>);<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows.Controls&quot;</span>));<br>     <span style="color:#0000ff">return</span> namespaces;<br> }</div> </div> </div>  <p>Once the namespace and import statement are created we need to add them to out CodeCompileUnit instance.&#160; Then we need to create our dynamic class.&#160; We need to make sure it is a public class:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a495da08-da32-46e0-ba99-c5fac5d189e1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the target class.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeTypeDeclaration</span> CreateTargetClass()<br> {<br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeTypeDeclaration</span>(<span style="color:#a31515">&quot;DynamicClass&quot;</span>);<br>     targetClass.TypeAttributes = <span style="color:#2b91af">TypeAttributes</span>.Public;<br>     <span style="color:#0000ff">return</span> targetClass;<br> }</div> </div> </div>  <p>When the dynamic class is created we add it to our namespace.&#160; Now we create a method. We give it a name of ExecuteScript and set its access modifier to public.&#160; We specify that it accepts two parameters.&#160; One being the sender which is of type object, and one that is the event args that is of type RoutedEventArgs.&#160; Lastly, we set the body of the method to the Script property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4cae0858-7130-4df1-b3b1-cf49063a4d50" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the ExecuteScript method.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#2b91af">CodeMemberMethod</span> CreateExecuteScriptMethod()<br> {<br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeMemberMethod</span>();<br>     executeEventMethod.Name = <span style="color:#a31515">&quot;ExecuteScript&quot;</span>;<br>     executeEventMethod.Attributes = <span style="color:#2b91af">MemberAttributes</span>.Public | <span style="color:#2b91af">MemberAttributes</span>.Final;<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Object&quot;</span>, <span style="color:#a31515">&quot;sender&quot;</span>));<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Windows.RoutedEventArgs&quot;</span>, <span style="color:#a31515">&quot;e&quot;</span>));<br>     executeEventMethod.Statements.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeSnippetStatement</span>(Script));<br>     <span style="color:#0000ff">return</span> executeEventMethod;<br> }</div> </div> </div>  <p>Now we have to create our compiler parameters.&#160; These include adding referencing to the necessary Dlls required to run your code.&#160; We also want to specify that we want to generate the code in memory.&#160; If you wanted to you could save the assembly to a file.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cebbac90-1864-436d-8248-de681876fa83" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the compiler parameters.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerParameters</span> CreateCompilerParameters()<br> {<br>     <span style="color:#008000">//add compiler parameters and assembly references</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CompilerParameters</span>();<br>     compilerParams.CompilerOptions = <span style="color:#a31515">&quot;/target:library /optimize&quot;</span>;<br>     compilerParams.GenerateExecutable = <span style="color:#0000ff">false</span>;<br>     compilerParams.GenerateInMemory = <span style="color:#0000ff">true</span>;<br> <br>     <span style="color:#008000">//you can add references individually if you want by providing the location of the assembly</span><br>     <span style="color:#008000">//compilerParams.ReferencedAssemblies.Add(&quot;System.dll&quot;);</span><br> <br>     <span style="color:#008000">//I am lazy so I will just loop through the assemblies that are already loaded and add those</span><br>     <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Assembly</span> assembly <span style="color:#0000ff">in</span> <span style="color:#2b91af">AppDomain</span>.CurrentDomain.GetAssemblies())<br>     {<br>         <span style="color:#0000ff">try</span><br>         {<br>             <span style="color:#0000ff">string</span> location = assembly.Location;<br>             <span style="color:#0000ff">if</span> (!<span style="color:#2b91af">String</span>.IsNullOrEmpty(location))<br>                 compilerParams.ReferencedAssemblies.Add(location);<br>         }<br>         <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">NotSupportedException</span>)<br>         {<br>             <span style="color:#008000">// this happens for dynamic assemblies, so just ignore it.                     </span><br>         }<br>     }<br> <br>     <span style="color:#0000ff">return</span> compilerParams;<br> }</div> </div> </div>  <p>Now we compile the code into an assembly.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b05d391c-e1d9-47c3-b9b3-2c147f47e7bb" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Compiles the assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compileUnit&quot;&gt;</span><span style="color:#008000">The compile unit.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compilerParams&quot;&gt;</span><span style="color:#008000">The compiler params.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerResults</span> CompileAssembly(<span style="color:#2b91af">CodeCompileUnit</span> compileUnit, <span style="color:#2b91af">CompilerParameters</span> compilerParams)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">CSharpCodeProvider</span> provider = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CSharpCodeProvider</span>())<br>     {<br>         <span style="color:#008000">// =============================================================================== //</span><br>         <span style="color:#008000">// if you want to see the actual complied source code uncomment //</span><br>         <span style="color:#008000">// =============================================================================== //</span><br> <br>         <span style="color:#008000">//StringBuilder source = new StringBuilder();</span><br>         <span style="color:#008000">//StringWriter sw = new StringWriter(source);</span><br>         <span style="color:#008000">//provider.GenerateCodeFromCompileUnit(compileUnit, sw, new CodeGeneratorOptions());</span><br>         <span style="color:#008000">//string sourceCode = source.ToString();</span><br> <br>         <span style="color:#0000ff">var</span> results = provider.CompileAssemblyFromDom(compilerParams, compileUnit);<br>         <span style="color:#0000ff">return</span> results;<br>     }<br> }</div> </div> </div>  <p>The last thing we need to do is run the code that was just compiled.&#160; We will need the help of reflection to accomplish this.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09c68e9b-98f4-4334-aa9f-ecf464569e54" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Executes the ExecuteScript method from the compiled CodeDom assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;results&quot;&gt;</span><span style="color:#008000">The results.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> ExecuteCode(<span style="color:#2b91af">CompilerResults</span> results, <span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">try</span><br>     {<br>         <span style="color:#2b91af">Assembly</span> executingAssembly = results.CompiledAssembly;<br>         <span style="color:#0000ff">if</span> (executingAssembly != <span style="color:#0000ff">null</span>)<br>         {<br>             <span style="color:#008000">//create an instance of our newly compiled assembly</span><br>             <span style="color:#0000ff">object</span> assemblyInstance = executingAssembly.CreateInstance(<span style="color:#a31515">&quot;WPFCodeInjection.DynamicClass&quot;</span>);<br> <br>             <span style="color:#008000">//get our ExecuteScript method and execute it.</span><br>             <span style="color:#2b91af">MethodInfo</span> info = assemblyInstance.GetType().GetMethod(<span style="color:#a31515">&quot;ExecuteScript&quot;</span>);<br>             info.Invoke(assemblyInstance, <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[] { sender, e });<br>         }<br>     }<br>     <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">Exception</span> ex)<br>     {<br>         <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Error: An exception occurred while executing the script&quot;</span>, ex);<br>     }<br> }</div> </div> </div>  <p>That is it.&#160; Now to test this out lets create a .txt file that contains our XAML that we define above and save it CodeSnippet.txt.&#160; In our MainWindow.xaml.cs, lets handle the Loaded event and load our CodeSnippet.txt using the XamlReader.Load method.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc56e72c-6fdc-4430-afb5-4498031c46f1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">void</span> MainWindow_Loaded(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">FileStream</span> fs = <span style="color:#0000ff">new</span> <span style="color:#2b91af">FileStream</span>(<span style="color:#a31515">@&quot;./CodeSnippet.txt&quot;</span>, <span style="color:#2b91af">FileMode</span>.Open))<br>     {<br>         <span style="color:#0000ff">this</span>.Content = <span style="color:#2b91af">XamlReader</span>.Load(fs);<br>     }<br> }</div> </div> </div>  <p>Run the application is this is what it should look like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb9.png" width="174" height="179" /></a></p>  <p>Now click the button and our C# code defined within the Script property will be dynamically compiled and executed changed the text of the button to this:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb10.png" width="184" height="179" /></a></p>  <p>This is a very simple example and is not intended to be a complete solution, but it does show some of the powerful capabilities you have using WPF, XAML, and the CodeDom.&#160; Like always <a href="http://brianlagunas.com/downloads/source/WpfCodeInjection.zip">download the source</a> and start playing around.&#160; See what kind of cool stuff you can do with it.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yes you can write Inline Code in XAML</title>
		<link>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yes-you-can-write-inline-code-in-xaml</link>
		<comments>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 21:11:51 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/</guid>
		<description><![CDATA[A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete it?”.&#160; Obviously I replied yes, you absolutely can delete the code-behind file from a XAML file and the application will still work.&#160; Then they replied, “That’s cool I guess, but what about the code that needs to execute, such as event handlers?”.&#160; Naturally I brought up the fact that using MVVM you don’t use event handlers, but as most developers do, they said, “Well what if I really needed it?”.&#160; My reply to that question was, “If you really had to, it is possible to write inline code inside the XAML file”.</p>  <p>They looked at me in amazement, “Really?”.&#160; Apparently that is a little known fact about WPF.&#160; Yes, it is absolutely possible to write inline code inside a XAML page without the need for a code-behind file, and everything will work as expected.&#160; I quickly realized that his was going somewhere I didn’t want it to go.&#160; I knew what was coming next; they asked me to show them how to do it. Uggg…</p>  <p>Okay here is the deal; what I am about to show you is not recommended.&#160; It goes against everything I have been teaching in the community, but if you are curious how to actually do this, it is quit simple.</p>    <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ddf41891-b77a-41c9-89aa-aeb2944933da" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--Define the button content --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;133&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Name</span><span style="color:#0000ff">=&quot;btnExitApp&quot;</span><span style="color:#ff0000"> Click</span><span style="color:#0000ff">=&quot;btnExitApp_Clicked&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Exit Application&quot;/&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--The C# implementation of the button&#39;s Click event handler. --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>             <span style="color:#808080">private void btnExitApp_Clicked(object sender, RoutedEventArgs e)</span><br>             <span style="color:#808080">{</span><br>                 <span style="color:#808080">// Get a handle to the current app and shut it down.</span><br>                 <span style="color:#808080">Application.Current.Shutdown();</span><br>             <span style="color:#808080">}</span><br>         <span style="color:#808080">]]&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div>    <p>As you can see the code snippet above is pretty simple.&#160; You will notice that the Button has a EventHandler defined called “btnExitApp_Clicked”.&#160; Since there is no code-behind (I deleted it) you may be expecting a compile error that says it cannot find the definition for the EventHandler.&#160; But wait, we do have the event handler defined within the &lt;x:Code&gt;….&lt;/x:Code&gt; tags.</p>  <p>The &lt;x:Code&gt;….&lt;/x:Code&gt; is a directive element defined in XAML.&#160; An x:Code directive element can contain inline programming code. The code that is defined inline can interact with the XAML on the same page.&#160; Notice that the code is inside the x:Code element and that the code must be surrounded by &lt;CDATA[...]]&gt; to escape the contents for XML, so that a XAML processor (interpreting either the XAML schema or the WPF schema) will not try to interpret the contents literally as XML.</p>  <p>That is all there really is to it.&#160; There are some limitations to using inline code, for more information you can check out the <a href="http://msdn.microsoft.com/en-us/library/aa970568.aspx" target="_blank">MSDN documentation</a>.&#160; Now, I don’t want to see this in any production code.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Simple WPF Loading Animation</title>
		<link>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-wpf-loading-animation</link>
		<comments>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 03:47:21 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/</guid>
		<description><![CDATA[Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could save myself some time by just using theirs.&#160; Well, after almost an hour searching, I found nothing.&#160; So much for being a timesaver.&#160; Now, don’t get me wrong, I found a couple of WPF animations out there, but none of them really fit what I needed.&#160; So I just decided to bite the bullet and create my own.&#160; After creating the animation I decided to share the fruits of my labor so that anyone else who is looking for the same thing I was, or something similar, wouldn’t have as much trouble as I did.</p>  <p>Here is what it looks like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="loadingAnimation" border="0" alt="loadingAnimation" src="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation_thumb.jpg" width="114" height="114" /></a> </p>  <p>Here is the source: <a href="http://brianlagunas.com/downloads/source/LoadingControl.zip">Download the Loading Animation Source</a></p>  <p>I hope it is useful to someone besides me.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Debugging XAML</title>
		<link>http://elegantcode.com/2009/04/14/debugging-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-xaml</link>
		<comments>http://elegantcode.com/2009/04/14/debugging-xaml/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 01:43:01 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/04/14/debugging-xaml/</guid>
		<description><![CDATA[Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths. Lets say I have the following code snippet: &#60;StatusBar&#62; &#60;StatusBarItem&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths.</p>  <p>Lets say I have the following code snippet:</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">       <span style="color: #0000ff">&lt;</span><span style="color: #800000">TextBlock</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;{Binding Messssage}&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>
  </div>
</div>

<p></p>

<p>As you can see my property Message is totally misspelled.&#160; If I were to run this application nothing would ever appear in my status bar, and I would not know why.&#160; I didn’t get any compile errors, and my view renders perfectly in my designer, so what the hell is going on.&#160; You might spend hours looking at your object’s property, stepping through the property changed events, or just saying XAML is a piece of crap and I give up.&#160; Well never fear, I am about to reveal the secret to debugging your XAML.</p>

<p>Look in your Output Window!</p>

<p><a href="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow.jpg" target="_blank"><img title="OutputWindow" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="79" alt="OutputWindow" src="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow-thumb.jpg" width="404" border="0" /></a> </p>

<p>Yes, the nearly always forgotten Output Window.&#160; As you can see, if you click on the image above, it tells me that I have a binding expression path error and gives the line number where the error occurred.&#160; So don’t spend hours stepping through code looking for a ghost.&#160; Just check your Output Window.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/04/14/debugging-xaml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WPF String.Format in XAML with the StringFormat attribute</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinWidth&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinWidth}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinHeight&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinHeight}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderThickness&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> InputControlBorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontFamily&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontFamily}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontSize&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.HorizontalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.VerticalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.ZoomMode&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Padding&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxPaddingThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButtonStyle&quot;</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;/&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Pressed&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> FontFamily</span><span style="background:#ffffff;color:#0000ff">=&quot;Segoe UI Symbol&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;X&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;*&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;Auto&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Focused&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonVisible&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonCollapsed&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Let’s test what we have so far.&#160; Add an instance of our WatermarkTextBox control to the BlankPage.xaml.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5b472f91-aaa4-4de0-a251-52d2d2c82795" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Page</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Class</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTextBoxControl.BlankPage&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">x</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">local</span><span style="background:#ffffff;color:#0000ff">=&quot;using:WatermarkTextBoxControl&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">d</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">mc</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> mc</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Ignorable</span><span style="background:#ffffff;color:#0000ff">=&quot;d&quot;&gt;</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Page</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image5.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb5.png" width="275" height="60" /></a></p>  <p>Looks great.&#160; Just like the default Windows TextBox.&#160; Now we need to start adding our Watermark elements to it.&#160; Obviously we need a property for our Watermark.&#160; Your first thought maybe to define it as a type of string, but I want to support any element, not just text, so I will define it as a type of Object.&#160; This will allow me to nest controls inside of the Watermark property instead of being restricted to a simple string.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:db082020-3ed1-4025-b979-4d938ab172a9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;Watermark&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> Watermark</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>I also want to define a DataTemplate that will be used to define the ContentTemplate for the Watermark.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd631c4b-41c5-442b-8fb7-9704ba9c139b" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkTemplateProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000"> WatermarkTemplate</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkTemplateProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkTemplateProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Now we need to modify our control template to support our new Watermark property. We will do this by simply adding a ContentPresenter to our Template.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4431129a-2a62-4f39-abc1-6c7e0c47b874" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate price, coupon</b>, <b>Where to buy Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span></div> </div> </div>  <p>Oh, <b>effects of Betnovate</b>, <b>Is Betnovate safe</b>, and don’t forget the ContentTemplate that will define the default look for our watermark.&#160; This is placed at the top of the Generic.xaml.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baa07ca8-8bac-40b7-aece-36f27dedd0e5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>purchase Betnovate online no prescription</b>, <b>Online buy Betnovate without a prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Key</span><span style="background:#ffffff;color:#0000ff">=&quot;DefaultWatermarkTemplate&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentControl</span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">Binding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;Gray&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>And we need to set the default value in a style setter.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7175292-1fca-49aa-85ae-7ff859ab8ec2" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Buy Betnovate online cod</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DefaultWatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot; /&gt;</span></div> </div> </div>    <p>As you can see, I placed the ComtentPresenter after the ContentElement and before the DeleteButton elements.&#160; You may have also noticed that I set the visibility to Collapsed.&#160; This is because by default I want the Watermark hidden.&#160; So that means we need to add some code to show the watermark when the text box has no focus and it has no text.&#160; First we need to add some visual states to the VisualStateManager.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b482c41e-77da-4f54-ad99-4493ac8b1f73" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from canada</b>, <b>Betnovate without prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkStates&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkVisible&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkCollapsed&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Next we need to add some code to handle the GotFocus and LostFocus events of the TextBox.&#160; Start by adding event handlers for the events in the constructor.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e05e8b51-c571-48bc-9ee7-10b58950f385" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from mexico</b>, <b>Japan, craiglist, ebay, overseas, paypal</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.GotFocus += WatermarkTextBox_GotFocus;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.LostFocus += WatermarkTextBox_LostFocus;</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>Now add the code that does the heavy lifting.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:367568eb-5f40-4e4a-9861-50bab0c05329" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate brand name</b>, <b>Purchase Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_GotFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, <b>where can i buy cheapest Betnovate online</b>, <b>Canada, mexico, india</b>, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState();</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_LostFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> hasFocus = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//if our text is empty and our control doesn&#39;t have focus then show the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//otherwise the control eirther has text or has focus which in either case we need to hide the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">String</span><span style="background:#ffffff;color:#000000">.IsNullOrEmpty(Text) &amp;&amp; !hasFocus)</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkVisible&quot;</span><span style="background:#ffffff;color:#000000">); </span><span style="background:#ffffff;color:#008000">//TODO: create constants for our magic strings</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">else</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkCollapsed&quot;</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToVisualState(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> stateName, <b>herbal Betnovate</b>, <b>Taking Betnovate</b>, </span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> useTransitions = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">VisualStateManager</span><span style="background:#ffffff;color:#000000">.GoToState(</span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">, stateName, <b>rx free Betnovate</b>, <b>Order Betnovate online c.o.d</b>, useTransitions);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>One last thing is to make sure we set the visual state when the template is applied.&#160; So override the OnApplyTemplate method as follows.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d36c00a9-70e0-4692-9b7c-92d0a6de7deb" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate schedule</b>, <b>Betnovate dosage</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">override</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnApplyTemplate()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">base</span><span style="background:#ffffff;color:#000000">.OnApplyTemplate();</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//we need to set the initial state of the watermark</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>That should do it.&#160; Now let check it out in action. Be sure to provide a watermark for our control.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0630f9fd-701c-4d59-bcdb-4c659a352180" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate cost</b>, <b>Betnovate no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#ff0000"> Watermark</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb6.png" width="279" height="60" /></a></p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb7.png" width="279" height="63" /></a></p>  <h4>Yes, <b>Betnovate from mexico</b>, <b>Betnovate description</b>, we found a bug</h4>  <p>Everything seems to be working perfectly.&#160; Until you actually try to use a watermark that isn’t text.&#160; Try using this as your watermark.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c7fdd2-45ff-4ca5-86cb-5fe1adc8c10e" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>online buying Betnovate</b>, <b>Betnovate pics</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Orientation</span><span style="background:#ffffff;color:#0000ff">=&quot;Horizontal&quot;&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Image</span><span style="background:#ffffff;color:#ff0000"> Source</span><span style="background:#ffffff;color:#0000ff">=&quot;Images/PencilTool16.png&quot;</span><span style="background:#ffffff;color:#ff0000"> Stretch</span><span style="background:#ffffff;color:#0000ff">=&quot;None&quot;</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;4,0, <b>Betnovate interactions</b>, <b>Get Betnovate</b>, 0,0&quot; /&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>Now let’s see our results.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb8.png" width="275" height="60" /></a></p>  <p>Hey!&#160; Where is my watermark?&#160; Well there appears to be a bug with a ContentPresenter/ContentControl that will not display content when the ContentTemplate has been set and the Content is anything else except a string.&#160; This just so happens to be the exact same bug that exists in Silverlight.&#160; Interesting I know.&#160; So how do we fix it?&#160; We have to delete the usage of our Watermarktemplate until this gets fixed.</p>  <p>Change:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:715e6953-8e22-4e2e-8b8f-a4700760cfa9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>real brand Betnovate online</b>, <b>Betnovate steet value</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>To:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f626a1e-1d1c-489a-96cb-7f056392a0a8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>my Betnovate experience</b>, <b>Betnovate wiki</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>               <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>Now let’s see what happens.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image9.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb9.png" width="276" height="59" /></a></p>  <p>Now that’s much better.&#160; Let’s hope this is just a beta bug.</p>  <p><a href="http://brianlagunas.com/downloads/source/WatermarkTextBoxControl.zip" target="_blank">Download the source</a></p>, <b>low dose Betnovate</b>.  Order Betnovate from mexican pharmacy.  Online Betnovate without a prescription.  Betnovate long term.  Betnovate photos.  Betnovate samples.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4354'>Glucophage For Sale</a>. <a href='http://elegantcode.com/?p=4681'>Betnovate For Sale</a>. <a href='http://elegantcode.com/?p=4291'>Buy Vibramycin Without Prescription</a>. <a href='http://elegantcode.com/?p=4268'>Soma For Sale</a>. <a href='http://elegantcode.com/?p=4276'>Buy Viagra Without Prescription</a>. <a href='http://elegantcode.com/?p=4831'>Buying Glucophage online over the counter</a>. <a href='http://elegantcode.com/?p=4846'>Effects of Ketoconazole Cream</a>. <a href='http://elegantcode.com/?p=5014'>Order Quinine online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4232'>Japan, craiglist, ebay, overseas, paypal</a>. <a href='http://elegantcode.com/?p=4867'>Ordering Soma online</a>.<br />
<b>Trackbacks from:</b> <a href='http://home.officesnapshots.com/?p=250'>Buy Betnovate Without Prescription</a>. <a href='http://reversemortgagedaily.com/?p=14063'>Buy Betnovate Without Prescription</a>. <a href='http://social-blend.com/?p=1202'>Buy Betnovate Without Prescription</a>. <a href='http://www.quarterlives.com/?p=454'>Buy Betnovate Without Prescription</a>. <a href='http://4realz.net/?p=758'>Buy Betnovate Without Prescription</a>. <a href='http://blog.farmland.org/?p=3440'>Betnovate dosage</a>. <a href='http://linuxologist.com/?p=129'>Betnovate price, coupon</a>. <a href='http://www.themusclecarplace.com/?p=3456'>Betnovate no rx</a>. <a href='http://www.thegriffonnews.com/?p=10192'>Betnovate use</a>. <a href='http://www.greatgreengoods.com/?p=3270'>Kjøpe Betnovate på nett, köpa Betnovate online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; xaml</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Betnovate Without Prescription</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinWidth&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinWidth}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinHeight&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinHeight}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderThickness&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> InputControlBorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontFamily&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontFamily}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontSize&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.HorizontalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.VerticalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.ZoomMode&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Padding&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxPaddingThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButtonStyle&quot;</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;/&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Pressed&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> FontFamily</span><span style="background:#ffffff;color:#0000ff">=&quot;Segoe UI Symbol&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;X&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;*&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;Auto&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Focused&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonVisible&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonCollapsed&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Let’s test what we have so far.&#160; Add an instance of our WatermarkTextBox control to the BlankPage.xaml.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5b472f91-aaa4-4de0-a251-52d2d2c82795" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Page</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Class</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTextBoxControl.BlankPage&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">x</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">local</span><span style="background:#ffffff;color:#0000ff">=&quot;using:WatermarkTextBoxControl&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">d</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">mc</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> mc</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Ignorable</span><span style="background:#ffffff;color:#0000ff">=&quot;d&quot;&gt;</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Page</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image5.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb5.png" width="275" height="60" /></a></p>  <p>Looks great.&#160; Just like the default Windows TextBox.&#160; Now we need to start adding our Watermark elements to it.&#160; Obviously we need a property for our Watermark.&#160; Your first thought maybe to define it as a type of string, but I want to support any element, not just text, so I will define it as a type of Object.&#160; This will allow me to nest controls inside of the Watermark property instead of being restricted to a simple string.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:db082020-3ed1-4025-b979-4d938ab172a9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;Watermark&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> Watermark</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>I also want to define a DataTemplate that will be used to define the ContentTemplate for the Watermark.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd631c4b-41c5-442b-8fb7-9704ba9c139b" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkTemplateProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000"> WatermarkTemplate</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkTemplateProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkTemplateProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Now we need to modify our control template to support our new Watermark property. We will do this by simply adding a ContentPresenter to our Template.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4431129a-2a62-4f39-abc1-6c7e0c47b874" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate price, coupon</b>, <b>Where to buy Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span></div> </div> </div>  <p>Oh, <b>effects of Betnovate</b>, <b>Is Betnovate safe</b>, and don’t forget the ContentTemplate that will define the default look for our watermark.&#160; This is placed at the top of the Generic.xaml.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baa07ca8-8bac-40b7-aece-36f27dedd0e5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>purchase Betnovate online no prescription</b>, <b>Online buy Betnovate without a prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Key</span><span style="background:#ffffff;color:#0000ff">=&quot;DefaultWatermarkTemplate&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentControl</span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">Binding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;Gray&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>And we need to set the default value in a style setter.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7175292-1fca-49aa-85ae-7ff859ab8ec2" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Buy Betnovate online cod</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DefaultWatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot; /&gt;</span></div> </div> </div>    <p>As you can see, I placed the ComtentPresenter after the ContentElement and before the DeleteButton elements.&#160; You may have also noticed that I set the visibility to Collapsed.&#160; This is because by default I want the Watermark hidden.&#160; So that means we need to add some code to show the watermark when the text box has no focus and it has no text.&#160; First we need to add some visual states to the VisualStateManager.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b482c41e-77da-4f54-ad99-4493ac8b1f73" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from canada</b>, <b>Betnovate without prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkStates&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkVisible&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkCollapsed&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Next we need to add some code to handle the GotFocus and LostFocus events of the TextBox.&#160; Start by adding event handlers for the events in the constructor.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e05e8b51-c571-48bc-9ee7-10b58950f385" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from mexico</b>, <b>Japan, craiglist, ebay, overseas, paypal</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.GotFocus += WatermarkTextBox_GotFocus;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.LostFocus += WatermarkTextBox_LostFocus;</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>Now add the code that does the heavy lifting.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:367568eb-5f40-4e4a-9861-50bab0c05329" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate brand name</b>, <b>Purchase Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_GotFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, <b>where can i buy cheapest Betnovate online</b>, <b>Canada, mexico, india</b>, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState();</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_LostFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> hasFocus = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//if our text is empty and our control doesn&#39;t have focus then show the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//otherwise the control eirther has text or has focus which in either case we need to hide the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">String</span><span style="background:#ffffff;color:#000000">.IsNullOrEmpty(Text) &amp;&amp; !hasFocus)</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkVisible&quot;</span><span style="background:#ffffff;color:#000000">); </span><span style="background:#ffffff;color:#008000">//TODO: create constants for our magic strings</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">else</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkCollapsed&quot;</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToVisualState(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> stateName, <b>herbal Betnovate</b>, <b>Taking Betnovate</b>, </span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> useTransitions = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">VisualStateManager</span><span style="background:#ffffff;color:#000000">.GoToState(</span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">, stateName, <b>rx free Betnovate</b>, <b>Order Betnovate online c.o.d</b>, useTransitions);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>One last thing is to make sure we set the visual state when the template is applied.&#160; So override the OnApplyTemplate method as follows.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d36c00a9-70e0-4692-9b7c-92d0a6de7deb" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate schedule</b>, <b>Betnovate dosage</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">override</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnApplyTemplate()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">base</span><span style="background:#ffffff;color:#000000">.OnApplyTemplate();</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//we need to set the initial state of the watermark</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>That should do it.&#160; Now let check it out in action. Be sure to provide a watermark for our control.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0630f9fd-701c-4d59-bcdb-4c659a352180" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate cost</b>, <b>Betnovate no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#ff0000"> Watermark</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb6.png" width="279" height="60" /></a></p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb7.png" width="279" height="63" /></a></p>  <h4>Yes, <b>Betnovate from mexico</b>, <b>Betnovate description</b>, we found a bug</h4>  <p>Everything seems to be working perfectly.&#160; Until you actually try to use a watermark that isn’t text.&#160; Try using this as your watermark.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c7fdd2-45ff-4ca5-86cb-5fe1adc8c10e" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>online buying Betnovate</b>, <b>Betnovate pics</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Orientation</span><span style="background:#ffffff;color:#0000ff">=&quot;Horizontal&quot;&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Image</span><span style="background:#ffffff;color:#ff0000"> Source</span><span style="background:#ffffff;color:#0000ff">=&quot;Images/PencilTool16.png&quot;</span><span style="background:#ffffff;color:#ff0000"> Stretch</span><span style="background:#ffffff;color:#0000ff">=&quot;None&quot;</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;4,0, <b>Betnovate interactions</b>, <b>Get Betnovate</b>, 0,0&quot; /&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>Now let’s see our results.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb8.png" width="275" height="60" /></a></p>  <p>Hey!&#160; Where is my watermark?&#160; Well there appears to be a bug with a ContentPresenter/ContentControl that will not display content when the ContentTemplate has been set and the Content is anything else except a string.&#160; This just so happens to be the exact same bug that exists in Silverlight.&#160; Interesting I know.&#160; So how do we fix it?&#160; We have to delete the usage of our Watermarktemplate until this gets fixed.</p>  <p>Change:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:715e6953-8e22-4e2e-8b8f-a4700760cfa9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>real brand Betnovate online</b>, <b>Betnovate steet value</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>To:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f626a1e-1d1c-489a-96cb-7f056392a0a8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>my Betnovate experience</b>, <b>Betnovate wiki</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>               <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>Now let’s see what happens.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image9.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb9.png" width="276" height="59" /></a></p>  <p>Now that’s much better.&#160; Let’s hope this is just a beta bug.</p>  <p><a href="http://brianlagunas.com/downloads/source/WatermarkTextBoxControl.zip" target="_blank">Download the source</a></p>, <b>low dose Betnovate</b>.  Order Betnovate from mexican pharmacy.  Online Betnovate without a prescription.  Betnovate long term.  Betnovate photos.  Betnovate samples.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4354'>Glucophage For Sale</a>. <a href='http://elegantcode.com/?p=4681'>Betnovate For Sale</a>. <a href='http://elegantcode.com/?p=4291'>Buy Vibramycin Without Prescription</a>. <a href='http://elegantcode.com/?p=4268'>Soma For Sale</a>. <a href='http://elegantcode.com/?p=4276'>Buy Viagra Without Prescription</a>. <a href='http://elegantcode.com/?p=4831'>Buying Glucophage online over the counter</a>. <a href='http://elegantcode.com/?p=4846'>Effects of Ketoconazole Cream</a>. <a href='http://elegantcode.com/?p=5014'>Order Quinine online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4232'>Japan, craiglist, ebay, overseas, paypal</a>. <a href='http://elegantcode.com/?p=4867'>Ordering Soma online</a>.<br />
<b>Trackbacks from:</b> <a href='http://home.officesnapshots.com/?p=250'>Buy Betnovate Without Prescription</a>. <a href='http://reversemortgagedaily.com/?p=14063'>Buy Betnovate Without Prescription</a>. <a href='http://social-blend.com/?p=1202'>Buy Betnovate Without Prescription</a>. <a href='http://www.quarterlives.com/?p=454'>Buy Betnovate Without Prescription</a>. <a href='http://4realz.net/?p=758'>Buy Betnovate Without Prescription</a>. <a href='http://blog.farmland.org/?p=3440'>Betnovate dosage</a>. <a href='http://linuxologist.com/?p=129'>Betnovate price, coupon</a>. <a href='http://www.themusclecarplace.com/?p=3456'>Betnovate no rx</a>. <a href='http://www.thegriffonnews.com/?p=10192'>Betnovate use</a>. <a href='http://www.greatgreengoods.com/?p=3270'>Kjøpe Betnovate på nett, köpa Betnovate online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vermox For Sale</title>
		<link>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:51:29 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[So far we have built an earthquake application Vermox For Sale, , mapped an address using geocoding, and even Prism-fied the Bing Maps WPF control.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can [...]]]></description>
			<content:encoded><![CDATA[<p> <p>So far we have built an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earthquake application</a> <b>Vermox For Sale</b>, , <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">mapped an address</a> using geocoding, and even <a href="http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/" target="_blank">Prism-fied the Bing Maps WPF control</a>.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can create this application.</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services. </p>  <p>For this application we will be using the Geocode Service and the Route Service.&#160; The Geocode service is used to match addresses, <b>Vermox dangers</b>, <b>Vermox coupon</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>Vermox dose</b>, <b>Vermox dosage</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; The Route service is used to generate routes and driving directions based on locations or waypoints.</p>  <p>Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>Vermox pharmacy</b>.  <b>Cheap Vermox</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>ordering Vermox online</b>.  <b>Vermox from mexico</b>, </p>  <p>Open up your App.xaml. You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca628505-dd3b-4d33-ae53-ad0ea17f81a9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy no prescription Vermox online</b>, <b>Buying Vermox online over the counter</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>We need to add the Geocode and Route service to our application.&#160; First, <b>where can i buy cheapest Vermox online</b>, <b>Low dose Vermox</b>, let’s start by adding the Geocode service.&#160; Right click the project and select “Add Service Reference”.&#160; Use the following address:</p>  <p><a href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name. I called mine BingServices.&#160; Now we need to add the Route service, <b>Vermox steet value</b>, <b>No prescription Vermox online</b>, but we don’t want to add a separate service reference.&#160; Ideally we would have a single service that contained both the Geocode and Route services.&#160; Luckily there is a trick we can use to do just that.&#160; Select the Project and click the “Show All Files” button at the top of the Solution Explorer.&#160; Expand the Service Reference folder and then expand the BingServices service.&#160; Look for a file called <strong>Reference.svcmap</strong>. Open the References.svcmap and locate the MetadataSource node.&#160; It will loko something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e1e98d3-82a4-419a-a32f-707e0559123c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox duration</b>, <b>Order Vermox online overnight delivery no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Simply add a new MetatdataSource as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7291104c-336c-4f44-9a3e-5843babcba3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox schedule</b>, <b>Where can i buy Vermox online</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">2</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see we added a new MetadataSource that points to the Route service and we gave it a SourceId of 2.&#160; Now right click the service and select “Update Service Reference”.&#160; This will generate a single service proxy for both the Geocode and Route services.&#160; Pretty slick huh?</p>  <p>The next step will be to create a ViewModel that will contain an ICommand that will execute the route calculation, <b>Vermox long term</b>, <b>Vermox price</b>, properties that will represent a “To” address and a “From” address.&#160; We will also need a property for the RouteResult and for the directions we generate.&#160; Lets first create our Direction object:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0230a924-5d25-4bed-880a-8b8cca1043e9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox samples</b>, <b>After Vermox</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">Direction</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Description { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">Location</span> Location { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> }</div> </div> </div>  <p>Now we will need a make-shift delegate command (do not use in production code):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:424be6fd-5bed-4501-ac25-33db908058c2" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>doses Vermox work</b>, <b>Is Vermox safe</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span> : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span> _execute;<br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span> execute)<br>     {<br>         _execute = execute;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke();<br>     }<br> }</div> </div> </div>  <p>Now on to the ViewModel itself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d9737cbe-bea9-4b93-af31-534d3ad53cb1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox pics</b>, <b>Vermox pictures</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">RouteViewModel</span>: <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> CalculateRouteCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _from = <span style="color:#a31515">&quot;Meridian, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> From<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _from; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _from = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;From&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _to = <span style="color:#a31515">&quot;Boise, <b>Vermox used for</b>, <b>Online buy Vermox without a prescription</b>, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> To<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _to; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _to = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;To&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">RouteResult</span> _routeResult;<br>     <span style="color:#0000ff">public</span> BingServices.<span style="color:#2b91af">RouteResult</span> RouteResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _routeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _routeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;RouteResult&quot;</span>);<br>         }<br>     }<br>     <br> <br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; _directions;<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; Directions<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _directions; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _directions = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;Directions&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> RouteViewModel()<br>     {<br>         CalculateRouteCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>(CalculateRoute);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute()<br>     {<br>         <span style="color:#0000ff">var</span> from = GeocodeAddress(From);<br>         <span style="color:#0000ff">var</span> to = GeocodeAddress(To);<br> <br>         CalculateRoute(from, to);<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">GeocodeResult</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br>         BingServices.<span style="color:#2b91af">GeocodeResult</span> result = <span style="color:#0000ff">null</span>;<br> <br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Query = address;<br>             result = client.Geocode(request).Results[0];<br>         }<br> <br>         <span style="color:#0000ff">return</span> result;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute(BingServices.<span style="color:#2b91af">GeocodeResult</span> from, <b>online buying Vermox hcl</b>, <b>Vermox reviews</b>, BingServices.<span style="color:#2b91af">GeocodeResult</span> to)<br>     {<br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">RouteServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IRouteService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">RouteRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Waypoints = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;BingServices.<span style="color:#2b91af">Waypoint</span>&gt;();<br>             request.Waypoints.Add(ConvertResultToWayPoint(from));<br>             request.Waypoints.Add(ConvertResultToWayPoint(to));<br> <br>             request.Options = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteOptions</span>();<br>             request.Options.RoutePathType = BingServices.<span style="color:#2b91af">RoutePathType</span>.Points;<br> <br>             RouteResult = client.CalculateRoute(request).Result;<br>         }<br> <br>         GetDirections();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GetDirections()<br>     {<br>         Directions = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt;();<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">ItineraryItem</span> item <span style="color:#0000ff">in</span> RouteResult.Legs[0].Itinerary)<br>         {<br>             <span style="color:#0000ff">var</span> direction = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Direction</span>();<br>             direction.Description = GetDirectionText(item);<br>             direction.Location = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(item.Location.Latitude, item.Location.Longitude);<br>             Directions.Add(direction);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">string</span> GetDirectionText(BingServices.<span style="color:#2b91af">ItineraryItem</span> item)<br>     {<br>         <span style="color:#0000ff">string</span> contentString = item.Text;<br>         <span style="color:#008000">//Remove tags from the string</span><br>         <span style="color:#2b91af">Regex</span> regex = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Regex</span>(<span style="color:#a31515">&quot;&lt;(.|&#92;n)*?&gt;&quot;</span>);<br>         contentString = regex.Replace(contentString, <b>purchase Vermox for sale</b>, <b>Vermox results</b>, <span style="color:#0000ff">string</span>.Empty);<br>         <span style="color:#0000ff">return</span> contentString;<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">Waypoint</span> ConvertResultToWayPoint(BingServices.<span style="color:#2b91af">GeocodeResult</span> result)<br>     {<br>         BingServices.<span style="color:#2b91af">Waypoint</span> waypoint = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">Waypoint</span>();<br>         waypoint.Description = result.DisplayName;<br>         waypoint.Location = result.Locations[0];<br>         <span style="color:#0000ff">return</span> waypoint;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>Let’s walk though the CalculateRoute Method.&#160; First we geocode the “From” and “To” properties the same way we did in the <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">geocoding post</a>.&#160; Once we have our From and To locations we use those results to generate a RouteRequest and send that request to the Route service.&#160; The service will generate a result and we set our RouteResult property accordingly.&#160; This property will be used in data binding shortly.&#160; Next we generate an ObservableCollection&lt;Direction&gt; by looping through all the ItineraryItems in the result.&#160; </p>  <p>Now that we have generate all of our data, <b>online buying Vermox</b>, <b>Vermox forum</b>, we need to create a View that supports and displays this data, but before we do that we need to create some attached properties.&#160; Why do you ask?&#160; Well because as it stands, <b>Vermox online cod</b>, <b>Vermox no prescription</b>, the Bing Maps WPF control is not data binding friendly.&#160; So we need to enable data binding with the use of attached properties.&#160; We will need an attached property for the Route result which will be responsible for drawing the route line on the map.&#160; We will also need one for the MapLayer that will be used to contain the route line.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55925f26-554d-4793-8b07-532984d855c6" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>order Vermox from United States pharmacy</b>, <b>Vermox australia, uk, us, usa</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> RouteResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteResult&quot;</span>, <span style="color:#0000ff">typeof</span>(BingServices.<span style="color:#2b91af">RouteResult</span>), <b>Vermox gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Vermox overnight</b>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingServices.<span style="color:#2b91af">RouteResult</span> GetRouteResult(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingServices.<span style="color:#2b91af">RouteResult</span>)target.GetValue(RouteResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteResult(<span style="color:#2b91af">DependencyObject</span> target, BingServices.<span style="color:#2b91af">RouteResult</span> value)<br>     {<br>         target.SetValue(RouteResultProperty, value);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteResultChanged((<span style="color:#2b91af">Map</span>)o, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.OldValue, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.NewValue);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">Map</span> map, BingServices.<span style="color:#2b91af">RouteResult</span> oldValue, BingServices.<span style="color:#2b91af">RouteResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">MapPolyline</span> routeLine = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapPolyline</span>();<br>         routeLine.Locations = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationCollection</span>();<br>         routeLine.Opacity = 0.65;<br>         routeLine.Stroke = <span style="color:#0000ff">new</span> <span style="color:#2b91af">SolidColorBrush</span>(<span style="color:#2b91af">Colors</span>.Blue);<br>         routeLine.StrokeThickness = 5.0;<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">Location</span> loc <span style="color:#0000ff">in</span> newValue.RoutePath.Points)<br>         {<br>             routeLine.Locations.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(loc.Latitude, loc.Longitude));<br>         }<br> <br>         <span style="color:#0000ff">var</span> routeLineLayer = GetRouteLineLayer(map);<br>         <span style="color:#0000ff">if</span> (routeLineLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             routeLineLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetRouteLineLayer(map, routeLineLayer);<br>         }<br> <br>         routeLineLayer.Children.Clear();<br>         routeLineLayer.Children.Add(routeLine);<br> <br>         <span style="color:#008000">//Set the map view</span><br>         <span style="color:#2b91af">LocationRect</span> rect = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationRect</span>(routeLine.Locations[0], routeLine.Locations[routeLine.Locations.Count - 1]);<br>         map.SetView(rect);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteResult</span><br> <br>     <span style="color:#0000ff">#region</span> RouteLineLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteLineLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteLineLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteLineLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(RouteLineLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(RouteLineLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteLineLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         <span style="color:#0000ff">if</span> (!map.Children.Contains(newValue))<br>             map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteLineLayer</span><br> }</div> </div> </div>  <p>The RouteResult property simply creates a MapPolyline, loops through all the points in the result and adds the locations to the route line.&#160; It then gets the RouteLineLayer and adds it to the map.&#160; Lastly, it sets the map’s view to best fit the route line.</p>  <p>Now we are ready for the View:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:393d6882-6c78-48e8-9046-d517df235427" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">core</span><span style="color:#0000ff">=&quot;clr-namespace:BingMapsCalculateRouteDemo.Core&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;RouteTemplate&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Ellipse</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Fill</span><span style="color:#0000ff">=&quot;Red&quot;</span><span style="color:#ff0000"> Opacity</span><span style="color:#0000ff">=&quot;0.8&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.Position</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Location}</span><span style="color:#0000ff">&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.PositionOrigin</span><span style="color:#0000ff">=&quot;Center&quot;</span><br>                     <span style="color:#ff0000"> Tag</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding}</span><span style="color:#0000ff">&quot;</span><br>                     <span style="color:#ff0000"> MouseEnter</span><span style="color:#0000ff">=&quot;Route_MouseEnter&quot;</span> <br>                     <span style="color:#ff0000"> MouseLeave</span><span style="color:#0000ff">=&quot;Route_MouseLeave&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;150&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> From}</span><span style="color:#0000ff">&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> To}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Get Route&quot;</span><span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CalculateRouteCommand}</span><span style="color:#0000ff">&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=&quot;AerialWithLabels&quot;</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> VerticalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> RouteResult}</span><span style="color:#0000ff">&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteLineLayer</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ElementName</span><span style="color:#0000ff">=RouteLineLayer}&quot;</span><br>                  <span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot; &gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;RouteLineLayer&quot; /&gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapItemsControl</span><span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Directions}</span><span style="color:#0000ff">&quot;</span><br>                                      <span style="color:#ff0000"> ItemTemplate</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> RouteTemplate}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br> <br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupLayer&quot;&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopup&quot;</span><span style="color:#ff0000"> Visibility</span><span style="color:#0000ff">=&quot;Collapsed&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;15&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupText&quot;</span><span style="color:#ff0000"> FontSize</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> FontWeight</span><span style="color:#0000ff">=&quot;Bold&quot;</span><span style="color:#ff0000"> TextWrapping</span><span style="color:#0000ff">=&quot;Wrap&quot; /&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Oh and don’t forget the code behind:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:14f2277a-a347-48e8-afd6-41465898d7fe" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">partial</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span><br> {<br>     <span style="color:#0000ff">public</span> MainWindow()<br>     {<br>         InitializeComponent();<br>         DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">RouteViewModel</span>();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseEnter(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         <span style="color:#2b91af">FrameworkElement</span> pin = sender <span style="color:#0000ff">as</span> <span style="color:#2b91af">FrameworkElement</span>;<br>         <span style="color:#2b91af">MapLayer</span>.SetPosition(ContentPopup, <span style="color:#2b91af">MapLayer</span>.GetPosition(pin));<br>         <span style="color:#2b91af">MapLayer</span>.SetPositionOffset(ContentPopup, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Point</span>(20, -15));<br> <br>         <span style="color:#0000ff">var</span> location = (<span style="color:#2b91af">Direction</span>)pin.Tag;<br> <br>         ContentPopupText.Text = location.Description;<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Visible;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseLeave(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Collapsed;<br>     }<br> }</div> </div> </div>  <p>Now let’s view the fruits of our labor at runtime.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/09/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/09/image_thumb.png" width="644" height="453" /></a></p>  <p>As you can see, given a “From” and “To” address, we can draw a route line and provide turn-by-turn directions as the user hovers over the direction pins.&#160; Pretty neat huh?&#160; And it wasn’t too difficult to pull off.&#160; As always you can <a href="http://www.brianlagunas.com/downloads/source/BingMapsCalculateRouteDemo.zip">Download the Source</a> and start playing.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4306'>Buy Biaxin Without Prescription</a>. <a href='http://elegantcode.com/?p=4228'>Aricept For Sale</a>. <a href='http://elegantcode.com/?p=4340'>Atarax For Sale</a>. <a href='http://elegantcode.com/?p=5052'>Lotrisone For Sale</a>. <a href='http://elegantcode.com/?p=4407'>Buy Nexium Without Prescription</a>. <a href='http://elegantcode.com/?p=4873'>Cafergot treatment</a>. <a href='http://elegantcode.com/?p=4780'>Canada, mexico, india</a>. <a href='http://elegantcode.com/?p=4202'>Online buying Celexa</a>. <a href='http://elegantcode.com/?p=4335'>Fast shipping Differin</a>. <a href='http://elegantcode.com/?p=4205'>Purchase Allopurinol online no prescription</a>.<br />
<b>Trackbacks from:</b> <a href='http://linuxologist.com/?p=193'>Vermox For Sale</a>. <a href='http://blog.farmland.org/?p=3110'>Vermox For Sale</a>. <a href='http://home.officesnapshots.com/?p=122'>Vermox For Sale</a>. <a href='http://reversemortgagedaily.com/?p=14171'>Vermox For Sale</a>. <a href='http://social-blend.com/?p=495'>Vermox For Sale</a>. <a href='http://www.themusclecarplace.com/?p=3175'>Vermox for sale</a>. <a href='http://www.thegriffonnews.com/?p=10415'>Ordering Vermox online</a>. <a href='http://www.quarterlives.com/?p=743'>Order Vermox online c.o.d</a>. <a href='http://tayloegray.com/?p=351'>Vermox from mexico</a>. <a href='http://www.greatgreengoods.com/?p=3949'>Purchase Vermox for sale</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buy Female Pink Viagra Without Prescription</title>
		<link>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prism-fy-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 16:13:02 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[prism]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been playing around with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled [...]]]></description>
			<content:encoded><![CDATA[<p> <p>If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">playing</a> <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">around</a> with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled MapLayers at runtime using Prism.</p>  <p> <b>Buy Female Pink Viagra Without Prescription</b>, The concept is simple.&#160; We want a Bing Maps application that can be extended at runtime.&#160; By extended, I mean that I want the ability to add new elements/modules to the Map at runtime.&#160; The important thing about these elements/modules is that they can come from anywhere and they should be loosely coupled from the Map as well as other elements/modules that may exist on the Map.</p>  <p>Luckily for us this is extremely simple to accomplish.&#160; All we have to do is create a custom RegionAdapter, register it with our Prism application, and then apply it to our Bing Map control.&#160; So let’s start with the RegionAdapter.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8809704-1b89-4479-9f50-32a29a8ce6e3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapRegionAdapter</span> : <span style="color:#2b91af">RegionAdapterBase</span>&lt;<span style="color:#2b91af">Map</span>&gt;<br> {<br>     <span style="color:#0000ff">public</span> MapRegionAdapter(<span style="color:#2b91af">IRegionBehaviorFactory</span> regionBehaviorFactory)<br>         : <span style="color:#0000ff">base</span>(regionBehaviorFactory)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> Adapt(<span style="color:#2b91af">IRegion</span> region, <span style="color:#2b91af">Map</span> regionTarget)<br>     {<br>         region.Views.CollectionChanged += (s, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Add)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.NewItems)<br>                     regionTarget.Children.Add(element);<br>             }<br>             <span style="color:#0000ff">else</span> <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Remove)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.OldItems)<br>                     <span style="color:#0000ff">if</span> (regionTarget.Children.Contains(element))<br>                         regionTarget.Children.Remove(element);<br>             }<br>         };<br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">IRegion</span> CreateRegion()<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">AllActiveRegion</span>();<br>     }<br> }</div> </div> </div> </p>  <p>Now in the Bootstrapper we need to register our mapping.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fce11974-ec82-4641-ac5c-a37a9ff443df" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">RegionAdapterMappings</span> ConfigureRegionAdapterMappings()<br> {<br>     <span style="color:#2b91af">RegionAdapterMappings</span> mappings = <span style="color:#0000ff">base</span>.ConfigureRegionAdapterMappings();<br>     mappings.RegisterMapping(<span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Map</span>), Container.Resolve&lt;<span style="color:#2b91af">MapRegionAdapter</span>&gt;());<br>     <span style="color:#0000ff">return</span> mappings;<br> }</div> </div> </div> </p>  <p>Now we simply give the Map a region name. (this is actually all the shell has in it)</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a72303d9-120c-4bba-a39e-18ae1979a63a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>online Female Pink Viagra without a prescription</b>, <b>Female Pink Viagra forum</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> prism</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionManager.RegionName</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Static</span><span style="color:#ff0000"> inf</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionNames</span><span style="color:#0000ff">.MapRegion}&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40, <b>order Female Pink Viagra online overnight delivery no prescription</b>, <b>Low dose Female Pink Viagra</b>, -95&quot;</span><span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot; /&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div> </p>  <p>That is all there is to it.&#160; You can now start injecting modules onto the Map at runtime.&#160; Lets look at my two modules I am using as an example.&#160; Here is the structure of my application:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb13.png" width="305" height="190" /></a></p>  <ul>   <li>ModuleA will inject a MapPolygon in the Shape of Texas.</li>    <li>ModuleB is the Earthquake application we built in an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earlier post</a>.</li>    <li>Infrastructure is the project where shared code goes, in this case our MapRegionAdapter</li>    <li>BingMapsPrismfiedDemo is of course our shell project.</li> </ul>  <p>This is what the application looks like at runtime when both modules have been injected into it.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb14.png" width="644" height="334" /></a></p>  <p>Now I can easily add more layers to this map as I see fit.&#160; As always, <b>online buy Female Pink Viagra without a prescription</b>, <b>No prescription Female Pink Viagra online</b>, <a href="http://www.brianlagunas.com/downloads/source/BingMapsPrismfiedDemo.zip">Download the Source</a> and start playing.&#160; You may want to add MEF support as well.</p>.  Where can i find Female Pink Viagra online.  Effects of Female Pink Viagra.  Purchase Female Pink Viagra.  Female Pink Viagra over the counter.  Purchase Female Pink Viagra online.  Buy Female Pink Viagra without prescription.  Female Pink Viagra recreational.  Buy generic Female Pink Viagra.  Cheap Female Pink Viagra.  Female Pink Viagra no prescription.  Female Pink Viagra wiki.  Cheap Female Pink Viagra no rx.  Female Pink Viagra canada, mexico, india.  Buying Female Pink Viagra online over the counter.  Where to buy Female Pink Viagra.  Female Pink Viagra cost.  Female Pink Viagra from mexico.  Is Female Pink Viagra safe.  Buy Female Pink Viagra online cod.  Buy Female Pink Viagra from mexico.  Where can i order Female Pink Viagra without prescription.  Real brand Female Pink Viagra online.  Buy Female Pink Viagra from canada.  Female Pink Viagra overnight.  Female Pink Viagra use.  Order Female Pink Viagra from mexican pharmacy.  Female Pink Viagra street price.  Female Pink Viagra coupon.  Female Pink Viagra schedule.  Female Pink Viagra mg.  Female Pink Viagra interactions.  Taking Female Pink Viagra.  Female Pink Viagra used for.  Is Female Pink Viagra addictive.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4750'>Celebrex For Sale</a>. <a href='http://elegantcode.com/?p=4661'>Buy Methotrexate Without Prescription</a>. <a href='http://elegantcode.com/?p=4755'>Buy Zovirax Without Prescription</a>. <a href='http://elegantcode.com/?p=4311'>Buy Topamax Without Prescription</a>. <a href='http://elegantcode.com/?p=4476'>Modalert For Sale</a>. <a href='http://elegantcode.com/?p=4671'>Buy Quinine no prescription</a>. <a href='http://elegantcode.com/?p=4643'>Premarin duration</a>. <a href='http://elegantcode.com/?p=4340'>Purchase Atarax for sale</a>. <a href='http://elegantcode.com/?p=4732'>Abilify price</a>. <a href='http://elegantcode.com/?p=4373'>No prescription Topamax online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.thegriffonnews.com/?p=10565'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5050'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://changecamp.ca/?p=593'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://linuxologist.com/?p=450'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://blog.farmland.org/?p=1496'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.quarterlives.com/?p=930'>Female Pink Viagra brand name</a>. <a href='http://www.greatgreengoods.com/?p=3683'>Discount Female Pink Viagra</a>. <a href='http://www.macneilbmx.com/blog/?p=4935'>Female Pink Viagra pics</a>. <a href='http://social-blend.com/?p=671'>Female Pink Viagra results</a>. <a href='http://4realz.net/?p=847'>Female Pink Viagra pics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Buy Tindamax Without Prescription</title>
		<link>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-an-address-with-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:21:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[In my last post Buy Tindamax Without Prescription, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate [...]]]></description>
			<content:encoded><![CDATA[<p> <p>In my last <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">post</a> <b>Buy Tindamax Without Prescription</b>, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate maps and imagery, driving directions, distance calculations, and other location intelligence into your applications, business processes, and Web sites. </p>  <p>Let’s start with the Geocode Service which is used to match addresses, <b>buy cheap Tindamax</b>, <b>Purchase Tindamax for sale</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>my Tindamax experience</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; We will create a simple application that allows you to enter an address and place a pushpin at that location.&#160; First thing is first:</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165" target="_blank">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/" target="_blank">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services.&#160; Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>order Tindamax from United States pharmacy</b>.  <b>Online buying Tindamax</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>buy Tindamax without a prescription</b>.  <b>After Tindamax</b>, </p>  <p>Open up your App.xaml.&#160; You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c7fbbfb-a6ac-496d-a298-bddbd655ac65" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>discount Tindamax</b>, <b>Buy Tindamax no prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Now create a very simple UI that will accept an address and a button to perform the geocoding:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc9a874e-765b-4bc2-b82b-88a96f1ef84c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax treatment</b>, <b>Tindamax no rx</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>                  <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>The next thing we need to do is add a new Service Reference to the project and point to the following service:</p>  <p><a title="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc" href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name (I called mine BingMapsService) and just for fun, <b>buy Tindamax online cod</b>, <b>Generic Tindamax</b>, in the “Add Service Reference” dialog, click the “Advanced” button and click “Generate asynchronous operations”.</p>  <p>Next we need to create a ViewModel to support our View.&#160; This is a WPF application after all.&#160; This ViewModel will need a command for the button that will perform the geocoding, <b>Tindamax duration</b>, <b>Low dose Tindamax</b>, and a property that will represent the result of the service that the UI will use to map the address.&#160; It should resemble something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b09cd91-31d1-426f-a539-9fe004a3702a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax street price</b>, <b>Tindamax blogs</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">GeocodeViewModel</span> : <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> GeocodeAddressCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> _geocodeResult;<br>     <span style="color:#0000ff">public</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GeocodeResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _geocodeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _geocodeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> GeocodeViewModel()<br>     {<br>         GeocodeAddressCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>&lt;<span style="color:#2b91af">String</span>&gt;(GeocodeAddress);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>I want to point out that the DelegateCommand&lt;T&gt; is a very simple ICommand implementation and should NOT be used in production applications.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cac2fd6-5f40-4d30-b70e-39cf0eb39d77" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax wiki</b>, <b>Tindamax cost</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span>&lt;T&gt; : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span>&lt;T&gt; _execute;<br> <br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span>&lt;T&gt; execute)<br>     {<br>         _execute = execute;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke((T)parameter);<br>     }<br> }</div> </div> </div>  <p>Let’s hook our UI up to our command.&#160; it should look something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f154da3-e1a9-48e1-8dcd-53063e2268ec" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax overnight</b>, <b>Online buy Tindamax without a prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;</span> <br>                    <span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeAddressCommand}</span><span style="color:#0000ff">&quot;</span><br>                    <span style="color:#ff0000"> CommandParameter</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">, <b>where can i buy Tindamax online</b>, <b>Discount Tindamax</b>, </span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=</span>_<span style="color:#0000ff">txtAddress}&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Notice that we are using the text of the TextBox as the CommandParameter.&#160; Next, we need to implement the command:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0d2006e3-d7cf-483a-b57b-284d06ecffff" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax for sale</b>, <b>Tindamax used for</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br> {<br>     <span style="color:#0000ff">using</span> (BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>     {<br>         client.GeocodeCompleted += (o, <b>buy no prescription Tindamax online</b>, <b>Tindamax online cod</b>, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Error == <span style="color:#0000ff">null</span>)<br>             {<br>                 GeocodeResult = e.Result.Results[0];<br>             }<br>         };<br> <br>         BingMapsService.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeRequest</span>();<br>         request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>         request.Query = address;<br>         client.GeocodeAsync(request);<br>     }<br> }</div> </div> </div>  <p>In this command we are simply creating an instance of the service client, creating a GeocodeRequest, <b>Tindamax coupon</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, setting the credentials using the ApplicationId we have stored in the App.xaml, and then using the address as the Query for the request.&#160; When the call to the service is completed we are setting the GeocodeResult property to the first element in the results.</p>  <p>Now the tricky part.&#160; We want to place a Pushpin on the address that was entered and then move the map to that location.&#160; We also need to make sure that when another address is entered, <b>buying Tindamax online over the counter</b>, <b>Is Tindamax safe</b>, we clear any previous Pushpins that may exist on the map.&#160; We also have to be aware that other elements my be on the map and we don’t want to accidentally alter those elements.&#160; Oh and did I mention this was an MVVM application and this has to be done with just data binding. </p>  <p>The approach that I decided to go with is to use <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" target="_blank">Attached Properties</a>.&#160; So I created two attached properties; one for the GeocodeResult and another for a MapLayer that will be dedicated to the GeocodeResult.&#160; This will allow us to create a MapLayer that is specific to our GeocodeResut and not alter any other elements that may be on the map.&#160; Let’s check out the code.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3cc3f4e4-cbae-4ffe-93bf-4a10f2e36d08" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>herbal Tindamax</b>, <b>Tindamax price, coupon</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> GeocodeResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>, <b>buy Tindamax without a prescription</b>, <b>Buy Tindamax without prescription</b>, <span style="color:#0000ff">typeof</span>(BingMapsService.<span style="color:#2b91af">GeocodeResult</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <b>cheap Tindamax</b>, <b>Tindamax trusted pharmacy reviews</b>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GetGeocodeResult(<span style="color:#2b91af">Map</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)target.GetValue(GeocodeResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResult(<span style="color:#2b91af">Map</span> target, <b>ordering Tindamax online</b>, <b>Tindamax canada, mexico, india</b>, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> value)<br>     {<br>         target.SetValue(GeocodeResultProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultChanged((<span style="color:#2b91af">Map</span>)o, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.OldValue, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">Map</span> map, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> oldValue, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">Location</span> location = newValue.Locations.Select(x =&gt; <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(x.Latitude, x.Longitude)).First();<br> <br>         <span style="color:#2b91af">Pushpin</span> pin = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Pushpin</span>();<br>         pin.Location = location;<br>         pin.ToolTip = newValue.Address.FormattedAddress;<br> <br>         <span style="color:#0000ff">var</span> locationLayer = GetGeocodeResultLayer(map);<br>         <span style="color:#0000ff">if</span> (locationLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             locationLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetGeocodeResultLayer(map, locationLayer);<br>         }<br> <br>         locationLayer.Children.Clear();<br>         locationLayer.Children.Add(pin);<br> <br>         map.SetView(location, map.ZoomLevel);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResult</span><br> <br>     <span style="color:#0000ff">#region</span> GeocodeResultLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResultLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(GeocodeResultLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(GeocodeResultLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResultLayer</span><br> }</div> </div> </div>  <p>Notice that when the GeocodeResult changes we get the Location and create a pushpin for that location.&#160; We also set the tooltip to the FormattedAddress of the GeocodeResult.&#160; So when we hover over the pushpin we will see a nice little tooltip of the address.&#160; Next we try to get the GeocodeResultLayer from the map, if it is null this means it doesn’t exist on the map yet so we create one and assign it accordingly.&#160; We clear the layer child elemnts and then add out pushpin.&#160; The last thing we do is call the SetView method of the Map control passing in the location and the current ZoomLevel.</p>  <p>The final step is to use our AttachedProperty on the map.&#160; Be sure to create a namespace for the MapInteractivity class and define it as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72d6307a-aef3-4f70-8d47-8d4529fc74e0" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>          <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.GeocodeResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeResult}</span><span style="color:#0000ff">&quot;</span><br>          <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>One last thing.&#160; Be sure to remember to set your DataContext of your View to the ViewModel we have created:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f7d0b4f-e096-487d-8343-fb42c94c3360" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> MainWindow()<br> {<br>     InitializeComponent();<br>     DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">GeocodeViewModel</span>(); <br> }</div> </div> </div>  <p>That’s it.&#160; You now have an application the can map (geocode) an address using the Bing Maps WPF Control and the Geocoding SOAP Service.&#160; Oh and we are doing this all with MVVM and data binding which is my favorite part.&#160; Be sure to <a href="http://www.brianlagunas.com/downloads/source/bingmapsgeocodedemo.zip">Download the Source</a> and start playing around.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4746'>Buy Clindamycin Gel Without Prescription</a>. <a href='http://elegantcode.com/?p=4328'>Buy Plavix Without Prescription</a>. <a href='http://elegantcode.com/?p=4302'>Buy Phenergan Without Prescription</a>. <a href='http://elegantcode.com/?p=4460'>Buy Proscar Without Prescription</a>. <a href='http://elegantcode.com/?p=4607'>Triamterene For Sale</a>. <a href='http://elegantcode.com/?p=4751'>Diflucan street price</a>. <a href='http://elegantcode.com/?p=4372'>Nexium steet value</a>. <a href='http://elegantcode.com/?p=4475'>Metronidazole Gel from mexico</a>. <a href='http://elegantcode.com/?p=4399'>Herbal Periactin</a>. <a href='http://elegantcode.com/?p=4858'>Tramadol over the counter</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.macneilbmx.com/blog/?p=6683'>Buy Tindamax Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=3313'>Buy Tindamax Without Prescription</a>. <a href='http://www.thegriffonnews.com/?p=9133'>Buy Tindamax Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5330'>Buy Tindamax Without Prescription</a>. <a href='http://changecamp.ca/?p=592'>Buy Tindamax Without Prescription</a>. <a href='http://social-blend.com/?p=444'>Tindamax online cod</a>. <a href='http://blog.farmland.org/?p=3958'>Order Tindamax from mexican pharmacy</a>. <a href='http://4realz.net/?p=717'>Tindamax forum</a>. <a href='http://reversemortgagedaily.com/?p=14265'>Tindamax trusted pharmacy reviews</a>. <a href='http://linuxologist.com/?p=1542'>Tindamax online cod</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &#8211; dynamically compile and run event handlers within loose XAML using CodeDom</title>
		<link>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom</link>
		<comments>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:37:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[dynamic code]]></category>
		<category><![CDATA[wpd]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/</guid>
		<description><![CDATA[Last week I wrote a blog post showing how you can write inline code in XAML.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon re-tweeted that post with a link to one of his own posts on exploring new techniques for DLR script in XAML which also links [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a blog post showing how <a href="http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/" target="_blank">you can write inline code in XAML</a>.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon <a href="http://twitter.com/#!/rrelyea/status/15099827364827136" target="_blank">re-tweeted</a> that post with a link to one of his own posts on <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/11/14/exploring-new-techniques-for-dlr-script-in-xaml.aspx" target="_blank">exploring new techniques for DLR script in XAML</a> which also links to another one of his posts which shows different techniques for <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/06/03/xaml-events-in-compiled-and-uncompiled-scenarios.aspx" target="_blank">hooking up events in compiled and uncompiled scenarios</a> which in turn links to <a href="http://www.thinkbottomup.com.au/site/blog/Embedding_DLR_Scripts_in_XAML_Part_1" target="_blank">this post about embedding DLR scripts in XAML</a> written by Daniel Paull.&#160; Wow, that is a lot of linking.</p>  <p>Well, now that everyone has been given their respective credit, let’s continue.&#160; I wanted to take my last post a little further.&#160; In that post I simply created an event handler for a button click event using inline code in the x:Code directive.&#160; If you started to play with the sample code, you might have thought to yourself, “I wonder if I can load this XAML, event handler and all, from a file or database and have it still work.”.&#160; Well, if you tried it, you found the answer really quick.&#160; No!&#160; The reason is pretty simple; code must be compiled in order to execute.&#160; Therefore any code inside loose XAML will fail.&#160; Also, when using loose XAML, trying to hookup an event handler would crash your application because it is not allowed.</p>  <p>Oh, then it must not be possible? Wrong!&#160; Well, then how do you do it if the code must be compiled?&#160; Simple, we compile the code just before we run it.&#160; Say what?&#160; That’s right, let me introduce you to the <a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" target="_blank">CodeDom</a>.&#160; The CodeDom allows you to dynamically generate and compile code at runtime.&#160; Let’s get to it.</p>  <p>We need to attach event handlers to elements in loose XAML, and have them execute C# code.&#160; Each element has different events to handle, and each event will execute different code.&#160; This tells me that we need an object that contains two properties, one to specify the RoutedEvent to handle, and another to specify the c# code to execute.&#160; We also need a common event handler definition to execute whenever the RoutedEvent is invoked.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c257533-76d5-4e97-9754-1b389f8f52b5" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DynamicEvent</span><br> {<br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the routed event to execute.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The routed event.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">RoutedEvent</span> RoutedEvent { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the script to run when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The script.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Script { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Called when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br>     {<br>         <br>     }<br> }</div> </div> </div>  <p>That was simple enough.&#160; Now, in order to attach event handlers to elements in loose XAML, we need away to get around the “no event handlers allowed” limitation.&#160; To do this we can use an attached property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c6021e-2311-4633-85f8-8fcb27a9cb89" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> HandlerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;Handler&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(OnHandlerChanged));<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DynamicEvent</span> GetHandler(<span style="color:#2b91af">DependencyObject</span> obj)<br> {<br>     <span style="color:#0000ff">return</span> (<span style="color:#2b91af">DynamicEvent</span>)obj.GetValue(HandlerProperty);<br> }<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetHandler(<span style="color:#2b91af">DependencyObject</span> obj, <span style="color:#0000ff">bool</span> value)<br> {<br>     obj.SetValue(HandlerProperty, value);<br> }<br> <br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnHandlerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">UIElement</span> uie = o <span style="color:#0000ff">as</span> <span style="color:#2b91af">UIElement</span>;<br>     <span style="color:#0000ff">if</span> (uie == <span style="color:#0000ff">null</span>)<br>         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">Exception</span>(<span style="color:#a31515">&quot;Attempt to set EventHandler on non-UIElement Type&quot;</span>);<br> <br>     <span style="color:#2b91af">DynamicEvent</span> oldHandler = e.OldValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br>     <span style="color:#2b91af">DynamicEvent</span> newHandler = e.NewValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br> <br>     <span style="color:#008000">// unhook the old event</span><br>     <span style="color:#0000ff">if</span> (oldHandler != <span style="color:#0000ff">null</span>)<br>         uie.RemoveHandler(oldHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(oldHandler.OnEventExecuted));<br> <br>     <span style="color:#008000">// hook up the new</span><br>     <span style="color:#0000ff">if</span> (newHandler != <span style="color:#0000ff">null</span>)<br>         uie.AddHandler(newHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(newHandler.OnEventExecuted));<br> <br> }</div> </div> </div>  <p>This attached property allows use to attach an instance of our DynamicEvent class to our element.&#160; When the Handler attached property is set, we simple add our OnEventExecute event handler to the RoutedEvent specified in the RoutedEvent property.&#160; Now we have the basic framework needed to attach and event handler to any event on any element in loose XAML.&#160; Let’s see how to attach an event handler in XAML using this newly created DynamicEvent class.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c323adca-e880-4dd4-997e-958bccc70c3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Initial Text&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#ff0000"> RoutedEvent</span><span style="color:#0000ff">=&quot;Button.Click&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#ff0000"> xml</span><span style="color:#0000ff">:</span><span style="color:#ff0000">space</span><span style="color:#0000ff">=&quot;preserve&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>                         <span style="color:#808080">var button = sender as Button;</span><br>                         <span style="color:#808080">button.Content = &quot;Changed with Dynamic Code&quot;;</span><br>                         <span style="color:#808080">]]&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Button</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see I have added a handler for a Button’s Click event.&#160; I also provided a Script to execute when the event is invoked.&#160; Notice that we are preserving the whitespace in the script.&#160; Of course nothing will happen just yet.&#160; Now we need to take the script and compile it at run time.&#160; This is where the CodeDom comes in.</p>  <p>The steps necessary to compile code at run time go a little something like this:</p>  <ul>   <li>Create a CodeCompileUnit </li>    <li>Add our namespace and import statements </li>    <li>create our dynamic class </li>    <li>add a method that will execute the Script </li>    <li>compile the code </li>    <li>execute the code </li> </ul>  <p>All these steps must be performed when the ROutedEvent is invoked, which means the code must be compiled inside the OnEventExecuted event handler.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56b1a794-ec6b-4976-9f18-e819f5a52641" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">CodeCompileUnit</span> compileUnit = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeCompileUnit</span>();<br> <br>     <span style="color:#008000">//create our namesapce and import statements, then add it to the compile unit</span><br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = CreateNamespaceAndImports();<br>     compileUnit.Namespaces.Add(namespaces);<br> <br>     <span style="color:#008000">//create our target class and add it to the namespace</span><br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = CreateTargetClass();<br>     namespaces.Types.Add(targetClass);<br> <br>     <span style="color:#008000">//create the ExecuteScript method and then add it to our class</span><br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = CreateExecuteScriptMethod();<br>     targetClass.Members.Add(executeEventMethod);<br> <br>     <span style="color:#008000">//create our compiler parameters</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = CreateCompilerParameters();<br> <br>     <span style="color:#008000">//compile the assembly</span><br>     <span style="color:#0000ff">var</span> results = CompileAssembly(compileUnit, compilerParams);<br> <br>     <span style="color:#008000">//execute the code</span><br>     ExecuteCode(results, sender, e);<br> }</div> </div> </div>  <p>The first step is really easy.&#160; We simply need to create an instance of the CodeCompileUnit class.&#160; The CodeCompileUnit references the CodeDom object graph and has properties for storing attributes, namespaces, and assemblies.&#160; Next we need to create our namespace and import statements.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b89b170-e94b-4b3b-a8d8-8df82193e6d3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the namespace and imports.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;remarks&gt;</span><span style="color:#008000">I have only added three import statements as an example. You should add all import statements required to run your dynamic code</span><span style="color:#808080">&lt;/remarks&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeNamespace</span> CreateNamespaceAndImports()<br> {<br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespace</span>(<span style="color:#a31515">&quot;WPFCodeInjection&quot;</span>);<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows.Controls&quot;</span>));<br>     <span style="color:#0000ff">return</span> namespaces;<br> }</div> </div> </div>  <p>Once the namespace and import statement are created we need to add them to out CodeCompileUnit instance.&#160; Then we need to create our dynamic class.&#160; We need to make sure it is a public class:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a495da08-da32-46e0-ba99-c5fac5d189e1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the target class.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeTypeDeclaration</span> CreateTargetClass()<br> {<br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeTypeDeclaration</span>(<span style="color:#a31515">&quot;DynamicClass&quot;</span>);<br>     targetClass.TypeAttributes = <span style="color:#2b91af">TypeAttributes</span>.Public;<br>     <span style="color:#0000ff">return</span> targetClass;<br> }</div> </div> </div>  <p>When the dynamic class is created we add it to our namespace.&#160; Now we create a method. We give it a name of ExecuteScript and set its access modifier to public.&#160; We specify that it accepts two parameters.&#160; One being the sender which is of type object, and one that is the event args that is of type RoutedEventArgs.&#160; Lastly, we set the body of the method to the Script property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4cae0858-7130-4df1-b3b1-cf49063a4d50" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the ExecuteScript method.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#2b91af">CodeMemberMethod</span> CreateExecuteScriptMethod()<br> {<br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeMemberMethod</span>();<br>     executeEventMethod.Name = <span style="color:#a31515">&quot;ExecuteScript&quot;</span>;<br>     executeEventMethod.Attributes = <span style="color:#2b91af">MemberAttributes</span>.Public | <span style="color:#2b91af">MemberAttributes</span>.Final;<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Object&quot;</span>, <span style="color:#a31515">&quot;sender&quot;</span>));<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Windows.RoutedEventArgs&quot;</span>, <span style="color:#a31515">&quot;e&quot;</span>));<br>     executeEventMethod.Statements.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeSnippetStatement</span>(Script));<br>     <span style="color:#0000ff">return</span> executeEventMethod;<br> }</div> </div> </div>  <p>Now we have to create our compiler parameters.&#160; These include adding referencing to the necessary Dlls required to run your code.&#160; We also want to specify that we want to generate the code in memory.&#160; If you wanted to you could save the assembly to a file.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cebbac90-1864-436d-8248-de681876fa83" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the compiler parameters.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerParameters</span> CreateCompilerParameters()<br> {<br>     <span style="color:#008000">//add compiler parameters and assembly references</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CompilerParameters</span>();<br>     compilerParams.CompilerOptions = <span style="color:#a31515">&quot;/target:library /optimize&quot;</span>;<br>     compilerParams.GenerateExecutable = <span style="color:#0000ff">false</span>;<br>     compilerParams.GenerateInMemory = <span style="color:#0000ff">true</span>;<br> <br>     <span style="color:#008000">//you can add references individually if you want by providing the location of the assembly</span><br>     <span style="color:#008000">//compilerParams.ReferencedAssemblies.Add(&quot;System.dll&quot;);</span><br> <br>     <span style="color:#008000">//I am lazy so I will just loop through the assemblies that are already loaded and add those</span><br>     <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Assembly</span> assembly <span style="color:#0000ff">in</span> <span style="color:#2b91af">AppDomain</span>.CurrentDomain.GetAssemblies())<br>     {<br>         <span style="color:#0000ff">try</span><br>         {<br>             <span style="color:#0000ff">string</span> location = assembly.Location;<br>             <span style="color:#0000ff">if</span> (!<span style="color:#2b91af">String</span>.IsNullOrEmpty(location))<br>                 compilerParams.ReferencedAssemblies.Add(location);<br>         }<br>         <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">NotSupportedException</span>)<br>         {<br>             <span style="color:#008000">// this happens for dynamic assemblies, so just ignore it.                     </span><br>         }<br>     }<br> <br>     <span style="color:#0000ff">return</span> compilerParams;<br> }</div> </div> </div>  <p>Now we compile the code into an assembly.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b05d391c-e1d9-47c3-b9b3-2c147f47e7bb" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Compiles the assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compileUnit&quot;&gt;</span><span style="color:#008000">The compile unit.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compilerParams&quot;&gt;</span><span style="color:#008000">The compiler params.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerResults</span> CompileAssembly(<span style="color:#2b91af">CodeCompileUnit</span> compileUnit, <span style="color:#2b91af">CompilerParameters</span> compilerParams)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">CSharpCodeProvider</span> provider = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CSharpCodeProvider</span>())<br>     {<br>         <span style="color:#008000">// =============================================================================== //</span><br>         <span style="color:#008000">// if you want to see the actual complied source code uncomment //</span><br>         <span style="color:#008000">// =============================================================================== //</span><br> <br>         <span style="color:#008000">//StringBuilder source = new StringBuilder();</span><br>         <span style="color:#008000">//StringWriter sw = new StringWriter(source);</span><br>         <span style="color:#008000">//provider.GenerateCodeFromCompileUnit(compileUnit, sw, new CodeGeneratorOptions());</span><br>         <span style="color:#008000">//string sourceCode = source.ToString();</span><br> <br>         <span style="color:#0000ff">var</span> results = provider.CompileAssemblyFromDom(compilerParams, compileUnit);<br>         <span style="color:#0000ff">return</span> results;<br>     }<br> }</div> </div> </div>  <p>The last thing we need to do is run the code that was just compiled.&#160; We will need the help of reflection to accomplish this.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09c68e9b-98f4-4334-aa9f-ecf464569e54" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Executes the ExecuteScript method from the compiled CodeDom assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;results&quot;&gt;</span><span style="color:#008000">The results.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> ExecuteCode(<span style="color:#2b91af">CompilerResults</span> results, <span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">try</span><br>     {<br>         <span style="color:#2b91af">Assembly</span> executingAssembly = results.CompiledAssembly;<br>         <span style="color:#0000ff">if</span> (executingAssembly != <span style="color:#0000ff">null</span>)<br>         {<br>             <span style="color:#008000">//create an instance of our newly compiled assembly</span><br>             <span style="color:#0000ff">object</span> assemblyInstance = executingAssembly.CreateInstance(<span style="color:#a31515">&quot;WPFCodeInjection.DynamicClass&quot;</span>);<br> <br>             <span style="color:#008000">//get our ExecuteScript method and execute it.</span><br>             <span style="color:#2b91af">MethodInfo</span> info = assemblyInstance.GetType().GetMethod(<span style="color:#a31515">&quot;ExecuteScript&quot;</span>);<br>             info.Invoke(assemblyInstance, <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[] { sender, e });<br>         }<br>     }<br>     <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">Exception</span> ex)<br>     {<br>         <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Error: An exception occurred while executing the script&quot;</span>, ex);<br>     }<br> }</div> </div> </div>  <p>That is it.&#160; Now to test this out lets create a .txt file that contains our XAML that we define above and save it CodeSnippet.txt.&#160; In our MainWindow.xaml.cs, lets handle the Loaded event and load our CodeSnippet.txt using the XamlReader.Load method.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc56e72c-6fdc-4430-afb5-4498031c46f1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">void</span> MainWindow_Loaded(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">FileStream</span> fs = <span style="color:#0000ff">new</span> <span style="color:#2b91af">FileStream</span>(<span style="color:#a31515">@&quot;./CodeSnippet.txt&quot;</span>, <span style="color:#2b91af">FileMode</span>.Open))<br>     {<br>         <span style="color:#0000ff">this</span>.Content = <span style="color:#2b91af">XamlReader</span>.Load(fs);<br>     }<br> }</div> </div> </div>  <p>Run the application is this is what it should look like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb9.png" width="174" height="179" /></a></p>  <p>Now click the button and our C# code defined within the Script property will be dynamically compiled and executed changed the text of the button to this:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb10.png" width="184" height="179" /></a></p>  <p>This is a very simple example and is not intended to be a complete solution, but it does show some of the powerful capabilities you have using WPF, XAML, and the CodeDom.&#160; Like always <a href="http://brianlagunas.com/downloads/source/WpfCodeInjection.zip">download the source</a> and start playing around.&#160; See what kind of cool stuff you can do with it.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yes you can write Inline Code in XAML</title>
		<link>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yes-you-can-write-inline-code-in-xaml</link>
		<comments>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 21:11:51 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/</guid>
		<description><![CDATA[A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete it?”.&#160; Obviously I replied yes, you absolutely can delete the code-behind file from a XAML file and the application will still work.&#160; Then they replied, “That’s cool I guess, but what about the code that needs to execute, such as event handlers?”.&#160; Naturally I brought up the fact that using MVVM you don’t use event handlers, but as most developers do, they said, “Well what if I really needed it?”.&#160; My reply to that question was, “If you really had to, it is possible to write inline code inside the XAML file”.</p>  <p>They looked at me in amazement, “Really?”.&#160; Apparently that is a little known fact about WPF.&#160; Yes, it is absolutely possible to write inline code inside a XAML page without the need for a code-behind file, and everything will work as expected.&#160; I quickly realized that his was going somewhere I didn’t want it to go.&#160; I knew what was coming next; they asked me to show them how to do it. Uggg…</p>  <p>Okay here is the deal; what I am about to show you is not recommended.&#160; It goes against everything I have been teaching in the community, but if you are curious how to actually do this, it is quit simple.</p>    <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ddf41891-b77a-41c9-89aa-aeb2944933da" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--Define the button content --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;133&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Name</span><span style="color:#0000ff">=&quot;btnExitApp&quot;</span><span style="color:#ff0000"> Click</span><span style="color:#0000ff">=&quot;btnExitApp_Clicked&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Exit Application&quot;/&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--The C# implementation of the button&#39;s Click event handler. --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>             <span style="color:#808080">private void btnExitApp_Clicked(object sender, RoutedEventArgs e)</span><br>             <span style="color:#808080">{</span><br>                 <span style="color:#808080">// Get a handle to the current app and shut it down.</span><br>                 <span style="color:#808080">Application.Current.Shutdown();</span><br>             <span style="color:#808080">}</span><br>         <span style="color:#808080">]]&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div>    <p>As you can see the code snippet above is pretty simple.&#160; You will notice that the Button has a EventHandler defined called “btnExitApp_Clicked”.&#160; Since there is no code-behind (I deleted it) you may be expecting a compile error that says it cannot find the definition for the EventHandler.&#160; But wait, we do have the event handler defined within the &lt;x:Code&gt;….&lt;/x:Code&gt; tags.</p>  <p>The &lt;x:Code&gt;….&lt;/x:Code&gt; is a directive element defined in XAML.&#160; An x:Code directive element can contain inline programming code. The code that is defined inline can interact with the XAML on the same page.&#160; Notice that the code is inside the x:Code element and that the code must be surrounded by &lt;CDATA[...]]&gt; to escape the contents for XML, so that a XAML processor (interpreting either the XAML schema or the WPF schema) will not try to interpret the contents literally as XML.</p>  <p>That is all there really is to it.&#160; There are some limitations to using inline code, for more information you can check out the <a href="http://msdn.microsoft.com/en-us/library/aa970568.aspx" target="_blank">MSDN documentation</a>.&#160; Now, I don’t want to see this in any production code.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Simple WPF Loading Animation</title>
		<link>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-wpf-loading-animation</link>
		<comments>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 03:47:21 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/</guid>
		<description><![CDATA[Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could save myself some time by just using theirs.&#160; Well, after almost an hour searching, I found nothing.&#160; So much for being a timesaver.&#160; Now, don’t get me wrong, I found a couple of WPF animations out there, but none of them really fit what I needed.&#160; So I just decided to bite the bullet and create my own.&#160; After creating the animation I decided to share the fruits of my labor so that anyone else who is looking for the same thing I was, or something similar, wouldn’t have as much trouble as I did.</p>  <p>Here is what it looks like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="loadingAnimation" border="0" alt="loadingAnimation" src="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation_thumb.jpg" width="114" height="114" /></a> </p>  <p>Here is the source: <a href="http://brianlagunas.com/downloads/source/LoadingControl.zip">Download the Loading Animation Source</a></p>  <p>I hope it is useful to someone besides me.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Debugging XAML</title>
		<link>http://elegantcode.com/2009/04/14/debugging-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-xaml</link>
		<comments>http://elegantcode.com/2009/04/14/debugging-xaml/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 01:43:01 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/04/14/debugging-xaml/</guid>
		<description><![CDATA[Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths. Lets say I have the following code snippet: &#60;StatusBar&#62; &#60;StatusBarItem&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths.</p>  <p>Lets say I have the following code snippet:</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">       <span style="color: #0000ff">&lt;</span><span style="color: #800000">TextBlock</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;{Binding Messssage}&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>
  </div>
</div>

<p></p>

<p>As you can see my property Message is totally misspelled.&#160; If I were to run this application nothing would ever appear in my status bar, and I would not know why.&#160; I didn’t get any compile errors, and my view renders perfectly in my designer, so what the hell is going on.&#160; You might spend hours looking at your object’s property, stepping through the property changed events, or just saying XAML is a piece of crap and I give up.&#160; Well never fear, I am about to reveal the secret to debugging your XAML.</p>

<p>Look in your Output Window!</p>

<p><a href="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow.jpg" target="_blank"><img title="OutputWindow" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="79" alt="OutputWindow" src="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow-thumb.jpg" width="404" border="0" /></a> </p>

<p>Yes, the nearly always forgotten Output Window.&#160; As you can see, if you click on the image above, it tells me that I have a binding expression path error and gives the line number where the error occurred.&#160; So don’t spend hours stepping through code looking for a ghost.&#160; Just check your Output Window.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/04/14/debugging-xaml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WPF String.Format in XAML with the StringFormat attribute</title>
		<link>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:51:29 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[So far we have built an earthquake application Vermox For Sale, , mapped an address using geocoding, and even Prism-fied the Bing Maps WPF control.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can [...]]]></description>
			<content:encoded><![CDATA[<p> <p>So far we have built an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earthquake application</a> <b>Vermox For Sale</b>, , <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">mapped an address</a> using geocoding, and even <a href="http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/" target="_blank">Prism-fied the Bing Maps WPF control</a>.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can create this application.</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services. </p>  <p>For this application we will be using the Geocode Service and the Route Service.&#160; The Geocode service is used to match addresses, <b>Vermox dangers</b>, <b>Vermox coupon</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>Vermox dose</b>, <b>Vermox dosage</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; The Route service is used to generate routes and driving directions based on locations or waypoints.</p>  <p>Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>Vermox pharmacy</b>.  <b>Cheap Vermox</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>ordering Vermox online</b>.  <b>Vermox from mexico</b>, </p>  <p>Open up your App.xaml. You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca628505-dd3b-4d33-ae53-ad0ea17f81a9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy no prescription Vermox online</b>, <b>Buying Vermox online over the counter</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>We need to add the Geocode and Route service to our application.&#160; First, <b>where can i buy cheapest Vermox online</b>, <b>Low dose Vermox</b>, let’s start by adding the Geocode service.&#160; Right click the project and select “Add Service Reference”.&#160; Use the following address:</p>  <p><a href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name. I called mine BingServices.&#160; Now we need to add the Route service, <b>Vermox steet value</b>, <b>No prescription Vermox online</b>, but we don’t want to add a separate service reference.&#160; Ideally we would have a single service that contained both the Geocode and Route services.&#160; Luckily there is a trick we can use to do just that.&#160; Select the Project and click the “Show All Files” button at the top of the Solution Explorer.&#160; Expand the Service Reference folder and then expand the BingServices service.&#160; Look for a file called <strong>Reference.svcmap</strong>. Open the References.svcmap and locate the MetadataSource node.&#160; It will loko something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e1e98d3-82a4-419a-a32f-707e0559123c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox duration</b>, <b>Order Vermox online overnight delivery no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Simply add a new MetatdataSource as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7291104c-336c-4f44-9a3e-5843babcba3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox schedule</b>, <b>Where can i buy Vermox online</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">2</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see we added a new MetadataSource that points to the Route service and we gave it a SourceId of 2.&#160; Now right click the service and select “Update Service Reference”.&#160; This will generate a single service proxy for both the Geocode and Route services.&#160; Pretty slick huh?</p>  <p>The next step will be to create a ViewModel that will contain an ICommand that will execute the route calculation, <b>Vermox long term</b>, <b>Vermox price</b>, properties that will represent a “To” address and a “From” address.&#160; We will also need a property for the RouteResult and for the directions we generate.&#160; Lets first create our Direction object:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0230a924-5d25-4bed-880a-8b8cca1043e9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox samples</b>, <b>After Vermox</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">Direction</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Description { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">Location</span> Location { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> }</div> </div> </div>  <p>Now we will need a make-shift delegate command (do not use in production code):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:424be6fd-5bed-4501-ac25-33db908058c2" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>doses Vermox work</b>, <b>Is Vermox safe</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span> : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span> _execute;<br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span> execute)<br>     {<br>         _execute = execute;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke();<br>     }<br> }</div> </div> </div>  <p>Now on to the ViewModel itself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d9737cbe-bea9-4b93-af31-534d3ad53cb1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox pics</b>, <b>Vermox pictures</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">RouteViewModel</span>: <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> CalculateRouteCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _from = <span style="color:#a31515">&quot;Meridian, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> From<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _from; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _from = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;From&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _to = <span style="color:#a31515">&quot;Boise, <b>Vermox used for</b>, <b>Online buy Vermox without a prescription</b>, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> To<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _to; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _to = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;To&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">RouteResult</span> _routeResult;<br>     <span style="color:#0000ff">public</span> BingServices.<span style="color:#2b91af">RouteResult</span> RouteResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _routeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _routeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;RouteResult&quot;</span>);<br>         }<br>     }<br>     <br> <br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; _directions;<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; Directions<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _directions; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _directions = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;Directions&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> RouteViewModel()<br>     {<br>         CalculateRouteCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>(CalculateRoute);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute()<br>     {<br>         <span style="color:#0000ff">var</span> from = GeocodeAddress(From);<br>         <span style="color:#0000ff">var</span> to = GeocodeAddress(To);<br> <br>         CalculateRoute(from, to);<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">GeocodeResult</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br>         BingServices.<span style="color:#2b91af">GeocodeResult</span> result = <span style="color:#0000ff">null</span>;<br> <br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Query = address;<br>             result = client.Geocode(request).Results[0];<br>         }<br> <br>         <span style="color:#0000ff">return</span> result;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute(BingServices.<span style="color:#2b91af">GeocodeResult</span> from, <b>online buying Vermox hcl</b>, <b>Vermox reviews</b>, BingServices.<span style="color:#2b91af">GeocodeResult</span> to)<br>     {<br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">RouteServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IRouteService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">RouteRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Waypoints = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;BingServices.<span style="color:#2b91af">Waypoint</span>&gt;();<br>             request.Waypoints.Add(ConvertResultToWayPoint(from));<br>             request.Waypoints.Add(ConvertResultToWayPoint(to));<br> <br>             request.Options = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteOptions</span>();<br>             request.Options.RoutePathType = BingServices.<span style="color:#2b91af">RoutePathType</span>.Points;<br> <br>             RouteResult = client.CalculateRoute(request).Result;<br>         }<br> <br>         GetDirections();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GetDirections()<br>     {<br>         Directions = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt;();<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">ItineraryItem</span> item <span style="color:#0000ff">in</span> RouteResult.Legs[0].Itinerary)<br>         {<br>             <span style="color:#0000ff">var</span> direction = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Direction</span>();<br>             direction.Description = GetDirectionText(item);<br>             direction.Location = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(item.Location.Latitude, item.Location.Longitude);<br>             Directions.Add(direction);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">string</span> GetDirectionText(BingServices.<span style="color:#2b91af">ItineraryItem</span> item)<br>     {<br>         <span style="color:#0000ff">string</span> contentString = item.Text;<br>         <span style="color:#008000">//Remove tags from the string</span><br>         <span style="color:#2b91af">Regex</span> regex = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Regex</span>(<span style="color:#a31515">&quot;&lt;(.|&#92;n)*?&gt;&quot;</span>);<br>         contentString = regex.Replace(contentString, <b>purchase Vermox for sale</b>, <b>Vermox results</b>, <span style="color:#0000ff">string</span>.Empty);<br>         <span style="color:#0000ff">return</span> contentString;<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">Waypoint</span> ConvertResultToWayPoint(BingServices.<span style="color:#2b91af">GeocodeResult</span> result)<br>     {<br>         BingServices.<span style="color:#2b91af">Waypoint</span> waypoint = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">Waypoint</span>();<br>         waypoint.Description = result.DisplayName;<br>         waypoint.Location = result.Locations[0];<br>         <span style="color:#0000ff">return</span> waypoint;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>Let’s walk though the CalculateRoute Method.&#160; First we geocode the “From” and “To” properties the same way we did in the <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">geocoding post</a>.&#160; Once we have our From and To locations we use those results to generate a RouteRequest and send that request to the Route service.&#160; The service will generate a result and we set our RouteResult property accordingly.&#160; This property will be used in data binding shortly.&#160; Next we generate an ObservableCollection&lt;Direction&gt; by looping through all the ItineraryItems in the result.&#160; </p>  <p>Now that we have generate all of our data, <b>online buying Vermox</b>, <b>Vermox forum</b>, we need to create a View that supports and displays this data, but before we do that we need to create some attached properties.&#160; Why do you ask?&#160; Well because as it stands, <b>Vermox online cod</b>, <b>Vermox no prescription</b>, the Bing Maps WPF control is not data binding friendly.&#160; So we need to enable data binding with the use of attached properties.&#160; We will need an attached property for the Route result which will be responsible for drawing the route line on the map.&#160; We will also need one for the MapLayer that will be used to contain the route line.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55925f26-554d-4793-8b07-532984d855c6" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>order Vermox from United States pharmacy</b>, <b>Vermox australia, uk, us, usa</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> RouteResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteResult&quot;</span>, <span style="color:#0000ff">typeof</span>(BingServices.<span style="color:#2b91af">RouteResult</span>), <b>Vermox gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Vermox overnight</b>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingServices.<span style="color:#2b91af">RouteResult</span> GetRouteResult(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingServices.<span style="color:#2b91af">RouteResult</span>)target.GetValue(RouteResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteResult(<span style="color:#2b91af">DependencyObject</span> target, BingServices.<span style="color:#2b91af">RouteResult</span> value)<br>     {<br>         target.SetValue(RouteResultProperty, value);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteResultChanged((<span style="color:#2b91af">Map</span>)o, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.OldValue, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.NewValue);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">Map</span> map, BingServices.<span style="color:#2b91af">RouteResult</span> oldValue, BingServices.<span style="color:#2b91af">RouteResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">MapPolyline</span> routeLine = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapPolyline</span>();<br>         routeLine.Locations = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationCollection</span>();<br>         routeLine.Opacity = 0.65;<br>         routeLine.Stroke = <span style="color:#0000ff">new</span> <span style="color:#2b91af">SolidColorBrush</span>(<span style="color:#2b91af">Colors</span>.Blue);<br>         routeLine.StrokeThickness = 5.0;<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">Location</span> loc <span style="color:#0000ff">in</span> newValue.RoutePath.Points)<br>         {<br>             routeLine.Locations.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(loc.Latitude, loc.Longitude));<br>         }<br> <br>         <span style="color:#0000ff">var</span> routeLineLayer = GetRouteLineLayer(map);<br>         <span style="color:#0000ff">if</span> (routeLineLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             routeLineLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetRouteLineLayer(map, routeLineLayer);<br>         }<br> <br>         routeLineLayer.Children.Clear();<br>         routeLineLayer.Children.Add(routeLine);<br> <br>         <span style="color:#008000">//Set the map view</span><br>         <span style="color:#2b91af">LocationRect</span> rect = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationRect</span>(routeLine.Locations[0], routeLine.Locations[routeLine.Locations.Count - 1]);<br>         map.SetView(rect);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteResult</span><br> <br>     <span style="color:#0000ff">#region</span> RouteLineLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteLineLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteLineLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteLineLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(RouteLineLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(RouteLineLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteLineLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         <span style="color:#0000ff">if</span> (!map.Children.Contains(newValue))<br>             map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteLineLayer</span><br> }</div> </div> </div>  <p>The RouteResult property simply creates a MapPolyline, loops through all the points in the result and adds the locations to the route line.&#160; It then gets the RouteLineLayer and adds it to the map.&#160; Lastly, it sets the map’s view to best fit the route line.</p>  <p>Now we are ready for the View:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:393d6882-6c78-48e8-9046-d517df235427" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">core</span><span style="color:#0000ff">=&quot;clr-namespace:BingMapsCalculateRouteDemo.Core&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;RouteTemplate&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Ellipse</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Fill</span><span style="color:#0000ff">=&quot;Red&quot;</span><span style="color:#ff0000"> Opacity</span><span style="color:#0000ff">=&quot;0.8&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.Position</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Location}</span><span style="color:#0000ff">&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.PositionOrigin</span><span style="color:#0000ff">=&quot;Center&quot;</span><br>                     <span style="color:#ff0000"> Tag</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding}</span><span style="color:#0000ff">&quot;</span><br>                     <span style="color:#ff0000"> MouseEnter</span><span style="color:#0000ff">=&quot;Route_MouseEnter&quot;</span> <br>                     <span style="color:#ff0000"> MouseLeave</span><span style="color:#0000ff">=&quot;Route_MouseLeave&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;150&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> From}</span><span style="color:#0000ff">&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> To}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Get Route&quot;</span><span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CalculateRouteCommand}</span><span style="color:#0000ff">&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=&quot;AerialWithLabels&quot;</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> VerticalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> RouteResult}</span><span style="color:#0000ff">&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteLineLayer</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ElementName</span><span style="color:#0000ff">=RouteLineLayer}&quot;</span><br>                  <span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot; &gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;RouteLineLayer&quot; /&gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapItemsControl</span><span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Directions}</span><span style="color:#0000ff">&quot;</span><br>                                      <span style="color:#ff0000"> ItemTemplate</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> RouteTemplate}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br> <br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupLayer&quot;&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopup&quot;</span><span style="color:#ff0000"> Visibility</span><span style="color:#0000ff">=&quot;Collapsed&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;15&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupText&quot;</span><span style="color:#ff0000"> FontSize</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> FontWeight</span><span style="color:#0000ff">=&quot;Bold&quot;</span><span style="color:#ff0000"> TextWrapping</span><span style="color:#0000ff">=&quot;Wrap&quot; /&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Oh and don’t forget the code behind:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:14f2277a-a347-48e8-afd6-41465898d7fe" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">partial</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span><br> {<br>     <span style="color:#0000ff">public</span> MainWindow()<br>     {<br>         InitializeComponent();<br>         DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">RouteViewModel</span>();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseEnter(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         <span style="color:#2b91af">FrameworkElement</span> pin = sender <span style="color:#0000ff">as</span> <span style="color:#2b91af">FrameworkElement</span>;<br>         <span style="color:#2b91af">MapLayer</span>.SetPosition(ContentPopup, <span style="color:#2b91af">MapLayer</span>.GetPosition(pin));<br>         <span style="color:#2b91af">MapLayer</span>.SetPositionOffset(ContentPopup, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Point</span>(20, -15));<br> <br>         <span style="color:#0000ff">var</span> location = (<span style="color:#2b91af">Direction</span>)pin.Tag;<br> <br>         ContentPopupText.Text = location.Description;<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Visible;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseLeave(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Collapsed;<br>     }<br> }</div> </div> </div>  <p>Now let’s view the fruits of our labor at runtime.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/09/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/09/image_thumb.png" width="644" height="453" /></a></p>  <p>As you can see, given a “From” and “To” address, we can draw a route line and provide turn-by-turn directions as the user hovers over the direction pins.&#160; Pretty neat huh?&#160; And it wasn’t too difficult to pull off.&#160; As always you can <a href="http://www.brianlagunas.com/downloads/source/BingMapsCalculateRouteDemo.zip">Download the Source</a> and start playing.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4306'>Buy Biaxin Without Prescription</a>. <a href='http://elegantcode.com/?p=4228'>Aricept For Sale</a>. <a href='http://elegantcode.com/?p=4340'>Atarax For Sale</a>. <a href='http://elegantcode.com/?p=5052'>Lotrisone For Sale</a>. <a href='http://elegantcode.com/?p=4407'>Buy Nexium Without Prescription</a>. <a href='http://elegantcode.com/?p=4873'>Cafergot treatment</a>. <a href='http://elegantcode.com/?p=4780'>Canada, mexico, india</a>. <a href='http://elegantcode.com/?p=4202'>Online buying Celexa</a>. <a href='http://elegantcode.com/?p=4335'>Fast shipping Differin</a>. <a href='http://elegantcode.com/?p=4205'>Purchase Allopurinol online no prescription</a>.<br />
<b>Trackbacks from:</b> <a href='http://linuxologist.com/?p=193'>Vermox For Sale</a>. <a href='http://blog.farmland.org/?p=3110'>Vermox For Sale</a>. <a href='http://home.officesnapshots.com/?p=122'>Vermox For Sale</a>. <a href='http://reversemortgagedaily.com/?p=14171'>Vermox For Sale</a>. <a href='http://social-blend.com/?p=495'>Vermox For Sale</a>. <a href='http://www.themusclecarplace.com/?p=3175'>Vermox for sale</a>. <a href='http://www.thegriffonnews.com/?p=10415'>Ordering Vermox online</a>. <a href='http://www.quarterlives.com/?p=743'>Order Vermox online c.o.d</a>. <a href='http://tayloegray.com/?p=351'>Vermox from mexico</a>. <a href='http://www.greatgreengoods.com/?p=3949'>Purchase Vermox for sale</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; xaml</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Betnovate Without Prescription</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinWidth&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinWidth}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinHeight&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinHeight}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderThickness&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> InputControlBorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontFamily&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontFamily}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontSize&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.HorizontalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.VerticalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.ZoomMode&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Padding&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxPaddingThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButtonStyle&quot;</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;/&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Pressed&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> FontFamily</span><span style="background:#ffffff;color:#0000ff">=&quot;Segoe UI Symbol&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;X&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;*&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;Auto&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Focused&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonVisible&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonCollapsed&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Let’s test what we have so far.&#160; Add an instance of our WatermarkTextBox control to the BlankPage.xaml.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5b472f91-aaa4-4de0-a251-52d2d2c82795" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Page</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Class</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTextBoxControl.BlankPage&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">x</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">local</span><span style="background:#ffffff;color:#0000ff">=&quot;using:WatermarkTextBoxControl&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">d</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">mc</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> mc</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Ignorable</span><span style="background:#ffffff;color:#0000ff">=&quot;d&quot;&gt;</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Page</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image5.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb5.png" width="275" height="60" /></a></p>  <p>Looks great.&#160; Just like the default Windows TextBox.&#160; Now we need to start adding our Watermark elements to it.&#160; Obviously we need a property for our Watermark.&#160; Your first thought maybe to define it as a type of string, but I want to support any element, not just text, so I will define it as a type of Object.&#160; This will allow me to nest controls inside of the Watermark property instead of being restricted to a simple string.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:db082020-3ed1-4025-b979-4d938ab172a9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;Watermark&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> Watermark</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>I also want to define a DataTemplate that will be used to define the ContentTemplate for the Watermark.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd631c4b-41c5-442b-8fb7-9704ba9c139b" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkTemplateProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000"> WatermarkTemplate</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkTemplateProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkTemplateProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Now we need to modify our control template to support our new Watermark property. We will do this by simply adding a ContentPresenter to our Template.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4431129a-2a62-4f39-abc1-6c7e0c47b874" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate price, coupon</b>, <b>Where to buy Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span></div> </div> </div>  <p>Oh, <b>effects of Betnovate</b>, <b>Is Betnovate safe</b>, and don’t forget the ContentTemplate that will define the default look for our watermark.&#160; This is placed at the top of the Generic.xaml.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baa07ca8-8bac-40b7-aece-36f27dedd0e5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>purchase Betnovate online no prescription</b>, <b>Online buy Betnovate without a prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Key</span><span style="background:#ffffff;color:#0000ff">=&quot;DefaultWatermarkTemplate&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentControl</span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">Binding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;Gray&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>And we need to set the default value in a style setter.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7175292-1fca-49aa-85ae-7ff859ab8ec2" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Buy Betnovate online cod</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DefaultWatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot; /&gt;</span></div> </div> </div>    <p>As you can see, I placed the ComtentPresenter after the ContentElement and before the DeleteButton elements.&#160; You may have also noticed that I set the visibility to Collapsed.&#160; This is because by default I want the Watermark hidden.&#160; So that means we need to add some code to show the watermark when the text box has no focus and it has no text.&#160; First we need to add some visual states to the VisualStateManager.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b482c41e-77da-4f54-ad99-4493ac8b1f73" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from canada</b>, <b>Betnovate without prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkStates&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkVisible&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkCollapsed&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Next we need to add some code to handle the GotFocus and LostFocus events of the TextBox.&#160; Start by adding event handlers for the events in the constructor.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e05e8b51-c571-48bc-9ee7-10b58950f385" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from mexico</b>, <b>Japan, craiglist, ebay, overseas, paypal</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.GotFocus += WatermarkTextBox_GotFocus;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.LostFocus += WatermarkTextBox_LostFocus;</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>Now add the code that does the heavy lifting.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:367568eb-5f40-4e4a-9861-50bab0c05329" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate brand name</b>, <b>Purchase Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_GotFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, <b>where can i buy cheapest Betnovate online</b>, <b>Canada, mexico, india</b>, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState();</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_LostFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> hasFocus = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//if our text is empty and our control doesn&#39;t have focus then show the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//otherwise the control eirther has text or has focus which in either case we need to hide the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">String</span><span style="background:#ffffff;color:#000000">.IsNullOrEmpty(Text) &amp;&amp; !hasFocus)</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkVisible&quot;</span><span style="background:#ffffff;color:#000000">); </span><span style="background:#ffffff;color:#008000">//TODO: create constants for our magic strings</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">else</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkCollapsed&quot;</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToVisualState(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> stateName, <b>herbal Betnovate</b>, <b>Taking Betnovate</b>, </span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> useTransitions = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">VisualStateManager</span><span style="background:#ffffff;color:#000000">.GoToState(</span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">, stateName, <b>rx free Betnovate</b>, <b>Order Betnovate online c.o.d</b>, useTransitions);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>One last thing is to make sure we set the visual state when the template is applied.&#160; So override the OnApplyTemplate method as follows.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d36c00a9-70e0-4692-9b7c-92d0a6de7deb" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate schedule</b>, <b>Betnovate dosage</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">override</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnApplyTemplate()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">base</span><span style="background:#ffffff;color:#000000">.OnApplyTemplate();</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//we need to set the initial state of the watermark</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>That should do it.&#160; Now let check it out in action. Be sure to provide a watermark for our control.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0630f9fd-701c-4d59-bcdb-4c659a352180" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate cost</b>, <b>Betnovate no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#ff0000"> Watermark</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb6.png" width="279" height="60" /></a></p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb7.png" width="279" height="63" /></a></p>  <h4>Yes, <b>Betnovate from mexico</b>, <b>Betnovate description</b>, we found a bug</h4>  <p>Everything seems to be working perfectly.&#160; Until you actually try to use a watermark that isn’t text.&#160; Try using this as your watermark.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c7fdd2-45ff-4ca5-86cb-5fe1adc8c10e" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>online buying Betnovate</b>, <b>Betnovate pics</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Orientation</span><span style="background:#ffffff;color:#0000ff">=&quot;Horizontal&quot;&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Image</span><span style="background:#ffffff;color:#ff0000"> Source</span><span style="background:#ffffff;color:#0000ff">=&quot;Images/PencilTool16.png&quot;</span><span style="background:#ffffff;color:#ff0000"> Stretch</span><span style="background:#ffffff;color:#0000ff">=&quot;None&quot;</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;4,0, <b>Betnovate interactions</b>, <b>Get Betnovate</b>, 0,0&quot; /&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>Now let’s see our results.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb8.png" width="275" height="60" /></a></p>  <p>Hey!&#160; Where is my watermark?&#160; Well there appears to be a bug with a ContentPresenter/ContentControl that will not display content when the ContentTemplate has been set and the Content is anything else except a string.&#160; This just so happens to be the exact same bug that exists in Silverlight.&#160; Interesting I know.&#160; So how do we fix it?&#160; We have to delete the usage of our Watermarktemplate until this gets fixed.</p>  <p>Change:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:715e6953-8e22-4e2e-8b8f-a4700760cfa9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>real brand Betnovate online</b>, <b>Betnovate steet value</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>To:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f626a1e-1d1c-489a-96cb-7f056392a0a8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>my Betnovate experience</b>, <b>Betnovate wiki</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>               <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>Now let’s see what happens.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image9.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb9.png" width="276" height="59" /></a></p>  <p>Now that’s much better.&#160; Let’s hope this is just a beta bug.</p>  <p><a href="http://brianlagunas.com/downloads/source/WatermarkTextBoxControl.zip" target="_blank">Download the source</a></p>, <b>low dose Betnovate</b>.  Order Betnovate from mexican pharmacy.  Online Betnovate without a prescription.  Betnovate long term.  Betnovate photos.  Betnovate samples.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4354'>Glucophage For Sale</a>. <a href='http://elegantcode.com/?p=4681'>Betnovate For Sale</a>. <a href='http://elegantcode.com/?p=4291'>Buy Vibramycin Without Prescription</a>. <a href='http://elegantcode.com/?p=4268'>Soma For Sale</a>. <a href='http://elegantcode.com/?p=4276'>Buy Viagra Without Prescription</a>. <a href='http://elegantcode.com/?p=4831'>Buying Glucophage online over the counter</a>. <a href='http://elegantcode.com/?p=4846'>Effects of Ketoconazole Cream</a>. <a href='http://elegantcode.com/?p=5014'>Order Quinine online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4232'>Japan, craiglist, ebay, overseas, paypal</a>. <a href='http://elegantcode.com/?p=4867'>Ordering Soma online</a>.<br />
<b>Trackbacks from:</b> <a href='http://home.officesnapshots.com/?p=250'>Buy Betnovate Without Prescription</a>. <a href='http://reversemortgagedaily.com/?p=14063'>Buy Betnovate Without Prescription</a>. <a href='http://social-blend.com/?p=1202'>Buy Betnovate Without Prescription</a>. <a href='http://www.quarterlives.com/?p=454'>Buy Betnovate Without Prescription</a>. <a href='http://4realz.net/?p=758'>Buy Betnovate Without Prescription</a>. <a href='http://blog.farmland.org/?p=3440'>Betnovate dosage</a>. <a href='http://linuxologist.com/?p=129'>Betnovate price, coupon</a>. <a href='http://www.themusclecarplace.com/?p=3456'>Betnovate no rx</a>. <a href='http://www.thegriffonnews.com/?p=10192'>Betnovate use</a>. <a href='http://www.greatgreengoods.com/?p=3270'>Kjøpe Betnovate på nett, köpa Betnovate online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vermox For Sale</title>
		<link>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:51:29 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[So far we have built an earthquake application Vermox For Sale, , mapped an address using geocoding, and even Prism-fied the Bing Maps WPF control.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can [...]]]></description>
			<content:encoded><![CDATA[<p> <p>So far we have built an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earthquake application</a> <b>Vermox For Sale</b>, , <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">mapped an address</a> using geocoding, and even <a href="http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/" target="_blank">Prism-fied the Bing Maps WPF control</a>.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can create this application.</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services. </p>  <p>For this application we will be using the Geocode Service and the Route Service.&#160; The Geocode service is used to match addresses, <b>Vermox dangers</b>, <b>Vermox coupon</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>Vermox dose</b>, <b>Vermox dosage</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; The Route service is used to generate routes and driving directions based on locations or waypoints.</p>  <p>Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>Vermox pharmacy</b>.  <b>Cheap Vermox</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>ordering Vermox online</b>.  <b>Vermox from mexico</b>, </p>  <p>Open up your App.xaml. You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca628505-dd3b-4d33-ae53-ad0ea17f81a9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy no prescription Vermox online</b>, <b>Buying Vermox online over the counter</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>We need to add the Geocode and Route service to our application.&#160; First, <b>where can i buy cheapest Vermox online</b>, <b>Low dose Vermox</b>, let’s start by adding the Geocode service.&#160; Right click the project and select “Add Service Reference”.&#160; Use the following address:</p>  <p><a href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name. I called mine BingServices.&#160; Now we need to add the Route service, <b>Vermox steet value</b>, <b>No prescription Vermox online</b>, but we don’t want to add a separate service reference.&#160; Ideally we would have a single service that contained both the Geocode and Route services.&#160; Luckily there is a trick we can use to do just that.&#160; Select the Project and click the “Show All Files” button at the top of the Solution Explorer.&#160; Expand the Service Reference folder and then expand the BingServices service.&#160; Look for a file called <strong>Reference.svcmap</strong>. Open the References.svcmap and locate the MetadataSource node.&#160; It will loko something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e1e98d3-82a4-419a-a32f-707e0559123c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox duration</b>, <b>Order Vermox online overnight delivery no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Simply add a new MetatdataSource as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7291104c-336c-4f44-9a3e-5843babcba3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox schedule</b>, <b>Where can i buy Vermox online</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">2</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see we added a new MetadataSource that points to the Route service and we gave it a SourceId of 2.&#160; Now right click the service and select “Update Service Reference”.&#160; This will generate a single service proxy for both the Geocode and Route services.&#160; Pretty slick huh?</p>  <p>The next step will be to create a ViewModel that will contain an ICommand that will execute the route calculation, <b>Vermox long term</b>, <b>Vermox price</b>, properties that will represent a “To” address and a “From” address.&#160; We will also need a property for the RouteResult and for the directions we generate.&#160; Lets first create our Direction object:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0230a924-5d25-4bed-880a-8b8cca1043e9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox samples</b>, <b>After Vermox</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">Direction</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Description { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">Location</span> Location { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> }</div> </div> </div>  <p>Now we will need a make-shift delegate command (do not use in production code):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:424be6fd-5bed-4501-ac25-33db908058c2" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>doses Vermox work</b>, <b>Is Vermox safe</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span> : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span> _execute;<br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span> execute)<br>     {<br>         _execute = execute;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke();<br>     }<br> }</div> </div> </div>  <p>Now on to the ViewModel itself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d9737cbe-bea9-4b93-af31-534d3ad53cb1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox pics</b>, <b>Vermox pictures</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">RouteViewModel</span>: <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> CalculateRouteCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _from = <span style="color:#a31515">&quot;Meridian, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> From<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _from; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _from = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;From&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _to = <span style="color:#a31515">&quot;Boise, <b>Vermox used for</b>, <b>Online buy Vermox without a prescription</b>, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> To<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _to; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _to = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;To&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">RouteResult</span> _routeResult;<br>     <span style="color:#0000ff">public</span> BingServices.<span style="color:#2b91af">RouteResult</span> RouteResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _routeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _routeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;RouteResult&quot;</span>);<br>         }<br>     }<br>     <br> <br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; _directions;<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; Directions<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _directions; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _directions = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;Directions&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> RouteViewModel()<br>     {<br>         CalculateRouteCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>(CalculateRoute);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute()<br>     {<br>         <span style="color:#0000ff">var</span> from = GeocodeAddress(From);<br>         <span style="color:#0000ff">var</span> to = GeocodeAddress(To);<br> <br>         CalculateRoute(from, to);<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">GeocodeResult</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br>         BingServices.<span style="color:#2b91af">GeocodeResult</span> result = <span style="color:#0000ff">null</span>;<br> <br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Query = address;<br>             result = client.Geocode(request).Results[0];<br>         }<br> <br>         <span style="color:#0000ff">return</span> result;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute(BingServices.<span style="color:#2b91af">GeocodeResult</span> from, <b>online buying Vermox hcl</b>, <b>Vermox reviews</b>, BingServices.<span style="color:#2b91af">GeocodeResult</span> to)<br>     {<br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">RouteServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IRouteService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">RouteRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Waypoints = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;BingServices.<span style="color:#2b91af">Waypoint</span>&gt;();<br>             request.Waypoints.Add(ConvertResultToWayPoint(from));<br>             request.Waypoints.Add(ConvertResultToWayPoint(to));<br> <br>             request.Options = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteOptions</span>();<br>             request.Options.RoutePathType = BingServices.<span style="color:#2b91af">RoutePathType</span>.Points;<br> <br>             RouteResult = client.CalculateRoute(request).Result;<br>         }<br> <br>         GetDirections();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GetDirections()<br>     {<br>         Directions = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt;();<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">ItineraryItem</span> item <span style="color:#0000ff">in</span> RouteResult.Legs[0].Itinerary)<br>         {<br>             <span style="color:#0000ff">var</span> direction = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Direction</span>();<br>             direction.Description = GetDirectionText(item);<br>             direction.Location = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(item.Location.Latitude, item.Location.Longitude);<br>             Directions.Add(direction);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">string</span> GetDirectionText(BingServices.<span style="color:#2b91af">ItineraryItem</span> item)<br>     {<br>         <span style="color:#0000ff">string</span> contentString = item.Text;<br>         <span style="color:#008000">//Remove tags from the string</span><br>         <span style="color:#2b91af">Regex</span> regex = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Regex</span>(<span style="color:#a31515">&quot;&lt;(.|&#92;n)*?&gt;&quot;</span>);<br>         contentString = regex.Replace(contentString, <b>purchase Vermox for sale</b>, <b>Vermox results</b>, <span style="color:#0000ff">string</span>.Empty);<br>         <span style="color:#0000ff">return</span> contentString;<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">Waypoint</span> ConvertResultToWayPoint(BingServices.<span style="color:#2b91af">GeocodeResult</span> result)<br>     {<br>         BingServices.<span style="color:#2b91af">Waypoint</span> waypoint = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">Waypoint</span>();<br>         waypoint.Description = result.DisplayName;<br>         waypoint.Location = result.Locations[0];<br>         <span style="color:#0000ff">return</span> waypoint;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>Let’s walk though the CalculateRoute Method.&#160; First we geocode the “From” and “To” properties the same way we did in the <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">geocoding post</a>.&#160; Once we have our From and To locations we use those results to generate a RouteRequest and send that request to the Route service.&#160; The service will generate a result and we set our RouteResult property accordingly.&#160; This property will be used in data binding shortly.&#160; Next we generate an ObservableCollection&lt;Direction&gt; by looping through all the ItineraryItems in the result.&#160; </p>  <p>Now that we have generate all of our data, <b>online buying Vermox</b>, <b>Vermox forum</b>, we need to create a View that supports and displays this data, but before we do that we need to create some attached properties.&#160; Why do you ask?&#160; Well because as it stands, <b>Vermox online cod</b>, <b>Vermox no prescription</b>, the Bing Maps WPF control is not data binding friendly.&#160; So we need to enable data binding with the use of attached properties.&#160; We will need an attached property for the Route result which will be responsible for drawing the route line on the map.&#160; We will also need one for the MapLayer that will be used to contain the route line.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55925f26-554d-4793-8b07-532984d855c6" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>order Vermox from United States pharmacy</b>, <b>Vermox australia, uk, us, usa</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> RouteResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteResult&quot;</span>, <span style="color:#0000ff">typeof</span>(BingServices.<span style="color:#2b91af">RouteResult</span>), <b>Vermox gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Vermox overnight</b>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingServices.<span style="color:#2b91af">RouteResult</span> GetRouteResult(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingServices.<span style="color:#2b91af">RouteResult</span>)target.GetValue(RouteResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteResult(<span style="color:#2b91af">DependencyObject</span> target, BingServices.<span style="color:#2b91af">RouteResult</span> value)<br>     {<br>         target.SetValue(RouteResultProperty, value);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteResultChanged((<span style="color:#2b91af">Map</span>)o, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.OldValue, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.NewValue);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">Map</span> map, BingServices.<span style="color:#2b91af">RouteResult</span> oldValue, BingServices.<span style="color:#2b91af">RouteResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">MapPolyline</span> routeLine = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapPolyline</span>();<br>         routeLine.Locations = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationCollection</span>();<br>         routeLine.Opacity = 0.65;<br>         routeLine.Stroke = <span style="color:#0000ff">new</span> <span style="color:#2b91af">SolidColorBrush</span>(<span style="color:#2b91af">Colors</span>.Blue);<br>         routeLine.StrokeThickness = 5.0;<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">Location</span> loc <span style="color:#0000ff">in</span> newValue.RoutePath.Points)<br>         {<br>             routeLine.Locations.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(loc.Latitude, loc.Longitude));<br>         }<br> <br>         <span style="color:#0000ff">var</span> routeLineLayer = GetRouteLineLayer(map);<br>         <span style="color:#0000ff">if</span> (routeLineLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             routeLineLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetRouteLineLayer(map, routeLineLayer);<br>         }<br> <br>         routeLineLayer.Children.Clear();<br>         routeLineLayer.Children.Add(routeLine);<br> <br>         <span style="color:#008000">//Set the map view</span><br>         <span style="color:#2b91af">LocationRect</span> rect = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationRect</span>(routeLine.Locations[0], routeLine.Locations[routeLine.Locations.Count - 1]);<br>         map.SetView(rect);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteResult</span><br> <br>     <span style="color:#0000ff">#region</span> RouteLineLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteLineLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteLineLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteLineLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(RouteLineLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(RouteLineLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteLineLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         <span style="color:#0000ff">if</span> (!map.Children.Contains(newValue))<br>             map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteLineLayer</span><br> }</div> </div> </div>  <p>The RouteResult property simply creates a MapPolyline, loops through all the points in the result and adds the locations to the route line.&#160; It then gets the RouteLineLayer and adds it to the map.&#160; Lastly, it sets the map’s view to best fit the route line.</p>  <p>Now we are ready for the View:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:393d6882-6c78-48e8-9046-d517df235427" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">core</span><span style="color:#0000ff">=&quot;clr-namespace:BingMapsCalculateRouteDemo.Core&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;RouteTemplate&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Ellipse</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Fill</span><span style="color:#0000ff">=&quot;Red&quot;</span><span style="color:#ff0000"> Opacity</span><span style="color:#0000ff">=&quot;0.8&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.Position</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Location}</span><span style="color:#0000ff">&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.PositionOrigin</span><span style="color:#0000ff">=&quot;Center&quot;</span><br>                     <span style="color:#ff0000"> Tag</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding}</span><span style="color:#0000ff">&quot;</span><br>                     <span style="color:#ff0000"> MouseEnter</span><span style="color:#0000ff">=&quot;Route_MouseEnter&quot;</span> <br>                     <span style="color:#ff0000"> MouseLeave</span><span style="color:#0000ff">=&quot;Route_MouseLeave&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;150&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> From}</span><span style="color:#0000ff">&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> To}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Get Route&quot;</span><span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CalculateRouteCommand}</span><span style="color:#0000ff">&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=&quot;AerialWithLabels&quot;</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> VerticalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> RouteResult}</span><span style="color:#0000ff">&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteLineLayer</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ElementName</span><span style="color:#0000ff">=RouteLineLayer}&quot;</span><br>                  <span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot; &gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;RouteLineLayer&quot; /&gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapItemsControl</span><span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Directions}</span><span style="color:#0000ff">&quot;</span><br>                                      <span style="color:#ff0000"> ItemTemplate</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> RouteTemplate}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br> <br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupLayer&quot;&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopup&quot;</span><span style="color:#ff0000"> Visibility</span><span style="color:#0000ff">=&quot;Collapsed&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;15&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupText&quot;</span><span style="color:#ff0000"> FontSize</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> FontWeight</span><span style="color:#0000ff">=&quot;Bold&quot;</span><span style="color:#ff0000"> TextWrapping</span><span style="color:#0000ff">=&quot;Wrap&quot; /&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Oh and don’t forget the code behind:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:14f2277a-a347-48e8-afd6-41465898d7fe" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">partial</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span><br> {<br>     <span style="color:#0000ff">public</span> MainWindow()<br>     {<br>         InitializeComponent();<br>         DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">RouteViewModel</span>();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseEnter(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         <span style="color:#2b91af">FrameworkElement</span> pin = sender <span style="color:#0000ff">as</span> <span style="color:#2b91af">FrameworkElement</span>;<br>         <span style="color:#2b91af">MapLayer</span>.SetPosition(ContentPopup, <span style="color:#2b91af">MapLayer</span>.GetPosition(pin));<br>         <span style="color:#2b91af">MapLayer</span>.SetPositionOffset(ContentPopup, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Point</span>(20, -15));<br> <br>         <span style="color:#0000ff">var</span> location = (<span style="color:#2b91af">Direction</span>)pin.Tag;<br> <br>         ContentPopupText.Text = location.Description;<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Visible;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseLeave(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Collapsed;<br>     }<br> }</div> </div> </div>  <p>Now let’s view the fruits of our labor at runtime.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/09/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/09/image_thumb.png" width="644" height="453" /></a></p>  <p>As you can see, given a “From” and “To” address, we can draw a route line and provide turn-by-turn directions as the user hovers over the direction pins.&#160; Pretty neat huh?&#160; And it wasn’t too difficult to pull off.&#160; As always you can <a href="http://www.brianlagunas.com/downloads/source/BingMapsCalculateRouteDemo.zip">Download the Source</a> and start playing.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4306'>Buy Biaxin Without Prescription</a>. <a href='http://elegantcode.com/?p=4228'>Aricept For Sale</a>. <a href='http://elegantcode.com/?p=4340'>Atarax For Sale</a>. <a href='http://elegantcode.com/?p=5052'>Lotrisone For Sale</a>. <a href='http://elegantcode.com/?p=4407'>Buy Nexium Without Prescription</a>. <a href='http://elegantcode.com/?p=4873'>Cafergot treatment</a>. <a href='http://elegantcode.com/?p=4780'>Canada, mexico, india</a>. <a href='http://elegantcode.com/?p=4202'>Online buying Celexa</a>. <a href='http://elegantcode.com/?p=4335'>Fast shipping Differin</a>. <a href='http://elegantcode.com/?p=4205'>Purchase Allopurinol online no prescription</a>.<br />
<b>Trackbacks from:</b> <a href='http://linuxologist.com/?p=193'>Vermox For Sale</a>. <a href='http://blog.farmland.org/?p=3110'>Vermox For Sale</a>. <a href='http://home.officesnapshots.com/?p=122'>Vermox For Sale</a>. <a href='http://reversemortgagedaily.com/?p=14171'>Vermox For Sale</a>. <a href='http://social-blend.com/?p=495'>Vermox For Sale</a>. <a href='http://www.themusclecarplace.com/?p=3175'>Vermox for sale</a>. <a href='http://www.thegriffonnews.com/?p=10415'>Ordering Vermox online</a>. <a href='http://www.quarterlives.com/?p=743'>Order Vermox online c.o.d</a>. <a href='http://tayloegray.com/?p=351'>Vermox from mexico</a>. <a href='http://www.greatgreengoods.com/?p=3949'>Purchase Vermox for sale</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buy Female Pink Viagra Without Prescription</title>
		<link>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prism-fy-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 16:13:02 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[prism]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been playing around with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled [...]]]></description>
			<content:encoded><![CDATA[<p> <p>If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">playing</a> <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">around</a> with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled MapLayers at runtime using Prism.</p>  <p> <b>Buy Female Pink Viagra Without Prescription</b>, The concept is simple.&#160; We want a Bing Maps application that can be extended at runtime.&#160; By extended, I mean that I want the ability to add new elements/modules to the Map at runtime.&#160; The important thing about these elements/modules is that they can come from anywhere and they should be loosely coupled from the Map as well as other elements/modules that may exist on the Map.</p>  <p>Luckily for us this is extremely simple to accomplish.&#160; All we have to do is create a custom RegionAdapter, register it with our Prism application, and then apply it to our Bing Map control.&#160; So let’s start with the RegionAdapter.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8809704-1b89-4479-9f50-32a29a8ce6e3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapRegionAdapter</span> : <span style="color:#2b91af">RegionAdapterBase</span>&lt;<span style="color:#2b91af">Map</span>&gt;<br> {<br>     <span style="color:#0000ff">public</span> MapRegionAdapter(<span style="color:#2b91af">IRegionBehaviorFactory</span> regionBehaviorFactory)<br>         : <span style="color:#0000ff">base</span>(regionBehaviorFactory)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> Adapt(<span style="color:#2b91af">IRegion</span> region, <span style="color:#2b91af">Map</span> regionTarget)<br>     {<br>         region.Views.CollectionChanged += (s, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Add)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.NewItems)<br>                     regionTarget.Children.Add(element);<br>             }<br>             <span style="color:#0000ff">else</span> <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Remove)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.OldItems)<br>                     <span style="color:#0000ff">if</span> (regionTarget.Children.Contains(element))<br>                         regionTarget.Children.Remove(element);<br>             }<br>         };<br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">IRegion</span> CreateRegion()<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">AllActiveRegion</span>();<br>     }<br> }</div> </div> </div> </p>  <p>Now in the Bootstrapper we need to register our mapping.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fce11974-ec82-4641-ac5c-a37a9ff443df" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">RegionAdapterMappings</span> ConfigureRegionAdapterMappings()<br> {<br>     <span style="color:#2b91af">RegionAdapterMappings</span> mappings = <span style="color:#0000ff">base</span>.ConfigureRegionAdapterMappings();<br>     mappings.RegisterMapping(<span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Map</span>), Container.Resolve&lt;<span style="color:#2b91af">MapRegionAdapter</span>&gt;());<br>     <span style="color:#0000ff">return</span> mappings;<br> }</div> </div> </div> </p>  <p>Now we simply give the Map a region name. (this is actually all the shell has in it)</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a72303d9-120c-4bba-a39e-18ae1979a63a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>online Female Pink Viagra without a prescription</b>, <b>Female Pink Viagra forum</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> prism</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionManager.RegionName</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Static</span><span style="color:#ff0000"> inf</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionNames</span><span style="color:#0000ff">.MapRegion}&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40, <b>order Female Pink Viagra online overnight delivery no prescription</b>, <b>Low dose Female Pink Viagra</b>, -95&quot;</span><span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot; /&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div> </p>  <p>That is all there is to it.&#160; You can now start injecting modules onto the Map at runtime.&#160; Lets look at my two modules I am using as an example.&#160; Here is the structure of my application:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb13.png" width="305" height="190" /></a></p>  <ul>   <li>ModuleA will inject a MapPolygon in the Shape of Texas.</li>    <li>ModuleB is the Earthquake application we built in an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earlier post</a>.</li>    <li>Infrastructure is the project where shared code goes, in this case our MapRegionAdapter</li>    <li>BingMapsPrismfiedDemo is of course our shell project.</li> </ul>  <p>This is what the application looks like at runtime when both modules have been injected into it.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb14.png" width="644" height="334" /></a></p>  <p>Now I can easily add more layers to this map as I see fit.&#160; As always, <b>online buy Female Pink Viagra without a prescription</b>, <b>No prescription Female Pink Viagra online</b>, <a href="http://www.brianlagunas.com/downloads/source/BingMapsPrismfiedDemo.zip">Download the Source</a> and start playing.&#160; You may want to add MEF support as well.</p>.  Where can i find Female Pink Viagra online.  Effects of Female Pink Viagra.  Purchase Female Pink Viagra.  Female Pink Viagra over the counter.  Purchase Female Pink Viagra online.  Buy Female Pink Viagra without prescription.  Female Pink Viagra recreational.  Buy generic Female Pink Viagra.  Cheap Female Pink Viagra.  Female Pink Viagra no prescription.  Female Pink Viagra wiki.  Cheap Female Pink Viagra no rx.  Female Pink Viagra canada, mexico, india.  Buying Female Pink Viagra online over the counter.  Where to buy Female Pink Viagra.  Female Pink Viagra cost.  Female Pink Viagra from mexico.  Is Female Pink Viagra safe.  Buy Female Pink Viagra online cod.  Buy Female Pink Viagra from mexico.  Where can i order Female Pink Viagra without prescription.  Real brand Female Pink Viagra online.  Buy Female Pink Viagra from canada.  Female Pink Viagra overnight.  Female Pink Viagra use.  Order Female Pink Viagra from mexican pharmacy.  Female Pink Viagra street price.  Female Pink Viagra coupon.  Female Pink Viagra schedule.  Female Pink Viagra mg.  Female Pink Viagra interactions.  Taking Female Pink Viagra.  Female Pink Viagra used for.  Is Female Pink Viagra addictive.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4750'>Celebrex For Sale</a>. <a href='http://elegantcode.com/?p=4661'>Buy Methotrexate Without Prescription</a>. <a href='http://elegantcode.com/?p=4755'>Buy Zovirax Without Prescription</a>. <a href='http://elegantcode.com/?p=4311'>Buy Topamax Without Prescription</a>. <a href='http://elegantcode.com/?p=4476'>Modalert For Sale</a>. <a href='http://elegantcode.com/?p=4671'>Buy Quinine no prescription</a>. <a href='http://elegantcode.com/?p=4643'>Premarin duration</a>. <a href='http://elegantcode.com/?p=4340'>Purchase Atarax for sale</a>. <a href='http://elegantcode.com/?p=4732'>Abilify price</a>. <a href='http://elegantcode.com/?p=4373'>No prescription Topamax online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.thegriffonnews.com/?p=10565'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5050'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://changecamp.ca/?p=593'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://linuxologist.com/?p=450'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://blog.farmland.org/?p=1496'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.quarterlives.com/?p=930'>Female Pink Viagra brand name</a>. <a href='http://www.greatgreengoods.com/?p=3683'>Discount Female Pink Viagra</a>. <a href='http://www.macneilbmx.com/blog/?p=4935'>Female Pink Viagra pics</a>. <a href='http://social-blend.com/?p=671'>Female Pink Viagra results</a>. <a href='http://4realz.net/?p=847'>Female Pink Viagra pics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Buy Tindamax Without Prescription</title>
		<link>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-an-address-with-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:21:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[In my last post Buy Tindamax Without Prescription, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate [...]]]></description>
			<content:encoded><![CDATA[<p> <p>In my last <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">post</a> <b>Buy Tindamax Without Prescription</b>, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate maps and imagery, driving directions, distance calculations, and other location intelligence into your applications, business processes, and Web sites. </p>  <p>Let’s start with the Geocode Service which is used to match addresses, <b>buy cheap Tindamax</b>, <b>Purchase Tindamax for sale</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>my Tindamax experience</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; We will create a simple application that allows you to enter an address and place a pushpin at that location.&#160; First thing is first:</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165" target="_blank">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/" target="_blank">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services.&#160; Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>order Tindamax from United States pharmacy</b>.  <b>Online buying Tindamax</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>buy Tindamax without a prescription</b>.  <b>After Tindamax</b>, </p>  <p>Open up your App.xaml.&#160; You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c7fbbfb-a6ac-496d-a298-bddbd655ac65" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>discount Tindamax</b>, <b>Buy Tindamax no prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Now create a very simple UI that will accept an address and a button to perform the geocoding:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc9a874e-765b-4bc2-b82b-88a96f1ef84c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax treatment</b>, <b>Tindamax no rx</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>                  <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>The next thing we need to do is add a new Service Reference to the project and point to the following service:</p>  <p><a title="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc" href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name (I called mine BingMapsService) and just for fun, <b>buy Tindamax online cod</b>, <b>Generic Tindamax</b>, in the “Add Service Reference” dialog, click the “Advanced” button and click “Generate asynchronous operations”.</p>  <p>Next we need to create a ViewModel to support our View.&#160; This is a WPF application after all.&#160; This ViewModel will need a command for the button that will perform the geocoding, <b>Tindamax duration</b>, <b>Low dose Tindamax</b>, and a property that will represent the result of the service that the UI will use to map the address.&#160; It should resemble something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b09cd91-31d1-426f-a539-9fe004a3702a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax street price</b>, <b>Tindamax blogs</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">GeocodeViewModel</span> : <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> GeocodeAddressCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> _geocodeResult;<br>     <span style="color:#0000ff">public</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GeocodeResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _geocodeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _geocodeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> GeocodeViewModel()<br>     {<br>         GeocodeAddressCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>&lt;<span style="color:#2b91af">String</span>&gt;(GeocodeAddress);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>I want to point out that the DelegateCommand&lt;T&gt; is a very simple ICommand implementation and should NOT be used in production applications.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cac2fd6-5f40-4d30-b70e-39cf0eb39d77" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax wiki</b>, <b>Tindamax cost</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span>&lt;T&gt; : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span>&lt;T&gt; _execute;<br> <br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span>&lt;T&gt; execute)<br>     {<br>         _execute = execute;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke((T)parameter);<br>     }<br> }</div> </div> </div>  <p>Let’s hook our UI up to our command.&#160; it should look something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f154da3-e1a9-48e1-8dcd-53063e2268ec" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax overnight</b>, <b>Online buy Tindamax without a prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;</span> <br>                    <span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeAddressCommand}</span><span style="color:#0000ff">&quot;</span><br>                    <span style="color:#ff0000"> CommandParameter</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">, <b>where can i buy Tindamax online</b>, <b>Discount Tindamax</b>, </span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=</span>_<span style="color:#0000ff">txtAddress}&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Notice that we are using the text of the TextBox as the CommandParameter.&#160; Next, we need to implement the command:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0d2006e3-d7cf-483a-b57b-284d06ecffff" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax for sale</b>, <b>Tindamax used for</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br> {<br>     <span style="color:#0000ff">using</span> (BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>     {<br>         client.GeocodeCompleted += (o, <b>buy no prescription Tindamax online</b>, <b>Tindamax online cod</b>, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Error == <span style="color:#0000ff">null</span>)<br>             {<br>                 GeocodeResult = e.Result.Results[0];<br>             }<br>         };<br> <br>         BingMapsService.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeRequest</span>();<br>         request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>         request.Query = address;<br>         client.GeocodeAsync(request);<br>     }<br> }</div> </div> </div>  <p>In this command we are simply creating an instance of the service client, creating a GeocodeRequest, <b>Tindamax coupon</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, setting the credentials using the ApplicationId we have stored in the App.xaml, and then using the address as the Query for the request.&#160; When the call to the service is completed we are setting the GeocodeResult property to the first element in the results.</p>  <p>Now the tricky part.&#160; We want to place a Pushpin on the address that was entered and then move the map to that location.&#160; We also need to make sure that when another address is entered, <b>buying Tindamax online over the counter</b>, <b>Is Tindamax safe</b>, we clear any previous Pushpins that may exist on the map.&#160; We also have to be aware that other elements my be on the map and we don’t want to accidentally alter those elements.&#160; Oh and did I mention this was an MVVM application and this has to be done with just data binding. </p>  <p>The approach that I decided to go with is to use <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" target="_blank">Attached Properties</a>.&#160; So I created two attached properties; one for the GeocodeResult and another for a MapLayer that will be dedicated to the GeocodeResult.&#160; This will allow us to create a MapLayer that is specific to our GeocodeResut and not alter any other elements that may be on the map.&#160; Let’s check out the code.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3cc3f4e4-cbae-4ffe-93bf-4a10f2e36d08" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>herbal Tindamax</b>, <b>Tindamax price, coupon</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> GeocodeResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>, <b>buy Tindamax without a prescription</b>, <b>Buy Tindamax without prescription</b>, <span style="color:#0000ff">typeof</span>(BingMapsService.<span style="color:#2b91af">GeocodeResult</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <b>cheap Tindamax</b>, <b>Tindamax trusted pharmacy reviews</b>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GetGeocodeResult(<span style="color:#2b91af">Map</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)target.GetValue(GeocodeResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResult(<span style="color:#2b91af">Map</span> target, <b>ordering Tindamax online</b>, <b>Tindamax canada, mexico, india</b>, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> value)<br>     {<br>         target.SetValue(GeocodeResultProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultChanged((<span style="color:#2b91af">Map</span>)o, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.OldValue, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">Map</span> map, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> oldValue, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">Location</span> location = newValue.Locations.Select(x =&gt; <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(x.Latitude, x.Longitude)).First();<br> <br>         <span style="color:#2b91af">Pushpin</span> pin = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Pushpin</span>();<br>         pin.Location = location;<br>         pin.ToolTip = newValue.Address.FormattedAddress;<br> <br>         <span style="color:#0000ff">var</span> locationLayer = GetGeocodeResultLayer(map);<br>         <span style="color:#0000ff">if</span> (locationLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             locationLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetGeocodeResultLayer(map, locationLayer);<br>         }<br> <br>         locationLayer.Children.Clear();<br>         locationLayer.Children.Add(pin);<br> <br>         map.SetView(location, map.ZoomLevel);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResult</span><br> <br>     <span style="color:#0000ff">#region</span> GeocodeResultLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResultLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(GeocodeResultLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(GeocodeResultLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResultLayer</span><br> }</div> </div> </div>  <p>Notice that when the GeocodeResult changes we get the Location and create a pushpin for that location.&#160; We also set the tooltip to the FormattedAddress of the GeocodeResult.&#160; So when we hover over the pushpin we will see a nice little tooltip of the address.&#160; Next we try to get the GeocodeResultLayer from the map, if it is null this means it doesn’t exist on the map yet so we create one and assign it accordingly.&#160; We clear the layer child elemnts and then add out pushpin.&#160; The last thing we do is call the SetView method of the Map control passing in the location and the current ZoomLevel.</p>  <p>The final step is to use our AttachedProperty on the map.&#160; Be sure to create a namespace for the MapInteractivity class and define it as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72d6307a-aef3-4f70-8d47-8d4529fc74e0" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>          <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.GeocodeResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeResult}</span><span style="color:#0000ff">&quot;</span><br>          <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>One last thing.&#160; Be sure to remember to set your DataContext of your View to the ViewModel we have created:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f7d0b4f-e096-487d-8343-fb42c94c3360" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> MainWindow()<br> {<br>     InitializeComponent();<br>     DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">GeocodeViewModel</span>(); <br> }</div> </div> </div>  <p>That’s it.&#160; You now have an application the can map (geocode) an address using the Bing Maps WPF Control and the Geocoding SOAP Service.&#160; Oh and we are doing this all with MVVM and data binding which is my favorite part.&#160; Be sure to <a href="http://www.brianlagunas.com/downloads/source/bingmapsgeocodedemo.zip">Download the Source</a> and start playing around.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4746'>Buy Clindamycin Gel Without Prescription</a>. <a href='http://elegantcode.com/?p=4328'>Buy Plavix Without Prescription</a>. <a href='http://elegantcode.com/?p=4302'>Buy Phenergan Without Prescription</a>. <a href='http://elegantcode.com/?p=4460'>Buy Proscar Without Prescription</a>. <a href='http://elegantcode.com/?p=4607'>Triamterene For Sale</a>. <a href='http://elegantcode.com/?p=4751'>Diflucan street price</a>. <a href='http://elegantcode.com/?p=4372'>Nexium steet value</a>. <a href='http://elegantcode.com/?p=4475'>Metronidazole Gel from mexico</a>. <a href='http://elegantcode.com/?p=4399'>Herbal Periactin</a>. <a href='http://elegantcode.com/?p=4858'>Tramadol over the counter</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.macneilbmx.com/blog/?p=6683'>Buy Tindamax Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=3313'>Buy Tindamax Without Prescription</a>. <a href='http://www.thegriffonnews.com/?p=9133'>Buy Tindamax Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5330'>Buy Tindamax Without Prescription</a>. <a href='http://changecamp.ca/?p=592'>Buy Tindamax Without Prescription</a>. <a href='http://social-blend.com/?p=444'>Tindamax online cod</a>. <a href='http://blog.farmland.org/?p=3958'>Order Tindamax from mexican pharmacy</a>. <a href='http://4realz.net/?p=717'>Tindamax forum</a>. <a href='http://reversemortgagedaily.com/?p=14265'>Tindamax trusted pharmacy reviews</a>. <a href='http://linuxologist.com/?p=1542'>Tindamax online cod</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &#8211; dynamically compile and run event handlers within loose XAML using CodeDom</title>
		<link>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom</link>
		<comments>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:37:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[dynamic code]]></category>
		<category><![CDATA[wpd]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/</guid>
		<description><![CDATA[Last week I wrote a blog post showing how you can write inline code in XAML.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon re-tweeted that post with a link to one of his own posts on exploring new techniques for DLR script in XAML which also links [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a blog post showing how <a href="http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/" target="_blank">you can write inline code in XAML</a>.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon <a href="http://twitter.com/#!/rrelyea/status/15099827364827136" target="_blank">re-tweeted</a> that post with a link to one of his own posts on <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/11/14/exploring-new-techniques-for-dlr-script-in-xaml.aspx" target="_blank">exploring new techniques for DLR script in XAML</a> which also links to another one of his posts which shows different techniques for <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/06/03/xaml-events-in-compiled-and-uncompiled-scenarios.aspx" target="_blank">hooking up events in compiled and uncompiled scenarios</a> which in turn links to <a href="http://www.thinkbottomup.com.au/site/blog/Embedding_DLR_Scripts_in_XAML_Part_1" target="_blank">this post about embedding DLR scripts in XAML</a> written by Daniel Paull.&#160; Wow, that is a lot of linking.</p>  <p>Well, now that everyone has been given their respective credit, let’s continue.&#160; I wanted to take my last post a little further.&#160; In that post I simply created an event handler for a button click event using inline code in the x:Code directive.&#160; If you started to play with the sample code, you might have thought to yourself, “I wonder if I can load this XAML, event handler and all, from a file or database and have it still work.”.&#160; Well, if you tried it, you found the answer really quick.&#160; No!&#160; The reason is pretty simple; code must be compiled in order to execute.&#160; Therefore any code inside loose XAML will fail.&#160; Also, when using loose XAML, trying to hookup an event handler would crash your application because it is not allowed.</p>  <p>Oh, then it must not be possible? Wrong!&#160; Well, then how do you do it if the code must be compiled?&#160; Simple, we compile the code just before we run it.&#160; Say what?&#160; That’s right, let me introduce you to the <a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" target="_blank">CodeDom</a>.&#160; The CodeDom allows you to dynamically generate and compile code at runtime.&#160; Let’s get to it.</p>  <p>We need to attach event handlers to elements in loose XAML, and have them execute C# code.&#160; Each element has different events to handle, and each event will execute different code.&#160; This tells me that we need an object that contains two properties, one to specify the RoutedEvent to handle, and another to specify the c# code to execute.&#160; We also need a common event handler definition to execute whenever the RoutedEvent is invoked.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c257533-76d5-4e97-9754-1b389f8f52b5" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DynamicEvent</span><br> {<br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the routed event to execute.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The routed event.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">RoutedEvent</span> RoutedEvent { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the script to run when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The script.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Script { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Called when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br>     {<br>         <br>     }<br> }</div> </div> </div>  <p>That was simple enough.&#160; Now, in order to attach event handlers to elements in loose XAML, we need away to get around the “no event handlers allowed” limitation.&#160; To do this we can use an attached property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c6021e-2311-4633-85f8-8fcb27a9cb89" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> HandlerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;Handler&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(OnHandlerChanged));<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DynamicEvent</span> GetHandler(<span style="color:#2b91af">DependencyObject</span> obj)<br> {<br>     <span style="color:#0000ff">return</span> (<span style="color:#2b91af">DynamicEvent</span>)obj.GetValue(HandlerProperty);<br> }<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetHandler(<span style="color:#2b91af">DependencyObject</span> obj, <span style="color:#0000ff">bool</span> value)<br> {<br>     obj.SetValue(HandlerProperty, value);<br> }<br> <br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnHandlerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">UIElement</span> uie = o <span style="color:#0000ff">as</span> <span style="color:#2b91af">UIElement</span>;<br>     <span style="color:#0000ff">if</span> (uie == <span style="color:#0000ff">null</span>)<br>         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">Exception</span>(<span style="color:#a31515">&quot;Attempt to set EventHandler on non-UIElement Type&quot;</span>);<br> <br>     <span style="color:#2b91af">DynamicEvent</span> oldHandler = e.OldValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br>     <span style="color:#2b91af">DynamicEvent</span> newHandler = e.NewValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br> <br>     <span style="color:#008000">// unhook the old event</span><br>     <span style="color:#0000ff">if</span> (oldHandler != <span style="color:#0000ff">null</span>)<br>         uie.RemoveHandler(oldHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(oldHandler.OnEventExecuted));<br> <br>     <span style="color:#008000">// hook up the new</span><br>     <span style="color:#0000ff">if</span> (newHandler != <span style="color:#0000ff">null</span>)<br>         uie.AddHandler(newHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(newHandler.OnEventExecuted));<br> <br> }</div> </div> </div>  <p>This attached property allows use to attach an instance of our DynamicEvent class to our element.&#160; When the Handler attached property is set, we simple add our OnEventExecute event handler to the RoutedEvent specified in the RoutedEvent property.&#160; Now we have the basic framework needed to attach and event handler to any event on any element in loose XAML.&#160; Let’s see how to attach an event handler in XAML using this newly created DynamicEvent class.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c323adca-e880-4dd4-997e-958bccc70c3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Initial Text&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#ff0000"> RoutedEvent</span><span style="color:#0000ff">=&quot;Button.Click&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#ff0000"> xml</span><span style="color:#0000ff">:</span><span style="color:#ff0000">space</span><span style="color:#0000ff">=&quot;preserve&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>                         <span style="color:#808080">var button = sender as Button;</span><br>                         <span style="color:#808080">button.Content = &quot;Changed with Dynamic Code&quot;;</span><br>                         <span style="color:#808080">]]&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Button</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see I have added a handler for a Button’s Click event.&#160; I also provided a Script to execute when the event is invoked.&#160; Notice that we are preserving the whitespace in the script.&#160; Of course nothing will happen just yet.&#160; Now we need to take the script and compile it at run time.&#160; This is where the CodeDom comes in.</p>  <p>The steps necessary to compile code at run time go a little something like this:</p>  <ul>   <li>Create a CodeCompileUnit </li>    <li>Add our namespace and import statements </li>    <li>create our dynamic class </li>    <li>add a method that will execute the Script </li>    <li>compile the code </li>    <li>execute the code </li> </ul>  <p>All these steps must be performed when the ROutedEvent is invoked, which means the code must be compiled inside the OnEventExecuted event handler.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56b1a794-ec6b-4976-9f18-e819f5a52641" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">CodeCompileUnit</span> compileUnit = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeCompileUnit</span>();<br> <br>     <span style="color:#008000">//create our namesapce and import statements, then add it to the compile unit</span><br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = CreateNamespaceAndImports();<br>     compileUnit.Namespaces.Add(namespaces);<br> <br>     <span style="color:#008000">//create our target class and add it to the namespace</span><br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = CreateTargetClass();<br>     namespaces.Types.Add(targetClass);<br> <br>     <span style="color:#008000">//create the ExecuteScript method and then add it to our class</span><br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = CreateExecuteScriptMethod();<br>     targetClass.Members.Add(executeEventMethod);<br> <br>     <span style="color:#008000">//create our compiler parameters</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = CreateCompilerParameters();<br> <br>     <span style="color:#008000">//compile the assembly</span><br>     <span style="color:#0000ff">var</span> results = CompileAssembly(compileUnit, compilerParams);<br> <br>     <span style="color:#008000">//execute the code</span><br>     ExecuteCode(results, sender, e);<br> }</div> </div> </div>  <p>The first step is really easy.&#160; We simply need to create an instance of the CodeCompileUnit class.&#160; The CodeCompileUnit references the CodeDom object graph and has properties for storing attributes, namespaces, and assemblies.&#160; Next we need to create our namespace and import statements.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b89b170-e94b-4b3b-a8d8-8df82193e6d3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the namespace and imports.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;remarks&gt;</span><span style="color:#008000">I have only added three import statements as an example. You should add all import statements required to run your dynamic code</span><span style="color:#808080">&lt;/remarks&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeNamespace</span> CreateNamespaceAndImports()<br> {<br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespace</span>(<span style="color:#a31515">&quot;WPFCodeInjection&quot;</span>);<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows.Controls&quot;</span>));<br>     <span style="color:#0000ff">return</span> namespaces;<br> }</div> </div> </div>  <p>Once the namespace and import statement are created we need to add them to out CodeCompileUnit instance.&#160; Then we need to create our dynamic class.&#160; We need to make sure it is a public class:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a495da08-da32-46e0-ba99-c5fac5d189e1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the target class.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeTypeDeclaration</span> CreateTargetClass()<br> {<br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeTypeDeclaration</span>(<span style="color:#a31515">&quot;DynamicClass&quot;</span>);<br>     targetClass.TypeAttributes = <span style="color:#2b91af">TypeAttributes</span>.Public;<br>     <span style="color:#0000ff">return</span> targetClass;<br> }</div> </div> </div>  <p>When the dynamic class is created we add it to our namespace.&#160; Now we create a method. We give it a name of ExecuteScript and set its access modifier to public.&#160; We specify that it accepts two parameters.&#160; One being the sender which is of type object, and one that is the event args that is of type RoutedEventArgs.&#160; Lastly, we set the body of the method to the Script property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4cae0858-7130-4df1-b3b1-cf49063a4d50" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the ExecuteScript method.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#2b91af">CodeMemberMethod</span> CreateExecuteScriptMethod()<br> {<br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeMemberMethod</span>();<br>     executeEventMethod.Name = <span style="color:#a31515">&quot;ExecuteScript&quot;</span>;<br>     executeEventMethod.Attributes = <span style="color:#2b91af">MemberAttributes</span>.Public | <span style="color:#2b91af">MemberAttributes</span>.Final;<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Object&quot;</span>, <span style="color:#a31515">&quot;sender&quot;</span>));<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Windows.RoutedEventArgs&quot;</span>, <span style="color:#a31515">&quot;e&quot;</span>));<br>     executeEventMethod.Statements.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeSnippetStatement</span>(Script));<br>     <span style="color:#0000ff">return</span> executeEventMethod;<br> }</div> </div> </div>  <p>Now we have to create our compiler parameters.&#160; These include adding referencing to the necessary Dlls required to run your code.&#160; We also want to specify that we want to generate the code in memory.&#160; If you wanted to you could save the assembly to a file.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cebbac90-1864-436d-8248-de681876fa83" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the compiler parameters.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerParameters</span> CreateCompilerParameters()<br> {<br>     <span style="color:#008000">//add compiler parameters and assembly references</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CompilerParameters</span>();<br>     compilerParams.CompilerOptions = <span style="color:#a31515">&quot;/target:library /optimize&quot;</span>;<br>     compilerParams.GenerateExecutable = <span style="color:#0000ff">false</span>;<br>     compilerParams.GenerateInMemory = <span style="color:#0000ff">true</span>;<br> <br>     <span style="color:#008000">//you can add references individually if you want by providing the location of the assembly</span><br>     <span style="color:#008000">//compilerParams.ReferencedAssemblies.Add(&quot;System.dll&quot;);</span><br> <br>     <span style="color:#008000">//I am lazy so I will just loop through the assemblies that are already loaded and add those</span><br>     <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Assembly</span> assembly <span style="color:#0000ff">in</span> <span style="color:#2b91af">AppDomain</span>.CurrentDomain.GetAssemblies())<br>     {<br>         <span style="color:#0000ff">try</span><br>         {<br>             <span style="color:#0000ff">string</span> location = assembly.Location;<br>             <span style="color:#0000ff">if</span> (!<span style="color:#2b91af">String</span>.IsNullOrEmpty(location))<br>                 compilerParams.ReferencedAssemblies.Add(location);<br>         }<br>         <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">NotSupportedException</span>)<br>         {<br>             <span style="color:#008000">// this happens for dynamic assemblies, so just ignore it.                     </span><br>         }<br>     }<br> <br>     <span style="color:#0000ff">return</span> compilerParams;<br> }</div> </div> </div>  <p>Now we compile the code into an assembly.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b05d391c-e1d9-47c3-b9b3-2c147f47e7bb" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Compiles the assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compileUnit&quot;&gt;</span><span style="color:#008000">The compile unit.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compilerParams&quot;&gt;</span><span style="color:#008000">The compiler params.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerResults</span> CompileAssembly(<span style="color:#2b91af">CodeCompileUnit</span> compileUnit, <span style="color:#2b91af">CompilerParameters</span> compilerParams)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">CSharpCodeProvider</span> provider = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CSharpCodeProvider</span>())<br>     {<br>         <span style="color:#008000">// =============================================================================== //</span><br>         <span style="color:#008000">// if you want to see the actual complied source code uncomment //</span><br>         <span style="color:#008000">// =============================================================================== //</span><br> <br>         <span style="color:#008000">//StringBuilder source = new StringBuilder();</span><br>         <span style="color:#008000">//StringWriter sw = new StringWriter(source);</span><br>         <span style="color:#008000">//provider.GenerateCodeFromCompileUnit(compileUnit, sw, new CodeGeneratorOptions());</span><br>         <span style="color:#008000">//string sourceCode = source.ToString();</span><br> <br>         <span style="color:#0000ff">var</span> results = provider.CompileAssemblyFromDom(compilerParams, compileUnit);<br>         <span style="color:#0000ff">return</span> results;<br>     }<br> }</div> </div> </div>  <p>The last thing we need to do is run the code that was just compiled.&#160; We will need the help of reflection to accomplish this.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09c68e9b-98f4-4334-aa9f-ecf464569e54" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Executes the ExecuteScript method from the compiled CodeDom assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;results&quot;&gt;</span><span style="color:#008000">The results.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> ExecuteCode(<span style="color:#2b91af">CompilerResults</span> results, <span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">try</span><br>     {<br>         <span style="color:#2b91af">Assembly</span> executingAssembly = results.CompiledAssembly;<br>         <span style="color:#0000ff">if</span> (executingAssembly != <span style="color:#0000ff">null</span>)<br>         {<br>             <span style="color:#008000">//create an instance of our newly compiled assembly</span><br>             <span style="color:#0000ff">object</span> assemblyInstance = executingAssembly.CreateInstance(<span style="color:#a31515">&quot;WPFCodeInjection.DynamicClass&quot;</span>);<br> <br>             <span style="color:#008000">//get our ExecuteScript method and execute it.</span><br>             <span style="color:#2b91af">MethodInfo</span> info = assemblyInstance.GetType().GetMethod(<span style="color:#a31515">&quot;ExecuteScript&quot;</span>);<br>             info.Invoke(assemblyInstance, <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[] { sender, e });<br>         }<br>     }<br>     <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">Exception</span> ex)<br>     {<br>         <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Error: An exception occurred while executing the script&quot;</span>, ex);<br>     }<br> }</div> </div> </div>  <p>That is it.&#160; Now to test this out lets create a .txt file that contains our XAML that we define above and save it CodeSnippet.txt.&#160; In our MainWindow.xaml.cs, lets handle the Loaded event and load our CodeSnippet.txt using the XamlReader.Load method.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc56e72c-6fdc-4430-afb5-4498031c46f1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">void</span> MainWindow_Loaded(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">FileStream</span> fs = <span style="color:#0000ff">new</span> <span style="color:#2b91af">FileStream</span>(<span style="color:#a31515">@&quot;./CodeSnippet.txt&quot;</span>, <span style="color:#2b91af">FileMode</span>.Open))<br>     {<br>         <span style="color:#0000ff">this</span>.Content = <span style="color:#2b91af">XamlReader</span>.Load(fs);<br>     }<br> }</div> </div> </div>  <p>Run the application is this is what it should look like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb9.png" width="174" height="179" /></a></p>  <p>Now click the button and our C# code defined within the Script property will be dynamically compiled and executed changed the text of the button to this:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb10.png" width="184" height="179" /></a></p>  <p>This is a very simple example and is not intended to be a complete solution, but it does show some of the powerful capabilities you have using WPF, XAML, and the CodeDom.&#160; Like always <a href="http://brianlagunas.com/downloads/source/WpfCodeInjection.zip">download the source</a> and start playing around.&#160; See what kind of cool stuff you can do with it.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yes you can write Inline Code in XAML</title>
		<link>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yes-you-can-write-inline-code-in-xaml</link>
		<comments>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 21:11:51 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/</guid>
		<description><![CDATA[A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete it?”.&#160; Obviously I replied yes, you absolutely can delete the code-behind file from a XAML file and the application will still work.&#160; Then they replied, “That’s cool I guess, but what about the code that needs to execute, such as event handlers?”.&#160; Naturally I brought up the fact that using MVVM you don’t use event handlers, but as most developers do, they said, “Well what if I really needed it?”.&#160; My reply to that question was, “If you really had to, it is possible to write inline code inside the XAML file”.</p>  <p>They looked at me in amazement, “Really?”.&#160; Apparently that is a little known fact about WPF.&#160; Yes, it is absolutely possible to write inline code inside a XAML page without the need for a code-behind file, and everything will work as expected.&#160; I quickly realized that his was going somewhere I didn’t want it to go.&#160; I knew what was coming next; they asked me to show them how to do it. Uggg…</p>  <p>Okay here is the deal; what I am about to show you is not recommended.&#160; It goes against everything I have been teaching in the community, but if you are curious how to actually do this, it is quit simple.</p>    <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ddf41891-b77a-41c9-89aa-aeb2944933da" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--Define the button content --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;133&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Name</span><span style="color:#0000ff">=&quot;btnExitApp&quot;</span><span style="color:#ff0000"> Click</span><span style="color:#0000ff">=&quot;btnExitApp_Clicked&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Exit Application&quot;/&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--The C# implementation of the button&#39;s Click event handler. --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>             <span style="color:#808080">private void btnExitApp_Clicked(object sender, RoutedEventArgs e)</span><br>             <span style="color:#808080">{</span><br>                 <span style="color:#808080">// Get a handle to the current app and shut it down.</span><br>                 <span style="color:#808080">Application.Current.Shutdown();</span><br>             <span style="color:#808080">}</span><br>         <span style="color:#808080">]]&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div>    <p>As you can see the code snippet above is pretty simple.&#160; You will notice that the Button has a EventHandler defined called “btnExitApp_Clicked”.&#160; Since there is no code-behind (I deleted it) you may be expecting a compile error that says it cannot find the definition for the EventHandler.&#160; But wait, we do have the event handler defined within the &lt;x:Code&gt;….&lt;/x:Code&gt; tags.</p>  <p>The &lt;x:Code&gt;….&lt;/x:Code&gt; is a directive element defined in XAML.&#160; An x:Code directive element can contain inline programming code. The code that is defined inline can interact with the XAML on the same page.&#160; Notice that the code is inside the x:Code element and that the code must be surrounded by &lt;CDATA[...]]&gt; to escape the contents for XML, so that a XAML processor (interpreting either the XAML schema or the WPF schema) will not try to interpret the contents literally as XML.</p>  <p>That is all there really is to it.&#160; There are some limitations to using inline code, for more information you can check out the <a href="http://msdn.microsoft.com/en-us/library/aa970568.aspx" target="_blank">MSDN documentation</a>.&#160; Now, I don’t want to see this in any production code.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Simple WPF Loading Animation</title>
		<link>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-wpf-loading-animation</link>
		<comments>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 03:47:21 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/</guid>
		<description><![CDATA[Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could save myself some time by just using theirs.&#160; Well, after almost an hour searching, I found nothing.&#160; So much for being a timesaver.&#160; Now, don’t get me wrong, I found a couple of WPF animations out there, but none of them really fit what I needed.&#160; So I just decided to bite the bullet and create my own.&#160; After creating the animation I decided to share the fruits of my labor so that anyone else who is looking for the same thing I was, or something similar, wouldn’t have as much trouble as I did.</p>  <p>Here is what it looks like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="loadingAnimation" border="0" alt="loadingAnimation" src="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation_thumb.jpg" width="114" height="114" /></a> </p>  <p>Here is the source: <a href="http://brianlagunas.com/downloads/source/LoadingControl.zip">Download the Loading Animation Source</a></p>  <p>I hope it is useful to someone besides me.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Debugging XAML</title>
		<link>http://elegantcode.com/2009/04/14/debugging-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-xaml</link>
		<comments>http://elegantcode.com/2009/04/14/debugging-xaml/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 01:43:01 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/04/14/debugging-xaml/</guid>
		<description><![CDATA[Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths. Lets say I have the following code snippet: &#60;StatusBar&#62; &#60;StatusBarItem&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths.</p>  <p>Lets say I have the following code snippet:</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">       <span style="color: #0000ff">&lt;</span><span style="color: #800000">TextBlock</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;{Binding Messssage}&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>
  </div>
</div>

<p></p>

<p>As you can see my property Message is totally misspelled.&#160; If I were to run this application nothing would ever appear in my status bar, and I would not know why.&#160; I didn’t get any compile errors, and my view renders perfectly in my designer, so what the hell is going on.&#160; You might spend hours looking at your object’s property, stepping through the property changed events, or just saying XAML is a piece of crap and I give up.&#160; Well never fear, I am about to reveal the secret to debugging your XAML.</p>

<p>Look in your Output Window!</p>

<p><a href="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow.jpg" target="_blank"><img title="OutputWindow" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="79" alt="OutputWindow" src="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow-thumb.jpg" width="404" border="0" /></a> </p>

<p>Yes, the nearly always forgotten Output Window.&#160; As you can see, if you click on the image above, it tells me that I have a binding expression path error and gives the line number where the error occurred.&#160; So don’t spend hours stepping through code looking for a ghost.&#160; Just check your Output Window.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/04/14/debugging-xaml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WPF String.Format in XAML with the StringFormat attribute</title>
		<link>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prism-fy-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 16:13:02 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[prism]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been playing around with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled [...]]]></description>
			<content:encoded><![CDATA[<p> <p>If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">playing</a> <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">around</a> with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled MapLayers at runtime using Prism.</p>  <p> <b>Buy Female Pink Viagra Without Prescription</b>, The concept is simple.&#160; We want a Bing Maps application that can be extended at runtime.&#160; By extended, I mean that I want the ability to add new elements/modules to the Map at runtime.&#160; The important thing about these elements/modules is that they can come from anywhere and they should be loosely coupled from the Map as well as other elements/modules that may exist on the Map.</p>  <p>Luckily for us this is extremely simple to accomplish.&#160; All we have to do is create a custom RegionAdapter, register it with our Prism application, and then apply it to our Bing Map control.&#160; So let’s start with the RegionAdapter.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8809704-1b89-4479-9f50-32a29a8ce6e3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapRegionAdapter</span> : <span style="color:#2b91af">RegionAdapterBase</span>&lt;<span style="color:#2b91af">Map</span>&gt;<br> {<br>     <span style="color:#0000ff">public</span> MapRegionAdapter(<span style="color:#2b91af">IRegionBehaviorFactory</span> regionBehaviorFactory)<br>         : <span style="color:#0000ff">base</span>(regionBehaviorFactory)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> Adapt(<span style="color:#2b91af">IRegion</span> region, <span style="color:#2b91af">Map</span> regionTarget)<br>     {<br>         region.Views.CollectionChanged += (s, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Add)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.NewItems)<br>                     regionTarget.Children.Add(element);<br>             }<br>             <span style="color:#0000ff">else</span> <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Remove)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.OldItems)<br>                     <span style="color:#0000ff">if</span> (regionTarget.Children.Contains(element))<br>                         regionTarget.Children.Remove(element);<br>             }<br>         };<br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">IRegion</span> CreateRegion()<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">AllActiveRegion</span>();<br>     }<br> }</div> </div> </div> </p>  <p>Now in the Bootstrapper we need to register our mapping.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fce11974-ec82-4641-ac5c-a37a9ff443df" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">RegionAdapterMappings</span> ConfigureRegionAdapterMappings()<br> {<br>     <span style="color:#2b91af">RegionAdapterMappings</span> mappings = <span style="color:#0000ff">base</span>.ConfigureRegionAdapterMappings();<br>     mappings.RegisterMapping(<span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Map</span>), Container.Resolve&lt;<span style="color:#2b91af">MapRegionAdapter</span>&gt;());<br>     <span style="color:#0000ff">return</span> mappings;<br> }</div> </div> </div> </p>  <p>Now we simply give the Map a region name. (this is actually all the shell has in it)</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a72303d9-120c-4bba-a39e-18ae1979a63a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>online Female Pink Viagra without a prescription</b>, <b>Female Pink Viagra forum</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> prism</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionManager.RegionName</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Static</span><span style="color:#ff0000"> inf</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionNames</span><span style="color:#0000ff">.MapRegion}&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40, <b>order Female Pink Viagra online overnight delivery no prescription</b>, <b>Low dose Female Pink Viagra</b>, -95&quot;</span><span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot; /&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div> </p>  <p>That is all there is to it.&#160; You can now start injecting modules onto the Map at runtime.&#160; Lets look at my two modules I am using as an example.&#160; Here is the structure of my application:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb13.png" width="305" height="190" /></a></p>  <ul>   <li>ModuleA will inject a MapPolygon in the Shape of Texas.</li>    <li>ModuleB is the Earthquake application we built in an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earlier post</a>.</li>    <li>Infrastructure is the project where shared code goes, in this case our MapRegionAdapter</li>    <li>BingMapsPrismfiedDemo is of course our shell project.</li> </ul>  <p>This is what the application looks like at runtime when both modules have been injected into it.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb14.png" width="644" height="334" /></a></p>  <p>Now I can easily add more layers to this map as I see fit.&#160; As always, <b>online buy Female Pink Viagra without a prescription</b>, <b>No prescription Female Pink Viagra online</b>, <a href="http://www.brianlagunas.com/downloads/source/BingMapsPrismfiedDemo.zip">Download the Source</a> and start playing.&#160; You may want to add MEF support as well.</p>.  Where can i find Female Pink Viagra online.  Effects of Female Pink Viagra.  Purchase Female Pink Viagra.  Female Pink Viagra over the counter.  Purchase Female Pink Viagra online.  Buy Female Pink Viagra without prescription.  Female Pink Viagra recreational.  Buy generic Female Pink Viagra.  Cheap Female Pink Viagra.  Female Pink Viagra no prescription.  Female Pink Viagra wiki.  Cheap Female Pink Viagra no rx.  Female Pink Viagra canada, mexico, india.  Buying Female Pink Viagra online over the counter.  Where to buy Female Pink Viagra.  Female Pink Viagra cost.  Female Pink Viagra from mexico.  Is Female Pink Viagra safe.  Buy Female Pink Viagra online cod.  Buy Female Pink Viagra from mexico.  Where can i order Female Pink Viagra without prescription.  Real brand Female Pink Viagra online.  Buy Female Pink Viagra from canada.  Female Pink Viagra overnight.  Female Pink Viagra use.  Order Female Pink Viagra from mexican pharmacy.  Female Pink Viagra street price.  Female Pink Viagra coupon.  Female Pink Viagra schedule.  Female Pink Viagra mg.  Female Pink Viagra interactions.  Taking Female Pink Viagra.  Female Pink Viagra used for.  Is Female Pink Viagra addictive.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4750'>Celebrex For Sale</a>. <a href='http://elegantcode.com/?p=4661'>Buy Methotrexate Without Prescription</a>. <a href='http://elegantcode.com/?p=4755'>Buy Zovirax Without Prescription</a>. <a href='http://elegantcode.com/?p=4311'>Buy Topamax Without Prescription</a>. <a href='http://elegantcode.com/?p=4476'>Modalert For Sale</a>. <a href='http://elegantcode.com/?p=4671'>Buy Quinine no prescription</a>. <a href='http://elegantcode.com/?p=4643'>Premarin duration</a>. <a href='http://elegantcode.com/?p=4340'>Purchase Atarax for sale</a>. <a href='http://elegantcode.com/?p=4732'>Abilify price</a>. <a href='http://elegantcode.com/?p=4373'>No prescription Topamax online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.thegriffonnews.com/?p=10565'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5050'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://changecamp.ca/?p=593'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://linuxologist.com/?p=450'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://blog.farmland.org/?p=1496'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.quarterlives.com/?p=930'>Female Pink Viagra brand name</a>. <a href='http://www.greatgreengoods.com/?p=3683'>Discount Female Pink Viagra</a>. <a href='http://www.macneilbmx.com/blog/?p=4935'>Female Pink Viagra pics</a>. <a href='http://social-blend.com/?p=671'>Female Pink Viagra results</a>. <a href='http://4realz.net/?p=847'>Female Pink Viagra pics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; xaml</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Betnovate Without Prescription</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinWidth&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinWidth}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinHeight&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinHeight}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderThickness&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> InputControlBorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontFamily&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontFamily}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontSize&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.HorizontalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.VerticalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.ZoomMode&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Padding&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxPaddingThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButtonStyle&quot;</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;/&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Pressed&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> FontFamily</span><span style="background:#ffffff;color:#0000ff">=&quot;Segoe UI Symbol&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;X&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;*&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;Auto&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Focused&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonVisible&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonCollapsed&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Let’s test what we have so far.&#160; Add an instance of our WatermarkTextBox control to the BlankPage.xaml.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5b472f91-aaa4-4de0-a251-52d2d2c82795" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Page</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Class</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTextBoxControl.BlankPage&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">x</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">local</span><span style="background:#ffffff;color:#0000ff">=&quot;using:WatermarkTextBoxControl&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">d</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">mc</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> mc</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Ignorable</span><span style="background:#ffffff;color:#0000ff">=&quot;d&quot;&gt;</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Page</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image5.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb5.png" width="275" height="60" /></a></p>  <p>Looks great.&#160; Just like the default Windows TextBox.&#160; Now we need to start adding our Watermark elements to it.&#160; Obviously we need a property for our Watermark.&#160; Your first thought maybe to define it as a type of string, but I want to support any element, not just text, so I will define it as a type of Object.&#160; This will allow me to nest controls inside of the Watermark property instead of being restricted to a simple string.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:db082020-3ed1-4025-b979-4d938ab172a9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;Watermark&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> Watermark</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>I also want to define a DataTemplate that will be used to define the ContentTemplate for the Watermark.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd631c4b-41c5-442b-8fb7-9704ba9c139b" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkTemplateProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000"> WatermarkTemplate</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkTemplateProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkTemplateProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Now we need to modify our control template to support our new Watermark property. We will do this by simply adding a ContentPresenter to our Template.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4431129a-2a62-4f39-abc1-6c7e0c47b874" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate price, coupon</b>, <b>Where to buy Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span></div> </div> </div>  <p>Oh, <b>effects of Betnovate</b>, <b>Is Betnovate safe</b>, and don’t forget the ContentTemplate that will define the default look for our watermark.&#160; This is placed at the top of the Generic.xaml.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baa07ca8-8bac-40b7-aece-36f27dedd0e5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>purchase Betnovate online no prescription</b>, <b>Online buy Betnovate without a prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Key</span><span style="background:#ffffff;color:#0000ff">=&quot;DefaultWatermarkTemplate&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentControl</span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">Binding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;Gray&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>And we need to set the default value in a style setter.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7175292-1fca-49aa-85ae-7ff859ab8ec2" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Buy Betnovate online cod</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DefaultWatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot; /&gt;</span></div> </div> </div>    <p>As you can see, I placed the ComtentPresenter after the ContentElement and before the DeleteButton elements.&#160; You may have also noticed that I set the visibility to Collapsed.&#160; This is because by default I want the Watermark hidden.&#160; So that means we need to add some code to show the watermark when the text box has no focus and it has no text.&#160; First we need to add some visual states to the VisualStateManager.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b482c41e-77da-4f54-ad99-4493ac8b1f73" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from canada</b>, <b>Betnovate without prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkStates&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkVisible&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkCollapsed&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Next we need to add some code to handle the GotFocus and LostFocus events of the TextBox.&#160; Start by adding event handlers for the events in the constructor.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e05e8b51-c571-48bc-9ee7-10b58950f385" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from mexico</b>, <b>Japan, craiglist, ebay, overseas, paypal</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.GotFocus += WatermarkTextBox_GotFocus;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.LostFocus += WatermarkTextBox_LostFocus;</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>Now add the code that does the heavy lifting.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:367568eb-5f40-4e4a-9861-50bab0c05329" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate brand name</b>, <b>Purchase Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_GotFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, <b>where can i buy cheapest Betnovate online</b>, <b>Canada, mexico, india</b>, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState();</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_LostFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> hasFocus = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//if our text is empty and our control doesn&#39;t have focus then show the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//otherwise the control eirther has text or has focus which in either case we need to hide the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">String</span><span style="background:#ffffff;color:#000000">.IsNullOrEmpty(Text) &amp;&amp; !hasFocus)</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkVisible&quot;</span><span style="background:#ffffff;color:#000000">); </span><span style="background:#ffffff;color:#008000">//TODO: create constants for our magic strings</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">else</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkCollapsed&quot;</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToVisualState(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> stateName, <b>herbal Betnovate</b>, <b>Taking Betnovate</b>, </span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> useTransitions = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">VisualStateManager</span><span style="background:#ffffff;color:#000000">.GoToState(</span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">, stateName, <b>rx free Betnovate</b>, <b>Order Betnovate online c.o.d</b>, useTransitions);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>One last thing is to make sure we set the visual state when the template is applied.&#160; So override the OnApplyTemplate method as follows.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d36c00a9-70e0-4692-9b7c-92d0a6de7deb" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate schedule</b>, <b>Betnovate dosage</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">override</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnApplyTemplate()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">base</span><span style="background:#ffffff;color:#000000">.OnApplyTemplate();</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//we need to set the initial state of the watermark</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>That should do it.&#160; Now let check it out in action. Be sure to provide a watermark for our control.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0630f9fd-701c-4d59-bcdb-4c659a352180" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate cost</b>, <b>Betnovate no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#ff0000"> Watermark</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb6.png" width="279" height="60" /></a></p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb7.png" width="279" height="63" /></a></p>  <h4>Yes, <b>Betnovate from mexico</b>, <b>Betnovate description</b>, we found a bug</h4>  <p>Everything seems to be working perfectly.&#160; Until you actually try to use a watermark that isn’t text.&#160; Try using this as your watermark.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c7fdd2-45ff-4ca5-86cb-5fe1adc8c10e" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>online buying Betnovate</b>, <b>Betnovate pics</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Orientation</span><span style="background:#ffffff;color:#0000ff">=&quot;Horizontal&quot;&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Image</span><span style="background:#ffffff;color:#ff0000"> Source</span><span style="background:#ffffff;color:#0000ff">=&quot;Images/PencilTool16.png&quot;</span><span style="background:#ffffff;color:#ff0000"> Stretch</span><span style="background:#ffffff;color:#0000ff">=&quot;None&quot;</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;4,0, <b>Betnovate interactions</b>, <b>Get Betnovate</b>, 0,0&quot; /&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>Now let’s see our results.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb8.png" width="275" height="60" /></a></p>  <p>Hey!&#160; Where is my watermark?&#160; Well there appears to be a bug with a ContentPresenter/ContentControl that will not display content when the ContentTemplate has been set and the Content is anything else except a string.&#160; This just so happens to be the exact same bug that exists in Silverlight.&#160; Interesting I know.&#160; So how do we fix it?&#160; We have to delete the usage of our Watermarktemplate until this gets fixed.</p>  <p>Change:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:715e6953-8e22-4e2e-8b8f-a4700760cfa9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>real brand Betnovate online</b>, <b>Betnovate steet value</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>To:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f626a1e-1d1c-489a-96cb-7f056392a0a8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>my Betnovate experience</b>, <b>Betnovate wiki</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>               <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>Now let’s see what happens.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image9.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb9.png" width="276" height="59" /></a></p>  <p>Now that’s much better.&#160; Let’s hope this is just a beta bug.</p>  <p><a href="http://brianlagunas.com/downloads/source/WatermarkTextBoxControl.zip" target="_blank">Download the source</a></p>, <b>low dose Betnovate</b>.  Order Betnovate from mexican pharmacy.  Online Betnovate without a prescription.  Betnovate long term.  Betnovate photos.  Betnovate samples.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4354'>Glucophage For Sale</a>. <a href='http://elegantcode.com/?p=4681'>Betnovate For Sale</a>. <a href='http://elegantcode.com/?p=4291'>Buy Vibramycin Without Prescription</a>. <a href='http://elegantcode.com/?p=4268'>Soma For Sale</a>. <a href='http://elegantcode.com/?p=4276'>Buy Viagra Without Prescription</a>. <a href='http://elegantcode.com/?p=4831'>Buying Glucophage online over the counter</a>. <a href='http://elegantcode.com/?p=4846'>Effects of Ketoconazole Cream</a>. <a href='http://elegantcode.com/?p=5014'>Order Quinine online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4232'>Japan, craiglist, ebay, overseas, paypal</a>. <a href='http://elegantcode.com/?p=4867'>Ordering Soma online</a>.<br />
<b>Trackbacks from:</b> <a href='http://home.officesnapshots.com/?p=250'>Buy Betnovate Without Prescription</a>. <a href='http://reversemortgagedaily.com/?p=14063'>Buy Betnovate Without Prescription</a>. <a href='http://social-blend.com/?p=1202'>Buy Betnovate Without Prescription</a>. <a href='http://www.quarterlives.com/?p=454'>Buy Betnovate Without Prescription</a>. <a href='http://4realz.net/?p=758'>Buy Betnovate Without Prescription</a>. <a href='http://blog.farmland.org/?p=3440'>Betnovate dosage</a>. <a href='http://linuxologist.com/?p=129'>Betnovate price, coupon</a>. <a href='http://www.themusclecarplace.com/?p=3456'>Betnovate no rx</a>. <a href='http://www.thegriffonnews.com/?p=10192'>Betnovate use</a>. <a href='http://www.greatgreengoods.com/?p=3270'>Kjøpe Betnovate på nett, köpa Betnovate online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vermox For Sale</title>
		<link>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:51:29 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[So far we have built an earthquake application Vermox For Sale, , mapped an address using geocoding, and even Prism-fied the Bing Maps WPF control.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can [...]]]></description>
			<content:encoded><![CDATA[<p> <p>So far we have built an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earthquake application</a> <b>Vermox For Sale</b>, , <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">mapped an address</a> using geocoding, and even <a href="http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/" target="_blank">Prism-fied the Bing Maps WPF control</a>.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can create this application.</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services. </p>  <p>For this application we will be using the Geocode Service and the Route Service.&#160; The Geocode service is used to match addresses, <b>Vermox dangers</b>, <b>Vermox coupon</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>Vermox dose</b>, <b>Vermox dosage</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; The Route service is used to generate routes and driving directions based on locations or waypoints.</p>  <p>Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>Vermox pharmacy</b>.  <b>Cheap Vermox</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>ordering Vermox online</b>.  <b>Vermox from mexico</b>, </p>  <p>Open up your App.xaml. You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca628505-dd3b-4d33-ae53-ad0ea17f81a9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy no prescription Vermox online</b>, <b>Buying Vermox online over the counter</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>We need to add the Geocode and Route service to our application.&#160; First, <b>where can i buy cheapest Vermox online</b>, <b>Low dose Vermox</b>, let’s start by adding the Geocode service.&#160; Right click the project and select “Add Service Reference”.&#160; Use the following address:</p>  <p><a href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name. I called mine BingServices.&#160; Now we need to add the Route service, <b>Vermox steet value</b>, <b>No prescription Vermox online</b>, but we don’t want to add a separate service reference.&#160; Ideally we would have a single service that contained both the Geocode and Route services.&#160; Luckily there is a trick we can use to do just that.&#160; Select the Project and click the “Show All Files” button at the top of the Solution Explorer.&#160; Expand the Service Reference folder and then expand the BingServices service.&#160; Look for a file called <strong>Reference.svcmap</strong>. Open the References.svcmap and locate the MetadataSource node.&#160; It will loko something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e1e98d3-82a4-419a-a32f-707e0559123c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox duration</b>, <b>Order Vermox online overnight delivery no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Simply add a new MetatdataSource as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7291104c-336c-4f44-9a3e-5843babcba3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox schedule</b>, <b>Where can i buy Vermox online</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">2</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see we added a new MetadataSource that points to the Route service and we gave it a SourceId of 2.&#160; Now right click the service and select “Update Service Reference”.&#160; This will generate a single service proxy for both the Geocode and Route services.&#160; Pretty slick huh?</p>  <p>The next step will be to create a ViewModel that will contain an ICommand that will execute the route calculation, <b>Vermox long term</b>, <b>Vermox price</b>, properties that will represent a “To” address and a “From” address.&#160; We will also need a property for the RouteResult and for the directions we generate.&#160; Lets first create our Direction object:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0230a924-5d25-4bed-880a-8b8cca1043e9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox samples</b>, <b>After Vermox</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">Direction</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Description { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">Location</span> Location { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> }</div> </div> </div>  <p>Now we will need a make-shift delegate command (do not use in production code):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:424be6fd-5bed-4501-ac25-33db908058c2" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>doses Vermox work</b>, <b>Is Vermox safe</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span> : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span> _execute;<br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span> execute)<br>     {<br>         _execute = execute;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke();<br>     }<br> }</div> </div> </div>  <p>Now on to the ViewModel itself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d9737cbe-bea9-4b93-af31-534d3ad53cb1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox pics</b>, <b>Vermox pictures</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">RouteViewModel</span>: <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> CalculateRouteCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _from = <span style="color:#a31515">&quot;Meridian, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> From<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _from; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _from = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;From&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _to = <span style="color:#a31515">&quot;Boise, <b>Vermox used for</b>, <b>Online buy Vermox without a prescription</b>, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> To<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _to; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _to = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;To&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">RouteResult</span> _routeResult;<br>     <span style="color:#0000ff">public</span> BingServices.<span style="color:#2b91af">RouteResult</span> RouteResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _routeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _routeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;RouteResult&quot;</span>);<br>         }<br>     }<br>     <br> <br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; _directions;<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; Directions<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _directions; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _directions = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;Directions&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> RouteViewModel()<br>     {<br>         CalculateRouteCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>(CalculateRoute);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute()<br>     {<br>         <span style="color:#0000ff">var</span> from = GeocodeAddress(From);<br>         <span style="color:#0000ff">var</span> to = GeocodeAddress(To);<br> <br>         CalculateRoute(from, to);<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">GeocodeResult</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br>         BingServices.<span style="color:#2b91af">GeocodeResult</span> result = <span style="color:#0000ff">null</span>;<br> <br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Query = address;<br>             result = client.Geocode(request).Results[0];<br>         }<br> <br>         <span style="color:#0000ff">return</span> result;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute(BingServices.<span style="color:#2b91af">GeocodeResult</span> from, <b>online buying Vermox hcl</b>, <b>Vermox reviews</b>, BingServices.<span style="color:#2b91af">GeocodeResult</span> to)<br>     {<br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">RouteServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IRouteService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">RouteRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Waypoints = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;BingServices.<span style="color:#2b91af">Waypoint</span>&gt;();<br>             request.Waypoints.Add(ConvertResultToWayPoint(from));<br>             request.Waypoints.Add(ConvertResultToWayPoint(to));<br> <br>             request.Options = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteOptions</span>();<br>             request.Options.RoutePathType = BingServices.<span style="color:#2b91af">RoutePathType</span>.Points;<br> <br>             RouteResult = client.CalculateRoute(request).Result;<br>         }<br> <br>         GetDirections();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GetDirections()<br>     {<br>         Directions = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt;();<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">ItineraryItem</span> item <span style="color:#0000ff">in</span> RouteResult.Legs[0].Itinerary)<br>         {<br>             <span style="color:#0000ff">var</span> direction = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Direction</span>();<br>             direction.Description = GetDirectionText(item);<br>             direction.Location = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(item.Location.Latitude, item.Location.Longitude);<br>             Directions.Add(direction);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">string</span> GetDirectionText(BingServices.<span style="color:#2b91af">ItineraryItem</span> item)<br>     {<br>         <span style="color:#0000ff">string</span> contentString = item.Text;<br>         <span style="color:#008000">//Remove tags from the string</span><br>         <span style="color:#2b91af">Regex</span> regex = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Regex</span>(<span style="color:#a31515">&quot;&lt;(.|&#92;n)*?&gt;&quot;</span>);<br>         contentString = regex.Replace(contentString, <b>purchase Vermox for sale</b>, <b>Vermox results</b>, <span style="color:#0000ff">string</span>.Empty);<br>         <span style="color:#0000ff">return</span> contentString;<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">Waypoint</span> ConvertResultToWayPoint(BingServices.<span style="color:#2b91af">GeocodeResult</span> result)<br>     {<br>         BingServices.<span style="color:#2b91af">Waypoint</span> waypoint = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">Waypoint</span>();<br>         waypoint.Description = result.DisplayName;<br>         waypoint.Location = result.Locations[0];<br>         <span style="color:#0000ff">return</span> waypoint;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>Let’s walk though the CalculateRoute Method.&#160; First we geocode the “From” and “To” properties the same way we did in the <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">geocoding post</a>.&#160; Once we have our From and To locations we use those results to generate a RouteRequest and send that request to the Route service.&#160; The service will generate a result and we set our RouteResult property accordingly.&#160; This property will be used in data binding shortly.&#160; Next we generate an ObservableCollection&lt;Direction&gt; by looping through all the ItineraryItems in the result.&#160; </p>  <p>Now that we have generate all of our data, <b>online buying Vermox</b>, <b>Vermox forum</b>, we need to create a View that supports and displays this data, but before we do that we need to create some attached properties.&#160; Why do you ask?&#160; Well because as it stands, <b>Vermox online cod</b>, <b>Vermox no prescription</b>, the Bing Maps WPF control is not data binding friendly.&#160; So we need to enable data binding with the use of attached properties.&#160; We will need an attached property for the Route result which will be responsible for drawing the route line on the map.&#160; We will also need one for the MapLayer that will be used to contain the route line.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55925f26-554d-4793-8b07-532984d855c6" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>order Vermox from United States pharmacy</b>, <b>Vermox australia, uk, us, usa</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> RouteResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteResult&quot;</span>, <span style="color:#0000ff">typeof</span>(BingServices.<span style="color:#2b91af">RouteResult</span>), <b>Vermox gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Vermox overnight</b>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingServices.<span style="color:#2b91af">RouteResult</span> GetRouteResult(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingServices.<span style="color:#2b91af">RouteResult</span>)target.GetValue(RouteResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteResult(<span style="color:#2b91af">DependencyObject</span> target, BingServices.<span style="color:#2b91af">RouteResult</span> value)<br>     {<br>         target.SetValue(RouteResultProperty, value);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteResultChanged((<span style="color:#2b91af">Map</span>)o, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.OldValue, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.NewValue);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">Map</span> map, BingServices.<span style="color:#2b91af">RouteResult</span> oldValue, BingServices.<span style="color:#2b91af">RouteResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">MapPolyline</span> routeLine = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapPolyline</span>();<br>         routeLine.Locations = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationCollection</span>();<br>         routeLine.Opacity = 0.65;<br>         routeLine.Stroke = <span style="color:#0000ff">new</span> <span style="color:#2b91af">SolidColorBrush</span>(<span style="color:#2b91af">Colors</span>.Blue);<br>         routeLine.StrokeThickness = 5.0;<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">Location</span> loc <span style="color:#0000ff">in</span> newValue.RoutePath.Points)<br>         {<br>             routeLine.Locations.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(loc.Latitude, loc.Longitude));<br>         }<br> <br>         <span style="color:#0000ff">var</span> routeLineLayer = GetRouteLineLayer(map);<br>         <span style="color:#0000ff">if</span> (routeLineLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             routeLineLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetRouteLineLayer(map, routeLineLayer);<br>         }<br> <br>         routeLineLayer.Children.Clear();<br>         routeLineLayer.Children.Add(routeLine);<br> <br>         <span style="color:#008000">//Set the map view</span><br>         <span style="color:#2b91af">LocationRect</span> rect = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationRect</span>(routeLine.Locations[0], routeLine.Locations[routeLine.Locations.Count - 1]);<br>         map.SetView(rect);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteResult</span><br> <br>     <span style="color:#0000ff">#region</span> RouteLineLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteLineLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteLineLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteLineLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(RouteLineLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(RouteLineLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteLineLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         <span style="color:#0000ff">if</span> (!map.Children.Contains(newValue))<br>             map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteLineLayer</span><br> }</div> </div> </div>  <p>The RouteResult property simply creates a MapPolyline, loops through all the points in the result and adds the locations to the route line.&#160; It then gets the RouteLineLayer and adds it to the map.&#160; Lastly, it sets the map’s view to best fit the route line.</p>  <p>Now we are ready for the View:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:393d6882-6c78-48e8-9046-d517df235427" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">core</span><span style="color:#0000ff">=&quot;clr-namespace:BingMapsCalculateRouteDemo.Core&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;RouteTemplate&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Ellipse</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Fill</span><span style="color:#0000ff">=&quot;Red&quot;</span><span style="color:#ff0000"> Opacity</span><span style="color:#0000ff">=&quot;0.8&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.Position</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Location}</span><span style="color:#0000ff">&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.PositionOrigin</span><span style="color:#0000ff">=&quot;Center&quot;</span><br>                     <span style="color:#ff0000"> Tag</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding}</span><span style="color:#0000ff">&quot;</span><br>                     <span style="color:#ff0000"> MouseEnter</span><span style="color:#0000ff">=&quot;Route_MouseEnter&quot;</span> <br>                     <span style="color:#ff0000"> MouseLeave</span><span style="color:#0000ff">=&quot;Route_MouseLeave&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;150&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> From}</span><span style="color:#0000ff">&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> To}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Get Route&quot;</span><span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CalculateRouteCommand}</span><span style="color:#0000ff">&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=&quot;AerialWithLabels&quot;</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> VerticalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> RouteResult}</span><span style="color:#0000ff">&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteLineLayer</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ElementName</span><span style="color:#0000ff">=RouteLineLayer}&quot;</span><br>                  <span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot; &gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;RouteLineLayer&quot; /&gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapItemsControl</span><span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Directions}</span><span style="color:#0000ff">&quot;</span><br>                                      <span style="color:#ff0000"> ItemTemplate</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> RouteTemplate}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br> <br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupLayer&quot;&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopup&quot;</span><span style="color:#ff0000"> Visibility</span><span style="color:#0000ff">=&quot;Collapsed&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;15&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupText&quot;</span><span style="color:#ff0000"> FontSize</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> FontWeight</span><span style="color:#0000ff">=&quot;Bold&quot;</span><span style="color:#ff0000"> TextWrapping</span><span style="color:#0000ff">=&quot;Wrap&quot; /&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Oh and don’t forget the code behind:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:14f2277a-a347-48e8-afd6-41465898d7fe" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">partial</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span><br> {<br>     <span style="color:#0000ff">public</span> MainWindow()<br>     {<br>         InitializeComponent();<br>         DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">RouteViewModel</span>();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseEnter(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         <span style="color:#2b91af">FrameworkElement</span> pin = sender <span style="color:#0000ff">as</span> <span style="color:#2b91af">FrameworkElement</span>;<br>         <span style="color:#2b91af">MapLayer</span>.SetPosition(ContentPopup, <span style="color:#2b91af">MapLayer</span>.GetPosition(pin));<br>         <span style="color:#2b91af">MapLayer</span>.SetPositionOffset(ContentPopup, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Point</span>(20, -15));<br> <br>         <span style="color:#0000ff">var</span> location = (<span style="color:#2b91af">Direction</span>)pin.Tag;<br> <br>         ContentPopupText.Text = location.Description;<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Visible;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseLeave(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Collapsed;<br>     }<br> }</div> </div> </div>  <p>Now let’s view the fruits of our labor at runtime.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/09/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/09/image_thumb.png" width="644" height="453" /></a></p>  <p>As you can see, given a “From” and “To” address, we can draw a route line and provide turn-by-turn directions as the user hovers over the direction pins.&#160; Pretty neat huh?&#160; And it wasn’t too difficult to pull off.&#160; As always you can <a href="http://www.brianlagunas.com/downloads/source/BingMapsCalculateRouteDemo.zip">Download the Source</a> and start playing.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4306'>Buy Biaxin Without Prescription</a>. <a href='http://elegantcode.com/?p=4228'>Aricept For Sale</a>. <a href='http://elegantcode.com/?p=4340'>Atarax For Sale</a>. <a href='http://elegantcode.com/?p=5052'>Lotrisone For Sale</a>. <a href='http://elegantcode.com/?p=4407'>Buy Nexium Without Prescription</a>. <a href='http://elegantcode.com/?p=4873'>Cafergot treatment</a>. <a href='http://elegantcode.com/?p=4780'>Canada, mexico, india</a>. <a href='http://elegantcode.com/?p=4202'>Online buying Celexa</a>. <a href='http://elegantcode.com/?p=4335'>Fast shipping Differin</a>. <a href='http://elegantcode.com/?p=4205'>Purchase Allopurinol online no prescription</a>.<br />
<b>Trackbacks from:</b> <a href='http://linuxologist.com/?p=193'>Vermox For Sale</a>. <a href='http://blog.farmland.org/?p=3110'>Vermox For Sale</a>. <a href='http://home.officesnapshots.com/?p=122'>Vermox For Sale</a>. <a href='http://reversemortgagedaily.com/?p=14171'>Vermox For Sale</a>. <a href='http://social-blend.com/?p=495'>Vermox For Sale</a>. <a href='http://www.themusclecarplace.com/?p=3175'>Vermox for sale</a>. <a href='http://www.thegriffonnews.com/?p=10415'>Ordering Vermox online</a>. <a href='http://www.quarterlives.com/?p=743'>Order Vermox online c.o.d</a>. <a href='http://tayloegray.com/?p=351'>Vermox from mexico</a>. <a href='http://www.greatgreengoods.com/?p=3949'>Purchase Vermox for sale</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buy Female Pink Viagra Without Prescription</title>
		<link>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prism-fy-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 16:13:02 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[prism]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been playing around with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled [...]]]></description>
			<content:encoded><![CDATA[<p> <p>If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">playing</a> <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">around</a> with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled MapLayers at runtime using Prism.</p>  <p> <b>Buy Female Pink Viagra Without Prescription</b>, The concept is simple.&#160; We want a Bing Maps application that can be extended at runtime.&#160; By extended, I mean that I want the ability to add new elements/modules to the Map at runtime.&#160; The important thing about these elements/modules is that they can come from anywhere and they should be loosely coupled from the Map as well as other elements/modules that may exist on the Map.</p>  <p>Luckily for us this is extremely simple to accomplish.&#160; All we have to do is create a custom RegionAdapter, register it with our Prism application, and then apply it to our Bing Map control.&#160; So let’s start with the RegionAdapter.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8809704-1b89-4479-9f50-32a29a8ce6e3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapRegionAdapter</span> : <span style="color:#2b91af">RegionAdapterBase</span>&lt;<span style="color:#2b91af">Map</span>&gt;<br> {<br>     <span style="color:#0000ff">public</span> MapRegionAdapter(<span style="color:#2b91af">IRegionBehaviorFactory</span> regionBehaviorFactory)<br>         : <span style="color:#0000ff">base</span>(regionBehaviorFactory)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> Adapt(<span style="color:#2b91af">IRegion</span> region, <span style="color:#2b91af">Map</span> regionTarget)<br>     {<br>         region.Views.CollectionChanged += (s, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Add)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.NewItems)<br>                     regionTarget.Children.Add(element);<br>             }<br>             <span style="color:#0000ff">else</span> <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Remove)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.OldItems)<br>                     <span style="color:#0000ff">if</span> (regionTarget.Children.Contains(element))<br>                         regionTarget.Children.Remove(element);<br>             }<br>         };<br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">IRegion</span> CreateRegion()<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">AllActiveRegion</span>();<br>     }<br> }</div> </div> </div> </p>  <p>Now in the Bootstrapper we need to register our mapping.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fce11974-ec82-4641-ac5c-a37a9ff443df" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">RegionAdapterMappings</span> ConfigureRegionAdapterMappings()<br> {<br>     <span style="color:#2b91af">RegionAdapterMappings</span> mappings = <span style="color:#0000ff">base</span>.ConfigureRegionAdapterMappings();<br>     mappings.RegisterMapping(<span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Map</span>), Container.Resolve&lt;<span style="color:#2b91af">MapRegionAdapter</span>&gt;());<br>     <span style="color:#0000ff">return</span> mappings;<br> }</div> </div> </div> </p>  <p>Now we simply give the Map a region name. (this is actually all the shell has in it)</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a72303d9-120c-4bba-a39e-18ae1979a63a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>online Female Pink Viagra without a prescription</b>, <b>Female Pink Viagra forum</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> prism</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionManager.RegionName</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Static</span><span style="color:#ff0000"> inf</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionNames</span><span style="color:#0000ff">.MapRegion}&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40, <b>order Female Pink Viagra online overnight delivery no prescription</b>, <b>Low dose Female Pink Viagra</b>, -95&quot;</span><span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot; /&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div> </p>  <p>That is all there is to it.&#160; You can now start injecting modules onto the Map at runtime.&#160; Lets look at my two modules I am using as an example.&#160; Here is the structure of my application:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb13.png" width="305" height="190" /></a></p>  <ul>   <li>ModuleA will inject a MapPolygon in the Shape of Texas.</li>    <li>ModuleB is the Earthquake application we built in an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earlier post</a>.</li>    <li>Infrastructure is the project where shared code goes, in this case our MapRegionAdapter</li>    <li>BingMapsPrismfiedDemo is of course our shell project.</li> </ul>  <p>This is what the application looks like at runtime when both modules have been injected into it.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb14.png" width="644" height="334" /></a></p>  <p>Now I can easily add more layers to this map as I see fit.&#160; As always, <b>online buy Female Pink Viagra without a prescription</b>, <b>No prescription Female Pink Viagra online</b>, <a href="http://www.brianlagunas.com/downloads/source/BingMapsPrismfiedDemo.zip">Download the Source</a> and start playing.&#160; You may want to add MEF support as well.</p>.  Where can i find Female Pink Viagra online.  Effects of Female Pink Viagra.  Purchase Female Pink Viagra.  Female Pink Viagra over the counter.  Purchase Female Pink Viagra online.  Buy Female Pink Viagra without prescription.  Female Pink Viagra recreational.  Buy generic Female Pink Viagra.  Cheap Female Pink Viagra.  Female Pink Viagra no prescription.  Female Pink Viagra wiki.  Cheap Female Pink Viagra no rx.  Female Pink Viagra canada, mexico, india.  Buying Female Pink Viagra online over the counter.  Where to buy Female Pink Viagra.  Female Pink Viagra cost.  Female Pink Viagra from mexico.  Is Female Pink Viagra safe.  Buy Female Pink Viagra online cod.  Buy Female Pink Viagra from mexico.  Where can i order Female Pink Viagra without prescription.  Real brand Female Pink Viagra online.  Buy Female Pink Viagra from canada.  Female Pink Viagra overnight.  Female Pink Viagra use.  Order Female Pink Viagra from mexican pharmacy.  Female Pink Viagra street price.  Female Pink Viagra coupon.  Female Pink Viagra schedule.  Female Pink Viagra mg.  Female Pink Viagra interactions.  Taking Female Pink Viagra.  Female Pink Viagra used for.  Is Female Pink Viagra addictive.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4750'>Celebrex For Sale</a>. <a href='http://elegantcode.com/?p=4661'>Buy Methotrexate Without Prescription</a>. <a href='http://elegantcode.com/?p=4755'>Buy Zovirax Without Prescription</a>. <a href='http://elegantcode.com/?p=4311'>Buy Topamax Without Prescription</a>. <a href='http://elegantcode.com/?p=4476'>Modalert For Sale</a>. <a href='http://elegantcode.com/?p=4671'>Buy Quinine no prescription</a>. <a href='http://elegantcode.com/?p=4643'>Premarin duration</a>. <a href='http://elegantcode.com/?p=4340'>Purchase Atarax for sale</a>. <a href='http://elegantcode.com/?p=4732'>Abilify price</a>. <a href='http://elegantcode.com/?p=4373'>No prescription Topamax online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.thegriffonnews.com/?p=10565'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5050'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://changecamp.ca/?p=593'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://linuxologist.com/?p=450'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://blog.farmland.org/?p=1496'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.quarterlives.com/?p=930'>Female Pink Viagra brand name</a>. <a href='http://www.greatgreengoods.com/?p=3683'>Discount Female Pink Viagra</a>. <a href='http://www.macneilbmx.com/blog/?p=4935'>Female Pink Viagra pics</a>. <a href='http://social-blend.com/?p=671'>Female Pink Viagra results</a>. <a href='http://4realz.net/?p=847'>Female Pink Viagra pics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Buy Tindamax Without Prescription</title>
		<link>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-an-address-with-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:21:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[In my last post Buy Tindamax Without Prescription, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate [...]]]></description>
			<content:encoded><![CDATA[<p> <p>In my last <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">post</a> <b>Buy Tindamax Without Prescription</b>, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate maps and imagery, driving directions, distance calculations, and other location intelligence into your applications, business processes, and Web sites. </p>  <p>Let’s start with the Geocode Service which is used to match addresses, <b>buy cheap Tindamax</b>, <b>Purchase Tindamax for sale</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>my Tindamax experience</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; We will create a simple application that allows you to enter an address and place a pushpin at that location.&#160; First thing is first:</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165" target="_blank">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/" target="_blank">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services.&#160; Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>order Tindamax from United States pharmacy</b>.  <b>Online buying Tindamax</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>buy Tindamax without a prescription</b>.  <b>After Tindamax</b>, </p>  <p>Open up your App.xaml.&#160; You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c7fbbfb-a6ac-496d-a298-bddbd655ac65" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>discount Tindamax</b>, <b>Buy Tindamax no prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Now create a very simple UI that will accept an address and a button to perform the geocoding:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc9a874e-765b-4bc2-b82b-88a96f1ef84c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax treatment</b>, <b>Tindamax no rx</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>                  <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>The next thing we need to do is add a new Service Reference to the project and point to the following service:</p>  <p><a title="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc" href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name (I called mine BingMapsService) and just for fun, <b>buy Tindamax online cod</b>, <b>Generic Tindamax</b>, in the “Add Service Reference” dialog, click the “Advanced” button and click “Generate asynchronous operations”.</p>  <p>Next we need to create a ViewModel to support our View.&#160; This is a WPF application after all.&#160; This ViewModel will need a command for the button that will perform the geocoding, <b>Tindamax duration</b>, <b>Low dose Tindamax</b>, and a property that will represent the result of the service that the UI will use to map the address.&#160; It should resemble something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b09cd91-31d1-426f-a539-9fe004a3702a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax street price</b>, <b>Tindamax blogs</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">GeocodeViewModel</span> : <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> GeocodeAddressCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> _geocodeResult;<br>     <span style="color:#0000ff">public</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GeocodeResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _geocodeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _geocodeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> GeocodeViewModel()<br>     {<br>         GeocodeAddressCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>&lt;<span style="color:#2b91af">String</span>&gt;(GeocodeAddress);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>I want to point out that the DelegateCommand&lt;T&gt; is a very simple ICommand implementation and should NOT be used in production applications.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cac2fd6-5f40-4d30-b70e-39cf0eb39d77" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax wiki</b>, <b>Tindamax cost</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span>&lt;T&gt; : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span>&lt;T&gt; _execute;<br> <br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span>&lt;T&gt; execute)<br>     {<br>         _execute = execute;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke((T)parameter);<br>     }<br> }</div> </div> </div>  <p>Let’s hook our UI up to our command.&#160; it should look something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f154da3-e1a9-48e1-8dcd-53063e2268ec" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax overnight</b>, <b>Online buy Tindamax without a prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;</span> <br>                    <span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeAddressCommand}</span><span style="color:#0000ff">&quot;</span><br>                    <span style="color:#ff0000"> CommandParameter</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">, <b>where can i buy Tindamax online</b>, <b>Discount Tindamax</b>, </span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=</span>_<span style="color:#0000ff">txtAddress}&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Notice that we are using the text of the TextBox as the CommandParameter.&#160; Next, we need to implement the command:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0d2006e3-d7cf-483a-b57b-284d06ecffff" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax for sale</b>, <b>Tindamax used for</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br> {<br>     <span style="color:#0000ff">using</span> (BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>     {<br>         client.GeocodeCompleted += (o, <b>buy no prescription Tindamax online</b>, <b>Tindamax online cod</b>, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Error == <span style="color:#0000ff">null</span>)<br>             {<br>                 GeocodeResult = e.Result.Results[0];<br>             }<br>         };<br> <br>         BingMapsService.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeRequest</span>();<br>         request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>         request.Query = address;<br>         client.GeocodeAsync(request);<br>     }<br> }</div> </div> </div>  <p>In this command we are simply creating an instance of the service client, creating a GeocodeRequest, <b>Tindamax coupon</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, setting the credentials using the ApplicationId we have stored in the App.xaml, and then using the address as the Query for the request.&#160; When the call to the service is completed we are setting the GeocodeResult property to the first element in the results.</p>  <p>Now the tricky part.&#160; We want to place a Pushpin on the address that was entered and then move the map to that location.&#160; We also need to make sure that when another address is entered, <b>buying Tindamax online over the counter</b>, <b>Is Tindamax safe</b>, we clear any previous Pushpins that may exist on the map.&#160; We also have to be aware that other elements my be on the map and we don’t want to accidentally alter those elements.&#160; Oh and did I mention this was an MVVM application and this has to be done with just data binding. </p>  <p>The approach that I decided to go with is to use <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" target="_blank">Attached Properties</a>.&#160; So I created two attached properties; one for the GeocodeResult and another for a MapLayer that will be dedicated to the GeocodeResult.&#160; This will allow us to create a MapLayer that is specific to our GeocodeResut and not alter any other elements that may be on the map.&#160; Let’s check out the code.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3cc3f4e4-cbae-4ffe-93bf-4a10f2e36d08" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>herbal Tindamax</b>, <b>Tindamax price, coupon</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> GeocodeResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>, <b>buy Tindamax without a prescription</b>, <b>Buy Tindamax without prescription</b>, <span style="color:#0000ff">typeof</span>(BingMapsService.<span style="color:#2b91af">GeocodeResult</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <b>cheap Tindamax</b>, <b>Tindamax trusted pharmacy reviews</b>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GetGeocodeResult(<span style="color:#2b91af">Map</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)target.GetValue(GeocodeResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResult(<span style="color:#2b91af">Map</span> target, <b>ordering Tindamax online</b>, <b>Tindamax canada, mexico, india</b>, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> value)<br>     {<br>         target.SetValue(GeocodeResultProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultChanged((<span style="color:#2b91af">Map</span>)o, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.OldValue, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">Map</span> map, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> oldValue, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">Location</span> location = newValue.Locations.Select(x =&gt; <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(x.Latitude, x.Longitude)).First();<br> <br>         <span style="color:#2b91af">Pushpin</span> pin = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Pushpin</span>();<br>         pin.Location = location;<br>         pin.ToolTip = newValue.Address.FormattedAddress;<br> <br>         <span style="color:#0000ff">var</span> locationLayer = GetGeocodeResultLayer(map);<br>         <span style="color:#0000ff">if</span> (locationLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             locationLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetGeocodeResultLayer(map, locationLayer);<br>         }<br> <br>         locationLayer.Children.Clear();<br>         locationLayer.Children.Add(pin);<br> <br>         map.SetView(location, map.ZoomLevel);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResult</span><br> <br>     <span style="color:#0000ff">#region</span> GeocodeResultLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResultLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(GeocodeResultLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(GeocodeResultLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResultLayer</span><br> }</div> </div> </div>  <p>Notice that when the GeocodeResult changes we get the Location and create a pushpin for that location.&#160; We also set the tooltip to the FormattedAddress of the GeocodeResult.&#160; So when we hover over the pushpin we will see a nice little tooltip of the address.&#160; Next we try to get the GeocodeResultLayer from the map, if it is null this means it doesn’t exist on the map yet so we create one and assign it accordingly.&#160; We clear the layer child elemnts and then add out pushpin.&#160; The last thing we do is call the SetView method of the Map control passing in the location and the current ZoomLevel.</p>  <p>The final step is to use our AttachedProperty on the map.&#160; Be sure to create a namespace for the MapInteractivity class and define it as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72d6307a-aef3-4f70-8d47-8d4529fc74e0" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>          <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.GeocodeResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeResult}</span><span style="color:#0000ff">&quot;</span><br>          <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>One last thing.&#160; Be sure to remember to set your DataContext of your View to the ViewModel we have created:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f7d0b4f-e096-487d-8343-fb42c94c3360" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> MainWindow()<br> {<br>     InitializeComponent();<br>     DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">GeocodeViewModel</span>(); <br> }</div> </div> </div>  <p>That’s it.&#160; You now have an application the can map (geocode) an address using the Bing Maps WPF Control and the Geocoding SOAP Service.&#160; Oh and we are doing this all with MVVM and data binding which is my favorite part.&#160; Be sure to <a href="http://www.brianlagunas.com/downloads/source/bingmapsgeocodedemo.zip">Download the Source</a> and start playing around.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4746'>Buy Clindamycin Gel Without Prescription</a>. <a href='http://elegantcode.com/?p=4328'>Buy Plavix Without Prescription</a>. <a href='http://elegantcode.com/?p=4302'>Buy Phenergan Without Prescription</a>. <a href='http://elegantcode.com/?p=4460'>Buy Proscar Without Prescription</a>. <a href='http://elegantcode.com/?p=4607'>Triamterene For Sale</a>. <a href='http://elegantcode.com/?p=4751'>Diflucan street price</a>. <a href='http://elegantcode.com/?p=4372'>Nexium steet value</a>. <a href='http://elegantcode.com/?p=4475'>Metronidazole Gel from mexico</a>. <a href='http://elegantcode.com/?p=4399'>Herbal Periactin</a>. <a href='http://elegantcode.com/?p=4858'>Tramadol over the counter</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.macneilbmx.com/blog/?p=6683'>Buy Tindamax Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=3313'>Buy Tindamax Without Prescription</a>. <a href='http://www.thegriffonnews.com/?p=9133'>Buy Tindamax Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5330'>Buy Tindamax Without Prescription</a>. <a href='http://changecamp.ca/?p=592'>Buy Tindamax Without Prescription</a>. <a href='http://social-blend.com/?p=444'>Tindamax online cod</a>. <a href='http://blog.farmland.org/?p=3958'>Order Tindamax from mexican pharmacy</a>. <a href='http://4realz.net/?p=717'>Tindamax forum</a>. <a href='http://reversemortgagedaily.com/?p=14265'>Tindamax trusted pharmacy reviews</a>. <a href='http://linuxologist.com/?p=1542'>Tindamax online cod</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &#8211; dynamically compile and run event handlers within loose XAML using CodeDom</title>
		<link>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom</link>
		<comments>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:37:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[dynamic code]]></category>
		<category><![CDATA[wpd]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/</guid>
		<description><![CDATA[Last week I wrote a blog post showing how you can write inline code in XAML.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon re-tweeted that post with a link to one of his own posts on exploring new techniques for DLR script in XAML which also links [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a blog post showing how <a href="http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/" target="_blank">you can write inline code in XAML</a>.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon <a href="http://twitter.com/#!/rrelyea/status/15099827364827136" target="_blank">re-tweeted</a> that post with a link to one of his own posts on <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/11/14/exploring-new-techniques-for-dlr-script-in-xaml.aspx" target="_blank">exploring new techniques for DLR script in XAML</a> which also links to another one of his posts which shows different techniques for <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/06/03/xaml-events-in-compiled-and-uncompiled-scenarios.aspx" target="_blank">hooking up events in compiled and uncompiled scenarios</a> which in turn links to <a href="http://www.thinkbottomup.com.au/site/blog/Embedding_DLR_Scripts_in_XAML_Part_1" target="_blank">this post about embedding DLR scripts in XAML</a> written by Daniel Paull.&#160; Wow, that is a lot of linking.</p>  <p>Well, now that everyone has been given their respective credit, let’s continue.&#160; I wanted to take my last post a little further.&#160; In that post I simply created an event handler for a button click event using inline code in the x:Code directive.&#160; If you started to play with the sample code, you might have thought to yourself, “I wonder if I can load this XAML, event handler and all, from a file or database and have it still work.”.&#160; Well, if you tried it, you found the answer really quick.&#160; No!&#160; The reason is pretty simple; code must be compiled in order to execute.&#160; Therefore any code inside loose XAML will fail.&#160; Also, when using loose XAML, trying to hookup an event handler would crash your application because it is not allowed.</p>  <p>Oh, then it must not be possible? Wrong!&#160; Well, then how do you do it if the code must be compiled?&#160; Simple, we compile the code just before we run it.&#160; Say what?&#160; That’s right, let me introduce you to the <a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" target="_blank">CodeDom</a>.&#160; The CodeDom allows you to dynamically generate and compile code at runtime.&#160; Let’s get to it.</p>  <p>We need to attach event handlers to elements in loose XAML, and have them execute C# code.&#160; Each element has different events to handle, and each event will execute different code.&#160; This tells me that we need an object that contains two properties, one to specify the RoutedEvent to handle, and another to specify the c# code to execute.&#160; We also need a common event handler definition to execute whenever the RoutedEvent is invoked.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c257533-76d5-4e97-9754-1b389f8f52b5" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DynamicEvent</span><br> {<br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the routed event to execute.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The routed event.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">RoutedEvent</span> RoutedEvent { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the script to run when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The script.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Script { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Called when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br>     {<br>         <br>     }<br> }</div> </div> </div>  <p>That was simple enough.&#160; Now, in order to attach event handlers to elements in loose XAML, we need away to get around the “no event handlers allowed” limitation.&#160; To do this we can use an attached property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c6021e-2311-4633-85f8-8fcb27a9cb89" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> HandlerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;Handler&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(OnHandlerChanged));<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DynamicEvent</span> GetHandler(<span style="color:#2b91af">DependencyObject</span> obj)<br> {<br>     <span style="color:#0000ff">return</span> (<span style="color:#2b91af">DynamicEvent</span>)obj.GetValue(HandlerProperty);<br> }<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetHandler(<span style="color:#2b91af">DependencyObject</span> obj, <span style="color:#0000ff">bool</span> value)<br> {<br>     obj.SetValue(HandlerProperty, value);<br> }<br> <br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnHandlerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">UIElement</span> uie = o <span style="color:#0000ff">as</span> <span style="color:#2b91af">UIElement</span>;<br>     <span style="color:#0000ff">if</span> (uie == <span style="color:#0000ff">null</span>)<br>         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">Exception</span>(<span style="color:#a31515">&quot;Attempt to set EventHandler on non-UIElement Type&quot;</span>);<br> <br>     <span style="color:#2b91af">DynamicEvent</span> oldHandler = e.OldValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br>     <span style="color:#2b91af">DynamicEvent</span> newHandler = e.NewValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br> <br>     <span style="color:#008000">// unhook the old event</span><br>     <span style="color:#0000ff">if</span> (oldHandler != <span style="color:#0000ff">null</span>)<br>         uie.RemoveHandler(oldHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(oldHandler.OnEventExecuted));<br> <br>     <span style="color:#008000">// hook up the new</span><br>     <span style="color:#0000ff">if</span> (newHandler != <span style="color:#0000ff">null</span>)<br>         uie.AddHandler(newHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(newHandler.OnEventExecuted));<br> <br> }</div> </div> </div>  <p>This attached property allows use to attach an instance of our DynamicEvent class to our element.&#160; When the Handler attached property is set, we simple add our OnEventExecute event handler to the RoutedEvent specified in the RoutedEvent property.&#160; Now we have the basic framework needed to attach and event handler to any event on any element in loose XAML.&#160; Let’s see how to attach an event handler in XAML using this newly created DynamicEvent class.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c323adca-e880-4dd4-997e-958bccc70c3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Initial Text&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#ff0000"> RoutedEvent</span><span style="color:#0000ff">=&quot;Button.Click&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#ff0000"> xml</span><span style="color:#0000ff">:</span><span style="color:#ff0000">space</span><span style="color:#0000ff">=&quot;preserve&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>                         <span style="color:#808080">var button = sender as Button;</span><br>                         <span style="color:#808080">button.Content = &quot;Changed with Dynamic Code&quot;;</span><br>                         <span style="color:#808080">]]&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Button</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see I have added a handler for a Button’s Click event.&#160; I also provided a Script to execute when the event is invoked.&#160; Notice that we are preserving the whitespace in the script.&#160; Of course nothing will happen just yet.&#160; Now we need to take the script and compile it at run time.&#160; This is where the CodeDom comes in.</p>  <p>The steps necessary to compile code at run time go a little something like this:</p>  <ul>   <li>Create a CodeCompileUnit </li>    <li>Add our namespace and import statements </li>    <li>create our dynamic class </li>    <li>add a method that will execute the Script </li>    <li>compile the code </li>    <li>execute the code </li> </ul>  <p>All these steps must be performed when the ROutedEvent is invoked, which means the code must be compiled inside the OnEventExecuted event handler.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56b1a794-ec6b-4976-9f18-e819f5a52641" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">CodeCompileUnit</span> compileUnit = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeCompileUnit</span>();<br> <br>     <span style="color:#008000">//create our namesapce and import statements, then add it to the compile unit</span><br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = CreateNamespaceAndImports();<br>     compileUnit.Namespaces.Add(namespaces);<br> <br>     <span style="color:#008000">//create our target class and add it to the namespace</span><br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = CreateTargetClass();<br>     namespaces.Types.Add(targetClass);<br> <br>     <span style="color:#008000">//create the ExecuteScript method and then add it to our class</span><br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = CreateExecuteScriptMethod();<br>     targetClass.Members.Add(executeEventMethod);<br> <br>     <span style="color:#008000">//create our compiler parameters</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = CreateCompilerParameters();<br> <br>     <span style="color:#008000">//compile the assembly</span><br>     <span style="color:#0000ff">var</span> results = CompileAssembly(compileUnit, compilerParams);<br> <br>     <span style="color:#008000">//execute the code</span><br>     ExecuteCode(results, sender, e);<br> }</div> </div> </div>  <p>The first step is really easy.&#160; We simply need to create an instance of the CodeCompileUnit class.&#160; The CodeCompileUnit references the CodeDom object graph and has properties for storing attributes, namespaces, and assemblies.&#160; Next we need to create our namespace and import statements.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b89b170-e94b-4b3b-a8d8-8df82193e6d3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the namespace and imports.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;remarks&gt;</span><span style="color:#008000">I have only added three import statements as an example. You should add all import statements required to run your dynamic code</span><span style="color:#808080">&lt;/remarks&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeNamespace</span> CreateNamespaceAndImports()<br> {<br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespace</span>(<span style="color:#a31515">&quot;WPFCodeInjection&quot;</span>);<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows.Controls&quot;</span>));<br>     <span style="color:#0000ff">return</span> namespaces;<br> }</div> </div> </div>  <p>Once the namespace and import statement are created we need to add them to out CodeCompileUnit instance.&#160; Then we need to create our dynamic class.&#160; We need to make sure it is a public class:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a495da08-da32-46e0-ba99-c5fac5d189e1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the target class.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeTypeDeclaration</span> CreateTargetClass()<br> {<br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeTypeDeclaration</span>(<span style="color:#a31515">&quot;DynamicClass&quot;</span>);<br>     targetClass.TypeAttributes = <span style="color:#2b91af">TypeAttributes</span>.Public;<br>     <span style="color:#0000ff">return</span> targetClass;<br> }</div> </div> </div>  <p>When the dynamic class is created we add it to our namespace.&#160; Now we create a method. We give it a name of ExecuteScript and set its access modifier to public.&#160; We specify that it accepts two parameters.&#160; One being the sender which is of type object, and one that is the event args that is of type RoutedEventArgs.&#160; Lastly, we set the body of the method to the Script property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4cae0858-7130-4df1-b3b1-cf49063a4d50" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the ExecuteScript method.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#2b91af">CodeMemberMethod</span> CreateExecuteScriptMethod()<br> {<br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeMemberMethod</span>();<br>     executeEventMethod.Name = <span style="color:#a31515">&quot;ExecuteScript&quot;</span>;<br>     executeEventMethod.Attributes = <span style="color:#2b91af">MemberAttributes</span>.Public | <span style="color:#2b91af">MemberAttributes</span>.Final;<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Object&quot;</span>, <span style="color:#a31515">&quot;sender&quot;</span>));<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Windows.RoutedEventArgs&quot;</span>, <span style="color:#a31515">&quot;e&quot;</span>));<br>     executeEventMethod.Statements.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeSnippetStatement</span>(Script));<br>     <span style="color:#0000ff">return</span> executeEventMethod;<br> }</div> </div> </div>  <p>Now we have to create our compiler parameters.&#160; These include adding referencing to the necessary Dlls required to run your code.&#160; We also want to specify that we want to generate the code in memory.&#160; If you wanted to you could save the assembly to a file.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cebbac90-1864-436d-8248-de681876fa83" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the compiler parameters.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerParameters</span> CreateCompilerParameters()<br> {<br>     <span style="color:#008000">//add compiler parameters and assembly references</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CompilerParameters</span>();<br>     compilerParams.CompilerOptions = <span style="color:#a31515">&quot;/target:library /optimize&quot;</span>;<br>     compilerParams.GenerateExecutable = <span style="color:#0000ff">false</span>;<br>     compilerParams.GenerateInMemory = <span style="color:#0000ff">true</span>;<br> <br>     <span style="color:#008000">//you can add references individually if you want by providing the location of the assembly</span><br>     <span style="color:#008000">//compilerParams.ReferencedAssemblies.Add(&quot;System.dll&quot;);</span><br> <br>     <span style="color:#008000">//I am lazy so I will just loop through the assemblies that are already loaded and add those</span><br>     <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Assembly</span> assembly <span style="color:#0000ff">in</span> <span style="color:#2b91af">AppDomain</span>.CurrentDomain.GetAssemblies())<br>     {<br>         <span style="color:#0000ff">try</span><br>         {<br>             <span style="color:#0000ff">string</span> location = assembly.Location;<br>             <span style="color:#0000ff">if</span> (!<span style="color:#2b91af">String</span>.IsNullOrEmpty(location))<br>                 compilerParams.ReferencedAssemblies.Add(location);<br>         }<br>         <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">NotSupportedException</span>)<br>         {<br>             <span style="color:#008000">// this happens for dynamic assemblies, so just ignore it.                     </span><br>         }<br>     }<br> <br>     <span style="color:#0000ff">return</span> compilerParams;<br> }</div> </div> </div>  <p>Now we compile the code into an assembly.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b05d391c-e1d9-47c3-b9b3-2c147f47e7bb" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Compiles the assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compileUnit&quot;&gt;</span><span style="color:#008000">The compile unit.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compilerParams&quot;&gt;</span><span style="color:#008000">The compiler params.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerResults</span> CompileAssembly(<span style="color:#2b91af">CodeCompileUnit</span> compileUnit, <span style="color:#2b91af">CompilerParameters</span> compilerParams)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">CSharpCodeProvider</span> provider = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CSharpCodeProvider</span>())<br>     {<br>         <span style="color:#008000">// =============================================================================== //</span><br>         <span style="color:#008000">// if you want to see the actual complied source code uncomment //</span><br>         <span style="color:#008000">// =============================================================================== //</span><br> <br>         <span style="color:#008000">//StringBuilder source = new StringBuilder();</span><br>         <span style="color:#008000">//StringWriter sw = new StringWriter(source);</span><br>         <span style="color:#008000">//provider.GenerateCodeFromCompileUnit(compileUnit, sw, new CodeGeneratorOptions());</span><br>         <span style="color:#008000">//string sourceCode = source.ToString();</span><br> <br>         <span style="color:#0000ff">var</span> results = provider.CompileAssemblyFromDom(compilerParams, compileUnit);<br>         <span style="color:#0000ff">return</span> results;<br>     }<br> }</div> </div> </div>  <p>The last thing we need to do is run the code that was just compiled.&#160; We will need the help of reflection to accomplish this.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09c68e9b-98f4-4334-aa9f-ecf464569e54" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Executes the ExecuteScript method from the compiled CodeDom assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;results&quot;&gt;</span><span style="color:#008000">The results.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> ExecuteCode(<span style="color:#2b91af">CompilerResults</span> results, <span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">try</span><br>     {<br>         <span style="color:#2b91af">Assembly</span> executingAssembly = results.CompiledAssembly;<br>         <span style="color:#0000ff">if</span> (executingAssembly != <span style="color:#0000ff">null</span>)<br>         {<br>             <span style="color:#008000">//create an instance of our newly compiled assembly</span><br>             <span style="color:#0000ff">object</span> assemblyInstance = executingAssembly.CreateInstance(<span style="color:#a31515">&quot;WPFCodeInjection.DynamicClass&quot;</span>);<br> <br>             <span style="color:#008000">//get our ExecuteScript method and execute it.</span><br>             <span style="color:#2b91af">MethodInfo</span> info = assemblyInstance.GetType().GetMethod(<span style="color:#a31515">&quot;ExecuteScript&quot;</span>);<br>             info.Invoke(assemblyInstance, <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[] { sender, e });<br>         }<br>     }<br>     <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">Exception</span> ex)<br>     {<br>         <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Error: An exception occurred while executing the script&quot;</span>, ex);<br>     }<br> }</div> </div> </div>  <p>That is it.&#160; Now to test this out lets create a .txt file that contains our XAML that we define above and save it CodeSnippet.txt.&#160; In our MainWindow.xaml.cs, lets handle the Loaded event and load our CodeSnippet.txt using the XamlReader.Load method.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc56e72c-6fdc-4430-afb5-4498031c46f1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">void</span> MainWindow_Loaded(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">FileStream</span> fs = <span style="color:#0000ff">new</span> <span style="color:#2b91af">FileStream</span>(<span style="color:#a31515">@&quot;./CodeSnippet.txt&quot;</span>, <span style="color:#2b91af">FileMode</span>.Open))<br>     {<br>         <span style="color:#0000ff">this</span>.Content = <span style="color:#2b91af">XamlReader</span>.Load(fs);<br>     }<br> }</div> </div> </div>  <p>Run the application is this is what it should look like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb9.png" width="174" height="179" /></a></p>  <p>Now click the button and our C# code defined within the Script property will be dynamically compiled and executed changed the text of the button to this:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb10.png" width="184" height="179" /></a></p>  <p>This is a very simple example and is not intended to be a complete solution, but it does show some of the powerful capabilities you have using WPF, XAML, and the CodeDom.&#160; Like always <a href="http://brianlagunas.com/downloads/source/WpfCodeInjection.zip">download the source</a> and start playing around.&#160; See what kind of cool stuff you can do with it.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yes you can write Inline Code in XAML</title>
		<link>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yes-you-can-write-inline-code-in-xaml</link>
		<comments>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 21:11:51 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/</guid>
		<description><![CDATA[A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete it?”.&#160; Obviously I replied yes, you absolutely can delete the code-behind file from a XAML file and the application will still work.&#160; Then they replied, “That’s cool I guess, but what about the code that needs to execute, such as event handlers?”.&#160; Naturally I brought up the fact that using MVVM you don’t use event handlers, but as most developers do, they said, “Well what if I really needed it?”.&#160; My reply to that question was, “If you really had to, it is possible to write inline code inside the XAML file”.</p>  <p>They looked at me in amazement, “Really?”.&#160; Apparently that is a little known fact about WPF.&#160; Yes, it is absolutely possible to write inline code inside a XAML page without the need for a code-behind file, and everything will work as expected.&#160; I quickly realized that his was going somewhere I didn’t want it to go.&#160; I knew what was coming next; they asked me to show them how to do it. Uggg…</p>  <p>Okay here is the deal; what I am about to show you is not recommended.&#160; It goes against everything I have been teaching in the community, but if you are curious how to actually do this, it is quit simple.</p>    <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ddf41891-b77a-41c9-89aa-aeb2944933da" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--Define the button content --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;133&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Name</span><span style="color:#0000ff">=&quot;btnExitApp&quot;</span><span style="color:#ff0000"> Click</span><span style="color:#0000ff">=&quot;btnExitApp_Clicked&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Exit Application&quot;/&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--The C# implementation of the button&#39;s Click event handler. --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>             <span style="color:#808080">private void btnExitApp_Clicked(object sender, RoutedEventArgs e)</span><br>             <span style="color:#808080">{</span><br>                 <span style="color:#808080">// Get a handle to the current app and shut it down.</span><br>                 <span style="color:#808080">Application.Current.Shutdown();</span><br>             <span style="color:#808080">}</span><br>         <span style="color:#808080">]]&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div>    <p>As you can see the code snippet above is pretty simple.&#160; You will notice that the Button has a EventHandler defined called “btnExitApp_Clicked”.&#160; Since there is no code-behind (I deleted it) you may be expecting a compile error that says it cannot find the definition for the EventHandler.&#160; But wait, we do have the event handler defined within the &lt;x:Code&gt;….&lt;/x:Code&gt; tags.</p>  <p>The &lt;x:Code&gt;….&lt;/x:Code&gt; is a directive element defined in XAML.&#160; An x:Code directive element can contain inline programming code. The code that is defined inline can interact with the XAML on the same page.&#160; Notice that the code is inside the x:Code element and that the code must be surrounded by &lt;CDATA[...]]&gt; to escape the contents for XML, so that a XAML processor (interpreting either the XAML schema or the WPF schema) will not try to interpret the contents literally as XML.</p>  <p>That is all there really is to it.&#160; There are some limitations to using inline code, for more information you can check out the <a href="http://msdn.microsoft.com/en-us/library/aa970568.aspx" target="_blank">MSDN documentation</a>.&#160; Now, I don’t want to see this in any production code.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Simple WPF Loading Animation</title>
		<link>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-wpf-loading-animation</link>
		<comments>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 03:47:21 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/</guid>
		<description><![CDATA[Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could save myself some time by just using theirs.&#160; Well, after almost an hour searching, I found nothing.&#160; So much for being a timesaver.&#160; Now, don’t get me wrong, I found a couple of WPF animations out there, but none of them really fit what I needed.&#160; So I just decided to bite the bullet and create my own.&#160; After creating the animation I decided to share the fruits of my labor so that anyone else who is looking for the same thing I was, or something similar, wouldn’t have as much trouble as I did.</p>  <p>Here is what it looks like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="loadingAnimation" border="0" alt="loadingAnimation" src="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation_thumb.jpg" width="114" height="114" /></a> </p>  <p>Here is the source: <a href="http://brianlagunas.com/downloads/source/LoadingControl.zip">Download the Loading Animation Source</a></p>  <p>I hope it is useful to someone besides me.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Debugging XAML</title>
		<link>http://elegantcode.com/2009/04/14/debugging-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-xaml</link>
		<comments>http://elegantcode.com/2009/04/14/debugging-xaml/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 01:43:01 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/04/14/debugging-xaml/</guid>
		<description><![CDATA[Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths. Lets say I have the following code snippet: &#60;StatusBar&#62; &#60;StatusBarItem&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths.</p>  <p>Lets say I have the following code snippet:</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">       <span style="color: #0000ff">&lt;</span><span style="color: #800000">TextBlock</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;{Binding Messssage}&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>
  </div>
</div>

<p></p>

<p>As you can see my property Message is totally misspelled.&#160; If I were to run this application nothing would ever appear in my status bar, and I would not know why.&#160; I didn’t get any compile errors, and my view renders perfectly in my designer, so what the hell is going on.&#160; You might spend hours looking at your object’s property, stepping through the property changed events, or just saying XAML is a piece of crap and I give up.&#160; Well never fear, I am about to reveal the secret to debugging your XAML.</p>

<p>Look in your Output Window!</p>

<p><a href="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow.jpg" target="_blank"><img title="OutputWindow" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="79" alt="OutputWindow" src="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow-thumb.jpg" width="404" border="0" /></a> </p>

<p>Yes, the nearly always forgotten Output Window.&#160; As you can see, if you click on the image above, it tells me that I have a binding expression path error and gives the line number where the error occurred.&#160; So don’t spend hours stepping through code looking for a ghost.&#160; Just check your Output Window.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/04/14/debugging-xaml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WPF String.Format in XAML with the StringFormat attribute</title>
		<link>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-an-address-with-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:21:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[In my last post Buy Tindamax Without Prescription, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate [...]]]></description>
			<content:encoded><![CDATA[<p> <p>In my last <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">post</a> <b>Buy Tindamax Without Prescription</b>, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate maps and imagery, driving directions, distance calculations, and other location intelligence into your applications, business processes, and Web sites. </p>  <p>Let’s start with the Geocode Service which is used to match addresses, <b>buy cheap Tindamax</b>, <b>Purchase Tindamax for sale</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>my Tindamax experience</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; We will create a simple application that allows you to enter an address and place a pushpin at that location.&#160; First thing is first:</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165" target="_blank">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/" target="_blank">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services.&#160; Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>order Tindamax from United States pharmacy</b>.  <b>Online buying Tindamax</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>buy Tindamax without a prescription</b>.  <b>After Tindamax</b>, </p>  <p>Open up your App.xaml.&#160; You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c7fbbfb-a6ac-496d-a298-bddbd655ac65" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>discount Tindamax</b>, <b>Buy Tindamax no prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Now create a very simple UI that will accept an address and a button to perform the geocoding:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc9a874e-765b-4bc2-b82b-88a96f1ef84c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax treatment</b>, <b>Tindamax no rx</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>                  <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>The next thing we need to do is add a new Service Reference to the project and point to the following service:</p>  <p><a title="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc" href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name (I called mine BingMapsService) and just for fun, <b>buy Tindamax online cod</b>, <b>Generic Tindamax</b>, in the “Add Service Reference” dialog, click the “Advanced” button and click “Generate asynchronous operations”.</p>  <p>Next we need to create a ViewModel to support our View.&#160; This is a WPF application after all.&#160; This ViewModel will need a command for the button that will perform the geocoding, <b>Tindamax duration</b>, <b>Low dose Tindamax</b>, and a property that will represent the result of the service that the UI will use to map the address.&#160; It should resemble something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b09cd91-31d1-426f-a539-9fe004a3702a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax street price</b>, <b>Tindamax blogs</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">GeocodeViewModel</span> : <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> GeocodeAddressCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> _geocodeResult;<br>     <span style="color:#0000ff">public</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GeocodeResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _geocodeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _geocodeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> GeocodeViewModel()<br>     {<br>         GeocodeAddressCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>&lt;<span style="color:#2b91af">String</span>&gt;(GeocodeAddress);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>I want to point out that the DelegateCommand&lt;T&gt; is a very simple ICommand implementation and should NOT be used in production applications.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cac2fd6-5f40-4d30-b70e-39cf0eb39d77" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax wiki</b>, <b>Tindamax cost</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span>&lt;T&gt; : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span>&lt;T&gt; _execute;<br> <br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span>&lt;T&gt; execute)<br>     {<br>         _execute = execute;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke((T)parameter);<br>     }<br> }</div> </div> </div>  <p>Let’s hook our UI up to our command.&#160; it should look something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f154da3-e1a9-48e1-8dcd-53063e2268ec" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax overnight</b>, <b>Online buy Tindamax without a prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;</span> <br>                    <span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeAddressCommand}</span><span style="color:#0000ff">&quot;</span><br>                    <span style="color:#ff0000"> CommandParameter</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">, <b>where can i buy Tindamax online</b>, <b>Discount Tindamax</b>, </span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=</span>_<span style="color:#0000ff">txtAddress}&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Notice that we are using the text of the TextBox as the CommandParameter.&#160; Next, we need to implement the command:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0d2006e3-d7cf-483a-b57b-284d06ecffff" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax for sale</b>, <b>Tindamax used for</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br> {<br>     <span style="color:#0000ff">using</span> (BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>     {<br>         client.GeocodeCompleted += (o, <b>buy no prescription Tindamax online</b>, <b>Tindamax online cod</b>, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Error == <span style="color:#0000ff">null</span>)<br>             {<br>                 GeocodeResult = e.Result.Results[0];<br>             }<br>         };<br> <br>         BingMapsService.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeRequest</span>();<br>         request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>         request.Query = address;<br>         client.GeocodeAsync(request);<br>     }<br> }</div> </div> </div>  <p>In this command we are simply creating an instance of the service client, creating a GeocodeRequest, <b>Tindamax coupon</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, setting the credentials using the ApplicationId we have stored in the App.xaml, and then using the address as the Query for the request.&#160; When the call to the service is completed we are setting the GeocodeResult property to the first element in the results.</p>  <p>Now the tricky part.&#160; We want to place a Pushpin on the address that was entered and then move the map to that location.&#160; We also need to make sure that when another address is entered, <b>buying Tindamax online over the counter</b>, <b>Is Tindamax safe</b>, we clear any previous Pushpins that may exist on the map.&#160; We also have to be aware that other elements my be on the map and we don’t want to accidentally alter those elements.&#160; Oh and did I mention this was an MVVM application and this has to be done with just data binding. </p>  <p>The approach that I decided to go with is to use <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" target="_blank">Attached Properties</a>.&#160; So I created two attached properties; one for the GeocodeResult and another for a MapLayer that will be dedicated to the GeocodeResult.&#160; This will allow us to create a MapLayer that is specific to our GeocodeResut and not alter any other elements that may be on the map.&#160; Let’s check out the code.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3cc3f4e4-cbae-4ffe-93bf-4a10f2e36d08" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>herbal Tindamax</b>, <b>Tindamax price, coupon</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> GeocodeResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>, <b>buy Tindamax without a prescription</b>, <b>Buy Tindamax without prescription</b>, <span style="color:#0000ff">typeof</span>(BingMapsService.<span style="color:#2b91af">GeocodeResult</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <b>cheap Tindamax</b>, <b>Tindamax trusted pharmacy reviews</b>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GetGeocodeResult(<span style="color:#2b91af">Map</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)target.GetValue(GeocodeResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResult(<span style="color:#2b91af">Map</span> target, <b>ordering Tindamax online</b>, <b>Tindamax canada, mexico, india</b>, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> value)<br>     {<br>         target.SetValue(GeocodeResultProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultChanged((<span style="color:#2b91af">Map</span>)o, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.OldValue, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">Map</span> map, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> oldValue, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">Location</span> location = newValue.Locations.Select(x =&gt; <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(x.Latitude, x.Longitude)).First();<br> <br>         <span style="color:#2b91af">Pushpin</span> pin = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Pushpin</span>();<br>         pin.Location = location;<br>         pin.ToolTip = newValue.Address.FormattedAddress;<br> <br>         <span style="color:#0000ff">var</span> locationLayer = GetGeocodeResultLayer(map);<br>         <span style="color:#0000ff">if</span> (locationLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             locationLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetGeocodeResultLayer(map, locationLayer);<br>         }<br> <br>         locationLayer.Children.Clear();<br>         locationLayer.Children.Add(pin);<br> <br>         map.SetView(location, map.ZoomLevel);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResult</span><br> <br>     <span style="color:#0000ff">#region</span> GeocodeResultLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResultLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(GeocodeResultLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(GeocodeResultLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResultLayer</span><br> }</div> </div> </div>  <p>Notice that when the GeocodeResult changes we get the Location and create a pushpin for that location.&#160; We also set the tooltip to the FormattedAddress of the GeocodeResult.&#160; So when we hover over the pushpin we will see a nice little tooltip of the address.&#160; Next we try to get the GeocodeResultLayer from the map, if it is null this means it doesn’t exist on the map yet so we create one and assign it accordingly.&#160; We clear the layer child elemnts and then add out pushpin.&#160; The last thing we do is call the SetView method of the Map control passing in the location and the current ZoomLevel.</p>  <p>The final step is to use our AttachedProperty on the map.&#160; Be sure to create a namespace for the MapInteractivity class and define it as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72d6307a-aef3-4f70-8d47-8d4529fc74e0" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>          <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.GeocodeResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeResult}</span><span style="color:#0000ff">&quot;</span><br>          <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>One last thing.&#160; Be sure to remember to set your DataContext of your View to the ViewModel we have created:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f7d0b4f-e096-487d-8343-fb42c94c3360" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> MainWindow()<br> {<br>     InitializeComponent();<br>     DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">GeocodeViewModel</span>(); <br> }</div> </div> </div>  <p>That’s it.&#160; You now have an application the can map (geocode) an address using the Bing Maps WPF Control and the Geocoding SOAP Service.&#160; Oh and we are doing this all with MVVM and data binding which is my favorite part.&#160; Be sure to <a href="http://www.brianlagunas.com/downloads/source/bingmapsgeocodedemo.zip">Download the Source</a> and start playing around.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4746'>Buy Clindamycin Gel Without Prescription</a>. <a href='http://elegantcode.com/?p=4328'>Buy Plavix Without Prescription</a>. <a href='http://elegantcode.com/?p=4302'>Buy Phenergan Without Prescription</a>. <a href='http://elegantcode.com/?p=4460'>Buy Proscar Without Prescription</a>. <a href='http://elegantcode.com/?p=4607'>Triamterene For Sale</a>. <a href='http://elegantcode.com/?p=4751'>Diflucan street price</a>. <a href='http://elegantcode.com/?p=4372'>Nexium steet value</a>. <a href='http://elegantcode.com/?p=4475'>Metronidazole Gel from mexico</a>. <a href='http://elegantcode.com/?p=4399'>Herbal Periactin</a>. <a href='http://elegantcode.com/?p=4858'>Tramadol over the counter</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.macneilbmx.com/blog/?p=6683'>Buy Tindamax Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=3313'>Buy Tindamax Without Prescription</a>. <a href='http://www.thegriffonnews.com/?p=9133'>Buy Tindamax Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5330'>Buy Tindamax Without Prescription</a>. <a href='http://changecamp.ca/?p=592'>Buy Tindamax Without Prescription</a>. <a href='http://social-blend.com/?p=444'>Tindamax online cod</a>. <a href='http://blog.farmland.org/?p=3958'>Order Tindamax from mexican pharmacy</a>. <a href='http://4realz.net/?p=717'>Tindamax forum</a>. <a href='http://reversemortgagedaily.com/?p=14265'>Tindamax trusted pharmacy reviews</a>. <a href='http://linuxologist.com/?p=1542'>Tindamax online cod</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; xaml</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Betnovate Without Prescription</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinWidth&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinWidth}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;MinHeight&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxMinHeight}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderThickness&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> InputControlBorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontFamily&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontFamily}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;FontSize&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ContentFontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.HorizontalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.VerticalScrollBarVisibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Hidden&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;ScrollViewer.ZoomMode&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Padding&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxPaddingThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButtonStyle&quot;</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;Button&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;/&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonHoverGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Pressed&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;&gt;</span><br>                                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonPressedGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;GlyphElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxButtonGlyphBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> FontFamily</span><span style="background:#ffffff;color:#0000ff">=&quot;Segoe UI Symbol&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;X&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Center&quot;/&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.Resources</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;*&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ColumnDefinition</span><span style="background:#ffffff;color:#ff0000"> Width</span><span style="background:#ffffff;color:#0000ff">=&quot;Auto&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid.ColumnDefinitions</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;CommonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Disabled&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Background&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledFillBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderBrush&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledBorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Foreground&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxDisabledTextBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Normal&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxRestBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PointerOver&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverFillOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;/&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DoubleAnimation</span><span style="background:#ffffff;color:#ff0000"> Duration</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;</span><span style="background:#ffffff;color:#ff0000"> To</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> TextBoxHoverBorderOpacity}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Opacity&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;/&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;Focused&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonStates&quot;&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonVisible&quot;&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ButtonCollapsed&quot;/&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateManager.VisualStateGroups</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Grid</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Let’s test what we have so far.&#160; Add an instance of our WatermarkTextBox control to the BlankPage.xaml.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5b472f91-aaa4-4de0-a251-52d2d2c82795" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Page</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Class</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTextBoxControl.BlankPage&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">x</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">local</span><span style="background:#ffffff;color:#0000ff">=&quot;using:WatermarkTextBoxControl&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">d</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.microsoft.com/expression/blend/2008&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> xmlns</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">mc</span><span style="background:#ffffff;color:#0000ff">=&quot;http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</span><br>    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> mc</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Ignorable</span><span style="background:#ffffff;color:#0000ff">=&quot;d&quot;&gt;</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Page</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image5.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb5.png" width="275" height="60" /></a></p>  <p>Looks great.&#160; Just like the default Windows TextBox.&#160; Now we need to start adding our Watermark elements to it.&#160; Obviously we need a property for our Watermark.&#160; Your first thought maybe to define it as a type of string, but I want to support any element, not just text, so I will define it as a type of Object.&#160; This will allow me to nest controls inside of the Watermark property instead of being restricted to a simple string.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:db082020-3ed1-4025-b979-4d938ab172a9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;Watermark&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> Watermark</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>I also want to define a DataTemplate that will be used to define the ContentTemplate for the Watermark.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd631c4b-41c5-442b-8fb7-9704ba9c139b" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">static</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000"> WatermarkTemplateProperty = </span><span style="background:#ffffff;color:#2b91af">DependencyProperty</span><span style="background:#ffffff;color:#000000">.Register(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#000000">, </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">), </span><span style="background:#ffffff;color:#0000ff">new</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">PropertyMetadata</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#0000ff">null</span><span style="background:#ffffff;color:#000000">));</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000"> WatermarkTemplate</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">get</span><span style="background:#ffffff;color:#000000"> { </span><span style="background:#ffffff;color:#0000ff">return</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">DataTemplate</span><span style="background:#ffffff;color:#000000">)GetValue(WatermarkTemplateProperty); }</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">set</span><span style="background:#ffffff;color:#000000"> { SetValue(WatermarkTemplateProperty, </span><span style="background:#ffffff;color:#0000ff">value</span><span style="background:#ffffff;color:#000000">); }</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Now we need to modify our control template to support our new Watermark property. We will do this by simply adding a ContentPresenter to our Template.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4431129a-2a62-4f39-abc1-6c7e0c47b874" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate price, coupon</b>, <b>Where to buy Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BackgroundElement&quot;</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;BorderElement&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.ColumnSpan</span><span style="background:#ffffff;color:#0000ff">=&quot;2&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ScrollViewer</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;ContentElement&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> HorizontalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.HorizontalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Padding</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollBarVisibility</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollBarVisibility}&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalScrollMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.VerticalScrollMode}&quot;</span><span style="background:#ffffff;color:#ff0000"> ZoomMode</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> ScrollViewer</span><span style="background:#ffffff;color:#0000ff">.ZoomMode}&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Button</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;DeleteButton&quot;</span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Grid.Column</span><span style="background:#ffffff;color:#0000ff">=&quot;1&quot;</span><span style="background:#ffffff;color:#ff0000"> FontSize</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> FontSize}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><span style="background:#ffffff;color:#ff0000"> Style</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DeleteButtonStyle}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;</span><span style="background:#ffffff;color:#ff0000"> VerticalAlignment</span><span style="background:#ffffff;color:#0000ff">=&quot;Stretch&quot;/&gt;</span></div> </div> </div>  <p>Oh, <b>effects of Betnovate</b>, <b>Is Betnovate safe</b>, and don’t forget the ContentTemplate that will define the default look for our watermark.&#160; This is placed at the top of the Generic.xaml.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:baa07ca8-8bac-40b7-aece-36f27dedd0e5" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>purchase Betnovate online no prescription</b>, <b>Online buy Betnovate without a prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Key</span><span style="background:#ffffff;color:#0000ff">=&quot;DefaultWatermarkTemplate&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentControl</span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">Binding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#ff0000"> Foreground</span><span style="background:#ffffff;color:#0000ff">=&quot;Gray&quot;</span><span style="background:#ffffff;color:#ff0000"> IsTabStop</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DataTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>And we need to set the default value in a style setter.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e7175292-1fca-49aa-85ae-7ff859ab8ec2" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Buy Betnovate online cod</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkTemplate&quot;</span><span style="background:#ffffff;color:#ff0000"> Value</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> DefaultWatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot; /&gt;</span></div> </div> </div>    <p>As you can see, I placed the ComtentPresenter after the ContentElement and before the DeleteButton elements.&#160; You may have also noticed that I set the visibility to Collapsed.&#160; This is because by default I want the Watermark hidden.&#160; So that means we need to add some code to show the watermark when the text box has no focus and it has no text.&#160; First we need to add some visual states to the VisualStateManager.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b482c41e-77da-4f54-ad99-4493ac8b1f73" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from canada</b>, <b>Betnovate without prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkStates&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkVisible&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetProperty</span><span style="background:#ffffff;color:#0000ff">=&quot;Visibility&quot;</span><span style="background:#ffffff;color:#ff0000"> Storyboard.TargetName</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#ff0000"> KeyTime</span><span style="background:#ffffff;color:#0000ff">=&quot;0&quot;&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><span style="background:#ffffff;color:#000000">Visible</span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Visibility</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">DiscreteObjectKeyFrame</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ObjectAnimationUsingKeyFrames</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Storyboard</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">VisualState</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;WatermarkCollapsed&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">VisualStateGroup</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>Next we need to add some code to handle the GotFocus and LostFocus events of the TextBox.&#160; Start by adding event handlers for the events in the constructor.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e05e8b51-c571-48bc-9ee7-10b58950f385" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy Betnovate from mexico</b>, <b>Japan, craiglist, ebay, overseas, paypal</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.GotFocus += WatermarkTextBox_GotFocus;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.LostFocus += WatermarkTextBox_LostFocus;</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>Now add the code that does the heavy lifting.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:367568eb-5f40-4e4a-9861-50bab0c05329" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate brand name</b>, <b>Purchase Betnovate</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_GotFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, <b>where can i buy cheapest Betnovate online</b>, <b>Canada, mexico, india</b>, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState();</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox_LostFocus(</span><span style="background:#ffffff;color:#0000ff">object</span><span style="background:#ffffff;color:#000000"> sender, </span><span style="background:#ffffff;color:#2b91af">RoutedEventArgs</span><span style="background:#ffffff;color:#000000"> e)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> hasFocus = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//if our text is empty and our control doesn&#39;t have focus then show the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//otherwise the control eirther has text or has focus which in either case we need to hide the watermark</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">if</span><span style="background:#ffffff;color:#000000"> (</span><span style="background:#ffffff;color:#2b91af">String</span><span style="background:#ffffff;color:#000000">.IsNullOrEmpty(Text) &amp;&amp; !hasFocus)</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkVisible&quot;</span><span style="background:#ffffff;color:#000000">); </span><span style="background:#ffffff;color:#008000">//TODO: create constants for our magic strings</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">else</span><br>         <span style="background:#ffffff;color:#000000">GoToVisualState(</span><span style="background:#ffffff;color:#800000">&quot;WatermarkCollapsed&quot;</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span><br> <br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">private</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> GoToVisualState(</span><span style="background:#ffffff;color:#0000ff">string</span><span style="background:#ffffff;color:#000000"> stateName, <b>herbal Betnovate</b>, <b>Taking Betnovate</b>, </span><span style="background:#ffffff;color:#0000ff">bool</span><span style="background:#ffffff;color:#000000"> useTransitions = </span><span style="background:#ffffff;color:#0000ff">true</span><span style="background:#ffffff;color:#000000">)</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#2b91af">VisualStateManager</span><span style="background:#ffffff;color:#000000">.GoToState(</span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">, stateName, <b>rx free Betnovate</b>, <b>Order Betnovate online c.o.d</b>, useTransitions);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>One last thing is to make sure we set the visual state when the template is applied.&#160; So override the OnApplyTemplate method as follows.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d36c00a9-70e0-4692-9b7c-92d0a6de7deb" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Betnovate schedule</b>, <b>Betnovate dosage</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">protected</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">override</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">void</span><span style="background:#ffffff;color:#000000"> OnApplyTemplate()</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">base</span><span style="background:#ffffff;color:#000000">.OnApplyTemplate();</span><br> <br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#008000">//we need to set the initial state of the watermark</span><br>     <span style="background:#ffffff;color:#000000">GoToWatermarkVisualState(</span><span style="background:#ffffff;color:#0000ff">false</span><span style="background:#ffffff;color:#000000">);</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>    <p>That should do it.&#160; Now let check it out in action. Be sure to provide a watermark for our control.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0630f9fd-701c-4d59-bcdb-4c659a352180" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Betnovate cost</b>, <b>Betnovate no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">StaticResource</span><span style="background:#ffffff;color:#ff0000"> ApplicationPageBackgroundBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#ff0000"> Watermark</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot; /&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image6.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb6.png" width="279" height="60" /></a></p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image7.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb7.png" width="279" height="63" /></a></p>  <h4>Yes, <b>Betnovate from mexico</b>, <b>Betnovate description</b>, we found a bug</h4>  <p>Everything seems to be working perfectly.&#160; Until you actually try to use a watermark that isn’t text.&#160; Try using this as your watermark.</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:31c7fdd2-45ff-4ca5-86cb-5fe1adc8c10e" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>online buying Betnovate</b>, <b>Betnovate pics</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#ff0000"> Orientation</span><span style="background:#ffffff;color:#0000ff">=&quot;Horizontal&quot;&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Image</span><span style="background:#ffffff;color:#ff0000"> Source</span><span style="background:#ffffff;color:#0000ff">=&quot;Images/PencilTool16.png&quot;</span><span style="background:#ffffff;color:#ff0000"> Stretch</span><span style="background:#ffffff;color:#0000ff">=&quot;None&quot;</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff"> /&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">TextBlock</span><span style="background:#ffffff;color:#ff0000"> Text</span><span style="background:#ffffff;color:#0000ff">=&quot;Edit Text&quot;</span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;4,0, <b>Betnovate interactions</b>, <b>Get Betnovate</b>, 0,0&quot; /&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">StackPanel</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox.Watermark</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">local</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#a31515">WatermarkTextBox</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>    <p>Now let’s see our results.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image8.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb8.png" width="275" height="60" /></a></p>  <p>Hey!&#160; Where is my watermark?&#160; Well there appears to be a bug with a ContentPresenter/ContentControl that will not display content when the ContentTemplate has been set and the Content is anything else except a string.&#160; This just so happens to be the exact same bug that exists in Silverlight.&#160; Interesting I know.&#160; So how do we fix it?&#160; We have to delete the usage of our Watermarktemplate until this gets fixed.</p>  <p>Change:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:715e6953-8e22-4e2e-8b8f-a4700760cfa9" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>real brand Betnovate online</b>, <b>Betnovate steet value</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> ContentTemplate</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> WatermarkTemplate}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>To:</p>    <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6f626a1e-1d1c-489a-96cb-7f056392a0a8" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>my Betnovate experience</b>, <b>Betnovate wiki</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ContentPresenter</span><span style="background:#ffffff;color:#ff0000"> x</span><span style="background:#ffffff;color:#0000ff">:</span><span style="background:#ffffff;color:#ff0000">Name</span><span style="background:#ffffff;color:#0000ff">=&quot;PART_Watermark&quot;</span><span style="background:#ffffff;color:#000000"> </span><br>               <span style="background:#ffffff;color:#000000">                                         </span><span style="background:#ffffff;color:#ff0000"> Content</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Watermark}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><span style="background:#ffffff;color:#000000"></span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> IsHitTestVisible</span><span style="background:#ffffff;color:#0000ff">=&quot;False&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Margin</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Padding}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                  <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Visibility</span><span style="background:#ffffff;color:#0000ff">=&quot;Collapsed&quot;/&gt;</span></div> </div> </div>    <p>Now let’s see what happens.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image9.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb9.png" width="276" height="59" /></a></p>  <p>Now that’s much better.&#160; Let’s hope this is just a beta bug.</p>  <p><a href="http://brianlagunas.com/downloads/source/WatermarkTextBoxControl.zip" target="_blank">Download the source</a></p>, <b>low dose Betnovate</b>.  Order Betnovate from mexican pharmacy.  Online Betnovate without a prescription.  Betnovate long term.  Betnovate photos.  Betnovate samples.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4354'>Glucophage For Sale</a>. <a href='http://elegantcode.com/?p=4681'>Betnovate For Sale</a>. <a href='http://elegantcode.com/?p=4291'>Buy Vibramycin Without Prescription</a>. <a href='http://elegantcode.com/?p=4268'>Soma For Sale</a>. <a href='http://elegantcode.com/?p=4276'>Buy Viagra Without Prescription</a>. <a href='http://elegantcode.com/?p=4831'>Buying Glucophage online over the counter</a>. <a href='http://elegantcode.com/?p=4846'>Effects of Ketoconazole Cream</a>. <a href='http://elegantcode.com/?p=5014'>Order Quinine online overnight delivery no prescription</a>. <a href='http://elegantcode.com/?p=4232'>Japan, craiglist, ebay, overseas, paypal</a>. <a href='http://elegantcode.com/?p=4867'>Ordering Soma online</a>.<br />
<b>Trackbacks from:</b> <a href='http://home.officesnapshots.com/?p=250'>Buy Betnovate Without Prescription</a>. <a href='http://reversemortgagedaily.com/?p=14063'>Buy Betnovate Without Prescription</a>. <a href='http://social-blend.com/?p=1202'>Buy Betnovate Without Prescription</a>. <a href='http://www.quarterlives.com/?p=454'>Buy Betnovate Without Prescription</a>. <a href='http://4realz.net/?p=758'>Buy Betnovate Without Prescription</a>. <a href='http://blog.farmland.org/?p=3440'>Betnovate dosage</a>. <a href='http://linuxologist.com/?p=129'>Betnovate price, coupon</a>. <a href='http://www.themusclecarplace.com/?p=3456'>Betnovate no rx</a>. <a href='http://www.thegriffonnews.com/?p=10192'>Betnovate use</a>. <a href='http://www.greatgreengoods.com/?p=3270'>Kjøpe Betnovate på nett, köpa Betnovate online</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vermox For Sale</title>
		<link>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 16:51:29 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[So far we have built an earthquake application Vermox For Sale, , mapped an address using geocoding, and even Prism-fied the Bing Maps WPF control.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can [...]]]></description>
			<content:encoded><![CDATA[<p> <p>So far we have built an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earthquake application</a> <b>Vermox For Sale</b>, , <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">mapped an address</a> using geocoding, and even <a href="http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/" target="_blank">Prism-fied the Bing Maps WPF control</a>.&#160; Now let’s see how to map a route with turn-by-turn directions.&#160; By now it should be no surprise that you will need to complete the following steps before you can create this application.</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services. </p>  <p>For this application we will be using the Geocode Service and the Route Service.&#160; The Geocode service is used to match addresses, <b>Vermox dangers</b>, <b>Vermox coupon</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>Vermox dose</b>, <b>Vermox dosage</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; The Route service is used to generate routes and driving directions based on locations or waypoints.</p>  <p>Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>Vermox pharmacy</b>.  <b>Cheap Vermox</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>ordering Vermox online</b>.  <b>Vermox from mexico</b>, </p>  <p>Open up your App.xaml. You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ca628505-dd3b-4d33-ae53-ad0ea17f81a9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>buy no prescription Vermox online</b>, <b>Buying Vermox online over the counter</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>We need to add the Geocode and Route service to our application.&#160; First, <b>where can i buy cheapest Vermox online</b>, <b>Low dose Vermox</b>, let’s start by adding the Geocode service.&#160; Right click the project and select “Add Service Reference”.&#160; Use the following address:</p>  <p><a href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name. I called mine BingServices.&#160; Now we need to add the Route service, <b>Vermox steet value</b>, <b>No prescription Vermox online</b>, but we don’t want to add a separate service reference.&#160; Ideally we would have a single service that contained both the Geocode and Route services.&#160; Luckily there is a trick we can use to do just that.&#160; Select the Project and click the “Show All Files” button at the top of the Solution Explorer.&#160; Expand the Service Reference folder and then expand the BingServices service.&#160; Look for a file called <strong>Reference.svcmap</strong>. Open the References.svcmap and locate the MetadataSource node.&#160; It will loko something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1e1e98d3-82a4-419a-a32f-707e0559123c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox duration</b>, <b>Order Vermox online overnight delivery no prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Simply add a new MetatdataSource as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7291104c-336c-4f44-9a3e-5843babcba3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Vermox schedule</b>, <b>Where can i buy Vermox online</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">1</span>&quot;<span style="color:#0000ff"> /&gt;</span><br>   <span style="color:#0000ff">&lt;</span><span style="color:#a31515">MetadataSource</span><span style="color:#0000ff"> </span><span style="color:#ff0000">Address</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">Protocol</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">mex</span>&quot;<span style="color:#0000ff"> </span><span style="color:#ff0000">SourceId</span><span style="color:#0000ff">=</span>&quot;<span style="color:#0000ff">2</span>&quot;<span style="color:#0000ff"> /&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">MetadataSources</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see we added a new MetadataSource that points to the Route service and we gave it a SourceId of 2.&#160; Now right click the service and select “Update Service Reference”.&#160; This will generate a single service proxy for both the Geocode and Route services.&#160; Pretty slick huh?</p>  <p>The next step will be to create a ViewModel that will contain an ICommand that will execute the route calculation, <b>Vermox long term</b>, <b>Vermox price</b>, properties that will represent a “To” address and a “From” address.&#160; We will also need a property for the RouteResult and for the directions we generate.&#160; Lets first create our Direction object:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0230a924-5d25-4bed-880a-8b8cca1043e9" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox samples</b>, <b>After Vermox</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">Direction</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Description { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">Location</span> Location { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> }</div> </div> </div>  <p>Now we will need a make-shift delegate command (do not use in production code):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:424be6fd-5bed-4501-ac25-33db908058c2" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>doses Vermox work</b>, <b>Is Vermox safe</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span> : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span> _execute;<br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span> execute)<br>     {<br>         _execute = execute;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke();<br>     }<br> }</div> </div> </div>  <p>Now on to the ViewModel itself:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:d9737cbe-bea9-4b93-af31-534d3ad53cb1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Vermox pics</b>, <b>Vermox pictures</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">RouteViewModel</span>: <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> CalculateRouteCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _from = <span style="color:#a31515">&quot;Meridian, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> From<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _from; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _from = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;From&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">string</span> _to = <span style="color:#a31515">&quot;Boise, <b>Vermox used for</b>, <b>Online buy Vermox without a prescription</b>, ID&quot;</span>;<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> To<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _to; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _to = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;To&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">RouteResult</span> _routeResult;<br>     <span style="color:#0000ff">public</span> BingServices.<span style="color:#2b91af">RouteResult</span> RouteResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _routeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _routeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;RouteResult&quot;</span>);<br>         }<br>     }<br>     <br> <br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; _directions;<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt; Directions<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _directions; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _directions = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;Directions&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> RouteViewModel()<br>     {<br>         CalculateRouteCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>(CalculateRoute);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute()<br>     {<br>         <span style="color:#0000ff">var</span> from = GeocodeAddress(From);<br>         <span style="color:#0000ff">var</span> to = GeocodeAddress(To);<br> <br>         CalculateRoute(from, to);<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">GeocodeResult</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br>         BingServices.<span style="color:#2b91af">GeocodeResult</span> result = <span style="color:#0000ff">null</span>;<br> <br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">GeocodeRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Query = address;<br>             result = client.Geocode(request).Results[0];<br>         }<br> <br>         <span style="color:#0000ff">return</span> result;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> CalculateRoute(BingServices.<span style="color:#2b91af">GeocodeResult</span> from, <b>online buying Vermox hcl</b>, <b>Vermox reviews</b>, BingServices.<span style="color:#2b91af">GeocodeResult</span> to)<br>     {<br>         <span style="color:#0000ff">using</span> (BingServices.<span style="color:#2b91af">RouteServiceClient</span> client = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IRouteService&quot;</span>))<br>         {<br>             BingServices.<span style="color:#2b91af">RouteRequest</span> request = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteRequest</span>();<br>             request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>             request.Waypoints = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;BingServices.<span style="color:#2b91af">Waypoint</span>&gt;();<br>             request.Waypoints.Add(ConvertResultToWayPoint(from));<br>             request.Waypoints.Add(ConvertResultToWayPoint(to));<br> <br>             request.Options = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">RouteOptions</span>();<br>             request.Options.RoutePathType = BingServices.<span style="color:#2b91af">RoutePathType</span>.Points;<br> <br>             RouteResult = client.CalculateRoute(request).Result;<br>         }<br> <br>         GetDirections();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GetDirections()<br>     {<br>         Directions = <span style="color:#0000ff">new</span> <span style="color:#2b91af">ObservableCollection</span>&lt;<span style="color:#2b91af">Direction</span>&gt;();<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">ItineraryItem</span> item <span style="color:#0000ff">in</span> RouteResult.Legs[0].Itinerary)<br>         {<br>             <span style="color:#0000ff">var</span> direction = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Direction</span>();<br>             direction.Description = GetDirectionText(item);<br>             direction.Location = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(item.Location.Latitude, item.Location.Longitude);<br>             Directions.Add(direction);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">string</span> GetDirectionText(BingServices.<span style="color:#2b91af">ItineraryItem</span> item)<br>     {<br>         <span style="color:#0000ff">string</span> contentString = item.Text;<br>         <span style="color:#008000">//Remove tags from the string</span><br>         <span style="color:#2b91af">Regex</span> regex = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Regex</span>(<span style="color:#a31515">&quot;&lt;(.|&#92;n)*?&gt;&quot;</span>);<br>         contentString = regex.Replace(contentString, <b>purchase Vermox for sale</b>, <b>Vermox results</b>, <span style="color:#0000ff">string</span>.Empty);<br>         <span style="color:#0000ff">return</span> contentString;<br>     }<br> <br>     <span style="color:#0000ff">private</span> BingServices.<span style="color:#2b91af">Waypoint</span> ConvertResultToWayPoint(BingServices.<span style="color:#2b91af">GeocodeResult</span> result)<br>     {<br>         BingServices.<span style="color:#2b91af">Waypoint</span> waypoint = <span style="color:#0000ff">new</span> BingServices.<span style="color:#2b91af">Waypoint</span>();<br>         waypoint.Description = result.DisplayName;<br>         waypoint.Location = result.Locations[0];<br>         <span style="color:#0000ff">return</span> waypoint;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>Let’s walk though the CalculateRoute Method.&#160; First we geocode the “From” and “To” properties the same way we did in the <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">geocoding post</a>.&#160; Once we have our From and To locations we use those results to generate a RouteRequest and send that request to the Route service.&#160; The service will generate a result and we set our RouteResult property accordingly.&#160; This property will be used in data binding shortly.&#160; Next we generate an ObservableCollection&lt;Direction&gt; by looping through all the ItineraryItems in the result.&#160; </p>  <p>Now that we have generate all of our data, <b>online buying Vermox</b>, <b>Vermox forum</b>, we need to create a View that supports and displays this data, but before we do that we need to create some attached properties.&#160; Why do you ask?&#160; Well because as it stands, <b>Vermox online cod</b>, <b>Vermox no prescription</b>, the Bing Maps WPF control is not data binding friendly.&#160; So we need to enable data binding with the use of attached properties.&#160; We will need an attached property for the Route result which will be responsible for drawing the route line on the map.&#160; We will also need one for the MapLayer that will be used to contain the route line.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55925f26-554d-4793-8b07-532984d855c6" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>order Vermox from United States pharmacy</b>, <b>Vermox australia, uk, us, usa</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> RouteResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteResult&quot;</span>, <span style="color:#0000ff">typeof</span>(BingServices.<span style="color:#2b91af">RouteResult</span>), <b>Vermox gel, ointment, cream, pill, spray, continuous-release, extended-release</b>, <b>Vermox overnight</b>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingServices.<span style="color:#2b91af">RouteResult</span> GetRouteResult(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingServices.<span style="color:#2b91af">RouteResult</span>)target.GetValue(RouteResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteResult(<span style="color:#2b91af">DependencyObject</span> target, BingServices.<span style="color:#2b91af">RouteResult</span> value)<br>     {<br>         target.SetValue(RouteResultProperty, value);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteResultChanged((<span style="color:#2b91af">Map</span>)o, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.OldValue, (BingServices.<span style="color:#2b91af">RouteResult</span>)e.NewValue);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteResultChanged(<span style="color:#2b91af">Map</span> map, BingServices.<span style="color:#2b91af">RouteResult</span> oldValue, BingServices.<span style="color:#2b91af">RouteResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">MapPolyline</span> routeLine = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapPolyline</span>();<br>         routeLine.Locations = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationCollection</span>();<br>         routeLine.Opacity = 0.65;<br>         routeLine.Stroke = <span style="color:#0000ff">new</span> <span style="color:#2b91af">SolidColorBrush</span>(<span style="color:#2b91af">Colors</span>.Blue);<br>         routeLine.StrokeThickness = 5.0;<br> <br>         <span style="color:#0000ff">foreach</span> (BingServices.<span style="color:#2b91af">Location</span> loc <span style="color:#0000ff">in</span> newValue.RoutePath.Points)<br>         {<br>             routeLine.Locations.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(loc.Latitude, loc.Longitude));<br>         }<br> <br>         <span style="color:#0000ff">var</span> routeLineLayer = GetRouteLineLayer(map);<br>         <span style="color:#0000ff">if</span> (routeLineLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             routeLineLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetRouteLineLayer(map, routeLineLayer);<br>         }<br> <br>         routeLineLayer.Children.Clear();<br>         routeLineLayer.Children.Add(routeLine);<br> <br>         <span style="color:#008000">//Set the map view</span><br>         <span style="color:#2b91af">LocationRect</span> rect = <span style="color:#0000ff">new</span> <span style="color:#2b91af">LocationRect</span>(routeLine.Locations[0], routeLine.Locations[routeLine.Locations.Count - 1]);<br>         map.SetView(rect);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteResult</span><br> <br>     <span style="color:#0000ff">#region</span> RouteLineLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> RouteLineLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;RouteLineLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnRouteLineLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(RouteLineLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetRouteLineLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(RouteLineLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnRouteLineLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnRouteLineLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         <span style="color:#0000ff">if</span> (!map.Children.Contains(newValue))<br>             map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//RouteLineLayer</span><br> }</div> </div> </div>  <p>The RouteResult property simply creates a MapPolyline, loops through all the points in the result and adds the locations to the route line.&#160; It then gets the RouteLineLayer and adds it to the map.&#160; Lastly, it sets the map’s view to best fit the route line.</p>  <p>Now we are ready for the View:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:393d6882-6c78-48e8-9046-d517df235427" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsCalculateRouteDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">core</span><span style="color:#0000ff">=&quot;clr-namespace:BingMapsCalculateRouteDemo.Core&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">DataTemplate</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;RouteTemplate&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Ellipse</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> Fill</span><span style="color:#0000ff">=&quot;Red&quot;</span><span style="color:#ff0000"> Opacity</span><span style="color:#0000ff">=&quot;0.8&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.Position</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Location}</span><span style="color:#0000ff">&quot;</span> <br>                     <span style="color:#ff0000"> bing</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapLayer.PositionOrigin</span><span style="color:#0000ff">=&quot;Center&quot;</span><br>                     <span style="color:#ff0000"> Tag</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding}</span><span style="color:#0000ff">&quot;</span><br>                     <span style="color:#ff0000"> MouseEnter</span><span style="color:#0000ff">=&quot;Route_MouseEnter&quot;</span> <br>                     <span style="color:#ff0000"> MouseLeave</span><span style="color:#0000ff">=&quot;Route_MouseLeave&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">DataTemplate</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window.Resources</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">ColumnDefinition</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.ColumnDefinitions</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;150&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> From}</span><span style="color:#0000ff">&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> To}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Get Route&quot;</span><span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> CalculateRouteCommand}</span><span style="color:#0000ff">&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Column</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> Mode</span><span style="color:#0000ff">=&quot;AerialWithLabels&quot;</span><span style="color:#ff0000"> HorizontalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> VerticalAlignment</span><span style="color:#0000ff">=&quot;Stretch&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> RouteResult}</span><span style="color:#0000ff">&quot;</span><br>                  <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.RouteLineLayer</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> ElementName</span><span style="color:#0000ff">=RouteLineLayer}&quot;</span><br>                  <span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot; &gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;RouteLineLayer&quot; /&gt;</span><br>             <span style="color:#a31515"></span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapItemsControl</span><span style="color:#ff0000"> ItemsSource</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Directions}</span><span style="color:#0000ff">&quot;</span><br>                                      <span style="color:#ff0000"> ItemTemplate</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> RouteTemplate}</span><span style="color:#0000ff">&quot;/&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br> <br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupLayer&quot;&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopup&quot;</span><span style="color:#ff0000"> Visibility</span><span style="color:#0000ff">=&quot;Collapsed&quot;</span><span style="color:#ff0000"> Background</span><span style="color:#0000ff">=&quot;White&quot;&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;15&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBlock</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;ContentPopupText&quot;</span><span style="color:#ff0000"> FontSize</span><span style="color:#0000ff">=&quot;12&quot;</span><span style="color:#ff0000"> FontWeight</span><span style="color:#0000ff">=&quot;Bold&quot;</span><span style="color:#ff0000"> TextWrapping</span><span style="color:#0000ff">=&quot;Wrap&quot; /&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">MapLayer</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Oh and don’t forget the code behind:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:14f2277a-a347-48e8-afd6-41465898d7fe" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">partial</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MainWindow</span> : <span style="color:#2b91af">Window</span><br> {<br>     <span style="color:#0000ff">public</span> MainWindow()<br>     {<br>         InitializeComponent();<br>         DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">RouteViewModel</span>();<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseEnter(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         <span style="color:#2b91af">FrameworkElement</span> pin = sender <span style="color:#0000ff">as</span> <span style="color:#2b91af">FrameworkElement</span>;<br>         <span style="color:#2b91af">MapLayer</span>.SetPosition(ContentPopup, <span style="color:#2b91af">MapLayer</span>.GetPosition(pin));<br>         <span style="color:#2b91af">MapLayer</span>.SetPositionOffset(ContentPopup, <span style="color:#0000ff">new</span> <span style="color:#2b91af">Point</span>(20, -15));<br> <br>         <span style="color:#0000ff">var</span> location = (<span style="color:#2b91af">Direction</span>)pin.Tag;<br> <br>         ContentPopupText.Text = location.Description;<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Visible;<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> Route_MouseLeave(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">MouseEventArgs</span> e)<br>     {<br>         ContentPopup.Visibility = <span style="color:#2b91af">Visibility</span>.Collapsed;<br>     }<br> }</div> </div> </div>  <p>Now let’s view the fruits of our labor at runtime.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/09/image.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/09/image_thumb.png" width="644" height="453" /></a></p>  <p>As you can see, given a “From” and “To” address, we can draw a route line and provide turn-by-turn directions as the user hovers over the direction pins.&#160; Pretty neat huh?&#160; And it wasn’t too difficult to pull off.&#160; As always you can <a href="http://www.brianlagunas.com/downloads/source/BingMapsCalculateRouteDemo.zip">Download the Source</a> and start playing.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4306'>Buy Biaxin Without Prescription</a>. <a href='http://elegantcode.com/?p=4228'>Aricept For Sale</a>. <a href='http://elegantcode.com/?p=4340'>Atarax For Sale</a>. <a href='http://elegantcode.com/?p=5052'>Lotrisone For Sale</a>. <a href='http://elegantcode.com/?p=4407'>Buy Nexium Without Prescription</a>. <a href='http://elegantcode.com/?p=4873'>Cafergot treatment</a>. <a href='http://elegantcode.com/?p=4780'>Canada, mexico, india</a>. <a href='http://elegantcode.com/?p=4202'>Online buying Celexa</a>. <a href='http://elegantcode.com/?p=4335'>Fast shipping Differin</a>. <a href='http://elegantcode.com/?p=4205'>Purchase Allopurinol online no prescription</a>.<br />
<b>Trackbacks from:</b> <a href='http://linuxologist.com/?p=193'>Vermox For Sale</a>. <a href='http://blog.farmland.org/?p=3110'>Vermox For Sale</a>. <a href='http://home.officesnapshots.com/?p=122'>Vermox For Sale</a>. <a href='http://reversemortgagedaily.com/?p=14171'>Vermox For Sale</a>. <a href='http://social-blend.com/?p=495'>Vermox For Sale</a>. <a href='http://www.themusclecarplace.com/?p=3175'>Vermox for sale</a>. <a href='http://www.thegriffonnews.com/?p=10415'>Ordering Vermox online</a>. <a href='http://www.quarterlives.com/?p=743'>Order Vermox online c.o.d</a>. <a href='http://tayloegray.com/?p=351'>Vermox from mexico</a>. <a href='http://www.greatgreengoods.com/?p=3949'>Purchase Vermox for sale</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/09/09/mapping-a-route-with-directions-using-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buy Female Pink Viagra Without Prescription</title>
		<link>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=prism-fy-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 16:13:02 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Prism]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[prism]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been playing around with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled [...]]]></description>
			<content:encoded><![CDATA[<p> <p>If you know me or know of me you are aware that I am a big Prism advocate/evangelist.&#160; You may have also noticed that I have been <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">playing</a> <a href="http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/" target="_blank">around</a> with the new Bing Maps WPF control.&#160; So it shouldn’t surprise you that I would find a way to compose a Bing Map of loosely coupled MapLayers at runtime using Prism.</p>  <p> <b>Buy Female Pink Viagra Without Prescription</b>, The concept is simple.&#160; We want a Bing Maps application that can be extended at runtime.&#160; By extended, I mean that I want the ability to add new elements/modules to the Map at runtime.&#160; The important thing about these elements/modules is that they can come from anywhere and they should be loosely coupled from the Map as well as other elements/modules that may exist on the Map.</p>  <p>Luckily for us this is extremely simple to accomplish.&#160; All we have to do is create a custom RegionAdapter, register it with our Prism application, and then apply it to our Bing Map control.&#160; So let’s start with the RegionAdapter.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e8809704-1b89-4479-9f50-32a29a8ce6e3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapRegionAdapter</span> : <span style="color:#2b91af">RegionAdapterBase</span>&lt;<span style="color:#2b91af">Map</span>&gt;<br> {<br>     <span style="color:#0000ff">public</span> MapRegionAdapter(<span style="color:#2b91af">IRegionBehaviorFactory</span> regionBehaviorFactory)<br>         : <span style="color:#0000ff">base</span>(regionBehaviorFactory)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#0000ff">void</span> Adapt(<span style="color:#2b91af">IRegion</span> region, <span style="color:#2b91af">Map</span> regionTarget)<br>     {<br>         region.Views.CollectionChanged += (s, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Add)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.NewItems)<br>                     regionTarget.Children.Add(element);<br>             }<br>             <span style="color:#0000ff">else</span> <span style="color:#0000ff">if</span> (e.Action == System.Collections.Specialized.<span style="color:#2b91af">NotifyCollectionChangedAction</span>.Remove)<br>             {<br>                 <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">FrameworkElement</span> element <span style="color:#0000ff">in</span> e.OldItems)<br>                     <span style="color:#0000ff">if</span> (regionTarget.Children.Contains(element))<br>                         regionTarget.Children.Remove(element);<br>             }<br>         };<br>     }<br> <br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">IRegion</span> CreateRegion()<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">AllActiveRegion</span>();<br>     }<br> }</div> </div> </div> </p>  <p>Now in the Bootstrapper we need to register our mapping.</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fce11974-ec82-4641-ac5c-a37a9ff443df" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">protected</span> <span style="color:#0000ff">override</span> <span style="color:#2b91af">RegionAdapterMappings</span> ConfigureRegionAdapterMappings()<br> {<br>     <span style="color:#2b91af">RegionAdapterMappings</span> mappings = <span style="color:#0000ff">base</span>.ConfigureRegionAdapterMappings();<br>     mappings.RegisterMapping(<span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">Map</span>), Container.Resolve&lt;<span style="color:#2b91af">MapRegionAdapter</span>&gt;());<br>     <span style="color:#0000ff">return</span> mappings;<br> }</div> </div> </div> </p>  <p>Now we simply give the Map a region name. (this is actually all the shell has in it)</p>  <p>   <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a72303d9-120c-4bba-a39e-18ae1979a63a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>online Female Pink Viagra without a prescription</b>, <b>Female Pink Viagra forum</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> prism</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionManager.RegionName</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Static</span><span style="color:#ff0000"> inf</span><span style="color:#0000ff">:</span><span style="color:#ff0000">RegionNames</span><span style="color:#0000ff">.MapRegion}&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40, <b>order Female Pink Viagra online overnight delivery no prescription</b>, <b>Low dose Female Pink Viagra</b>, -95&quot;</span><span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot; /&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div> </p>  <p>That is all there is to it.&#160; You can now start injecting modules onto the Map at runtime.&#160; Lets look at my two modules I am using as an example.&#160; Here is the structure of my application:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image12.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb13.png" width="305" height="190" /></a></p>  <ul>   <li>ModuleA will inject a MapPolygon in the Shape of Texas.</li>    <li>ModuleB is the Earthquake application we built in an <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">earlier post</a>.</li>    <li>Infrastructure is the project where shared code goes, in this case our MapRegionAdapter</li>    <li>BingMapsPrismfiedDemo is of course our shell project.</li> </ul>  <p>This is what the application looks like at runtime when both modules have been injected into it.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2011/08/image13.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2011/08/image_thumb14.png" width="644" height="334" /></a></p>  <p>Now I can easily add more layers to this map as I see fit.&#160; As always, <b>online buy Female Pink Viagra without a prescription</b>, <b>No prescription Female Pink Viagra online</b>, <a href="http://www.brianlagunas.com/downloads/source/BingMapsPrismfiedDemo.zip">Download the Source</a> and start playing.&#160; You may want to add MEF support as well.</p>.  Where can i find Female Pink Viagra online.  Effects of Female Pink Viagra.  Purchase Female Pink Viagra.  Female Pink Viagra over the counter.  Purchase Female Pink Viagra online.  Buy Female Pink Viagra without prescription.  Female Pink Viagra recreational.  Buy generic Female Pink Viagra.  Cheap Female Pink Viagra.  Female Pink Viagra no prescription.  Female Pink Viagra wiki.  Cheap Female Pink Viagra no rx.  Female Pink Viagra canada, mexico, india.  Buying Female Pink Viagra online over the counter.  Where to buy Female Pink Viagra.  Female Pink Viagra cost.  Female Pink Viagra from mexico.  Is Female Pink Viagra safe.  Buy Female Pink Viagra online cod.  Buy Female Pink Viagra from mexico.  Where can i order Female Pink Viagra without prescription.  Real brand Female Pink Viagra online.  Buy Female Pink Viagra from canada.  Female Pink Viagra overnight.  Female Pink Viagra use.  Order Female Pink Viagra from mexican pharmacy.  Female Pink Viagra street price.  Female Pink Viagra coupon.  Female Pink Viagra schedule.  Female Pink Viagra mg.  Female Pink Viagra interactions.  Taking Female Pink Viagra.  Female Pink Viagra used for.  Is Female Pink Viagra addictive.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4750'>Celebrex For Sale</a>. <a href='http://elegantcode.com/?p=4661'>Buy Methotrexate Without Prescription</a>. <a href='http://elegantcode.com/?p=4755'>Buy Zovirax Without Prescription</a>. <a href='http://elegantcode.com/?p=4311'>Buy Topamax Without Prescription</a>. <a href='http://elegantcode.com/?p=4476'>Modalert For Sale</a>. <a href='http://elegantcode.com/?p=4671'>Buy Quinine no prescription</a>. <a href='http://elegantcode.com/?p=4643'>Premarin duration</a>. <a href='http://elegantcode.com/?p=4340'>Purchase Atarax for sale</a>. <a href='http://elegantcode.com/?p=4732'>Abilify price</a>. <a href='http://elegantcode.com/?p=4373'>No prescription Topamax online</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.thegriffonnews.com/?p=10565'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5050'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://changecamp.ca/?p=593'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://linuxologist.com/?p=450'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://blog.farmland.org/?p=1496'>Buy Female Pink Viagra Without Prescription</a>. <a href='http://www.quarterlives.com/?p=930'>Female Pink Viagra brand name</a>. <a href='http://www.greatgreengoods.com/?p=3683'>Discount Female Pink Viagra</a>. <a href='http://www.macneilbmx.com/blog/?p=4935'>Female Pink Viagra pics</a>. <a href='http://social-blend.com/?p=671'>Female Pink Viagra results</a>. <a href='http://4realz.net/?p=847'>Female Pink Viagra pics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/31/prism-fy-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Buy Tindamax Without Prescription</title>
		<link>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mapping-an-address-with-the-bing-maps-wpf-control-beta</link>
		<comments>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 22:21:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[bing maps]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/</guid>
		<description><![CDATA[In my last post Buy Tindamax Without Prescription, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate [...]]]></description>
			<content:encoded><![CDATA[<p> <p>In my last <a href="http://elegantcode.com/2011/08/26/build-an-earthquake-application-with-bing-maps-wpf-control-beta/" target="_blank">post</a> <b>Buy Tindamax Without Prescription</b>, I showed you how to get started using the Bing Maps WPF control by creating an earthquake application.&#160; Now I want to introduce you to the Bing Maps SOAP Services.&#160; The Bing Maps SOAP Services is a set of programmable SOAP services that allow you to integrate maps and imagery, driving directions, distance calculations, and other location intelligence into your applications, business processes, and Web sites. </p>  <p>Let’s start with the Geocode Service which is used to match addresses, <b>buy cheap Tindamax</b>, <b>Purchase Tindamax for sale</b>, places, and geographic entities to latitude and longitude coordinates on the map, <b>my Tindamax experience</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, as well as return location information for a specified latitude and longitude coordinate.&#160; We will create a simple application that allows you to enter an address and place a pushpin at that location.&#160; First thing is first:</p>  <ol>   <li><a href="http://www.microsoft.com/download/en/details.aspx?id=27165" target="_blank">Get the Bing Maps WPF control.</a> </li>    <li><a href="https://www.bingmapsportal.com/" target="_blank">Get a Bing Maps API key.</a> </li> </ol>  <p>You <strong><u>MUST</u></strong> have a Bing Maps API key in order to use any of the SOAP services.&#160; Now that you have that out of the way let’s write an application. Create a new WPF application targeting the .NET 4.0 framework, <b>order Tindamax from United States pharmacy</b>.  <b>Online buying Tindamax</b>, Add a reference to the <strong>Microsoft.Maps.MapControl.WPF.dll</strong>. This will most likely be located in Program Files or Program Files (x86) –&gt; Bing Maps WPF Control –&gt; Beta –&gt; Libraries, <b>buy Tindamax without a prescription</b>.  <b>After Tindamax</b>, </p>  <p>Open up your App.xaml.&#160; You need to add an ApplicationIdCredentialsProvider as a resource and enter your ApplicationId:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c7fbbfb-a6ac-496d-a298-bddbd655ac65" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>discount Tindamax</b>, <b>Buy Tindamax no prescription</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.App&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>             <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>             <span style="color:#ff0000"> StartupUri</span><span style="color:#0000ff">=&quot;MainWindow.xaml&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">ApplicationIdCredentialsProvider</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Key</span><span style="color:#0000ff">=&quot;MyCredentials&quot;</span><span style="color:#ff0000"> ApplicationId</span><span style="color:#0000ff">=&quot;Your API Key&quot; /&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application.Resources</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Application</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Now create a very simple UI that will accept an address and a button to perform the geocoding:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fc9a874e-765b-4bc2-b82b-88a96f1ef84c" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax treatment</b>, <b>Tindamax no rx</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Window</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Class</span><span style="color:#0000ff">=&quot;BingMapsGeocodeDemo.MainWindow&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">x</span><span style="color:#0000ff">=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;</span><br>        <span style="color:#ff0000"> xmlns</span><span style="color:#0000ff">:</span><span style="color:#ff0000">bing</span><span style="color:#0000ff">=&quot;clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF&quot;</span><br>        <span style="color:#ff0000"> Title</span><span style="color:#0000ff">=&quot;MainWindow&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;600&quot;</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;800&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;Auto&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">RowDefinition</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;*&quot; /&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid.RowDefinitions</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span><br> <br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>                  <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Window</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>The next thing we need to do is add a new Service Reference to the project and point to the following service:</p>  <p><a title="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc" href="http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc">http://dev.virtualearth.net/webservices/v1/geocodeservice/geocodeservice.svc</a></p>  <p>Give your service a name (I called mine BingMapsService) and just for fun, <b>buy Tindamax online cod</b>, <b>Generic Tindamax</b>, in the “Add Service Reference” dialog, click the “Advanced” button and click “Generate asynchronous operations”.</p>  <p>Next we need to create a ViewModel to support our View.&#160; This is a WPF application after all.&#160; This ViewModel will need a command for the button that will perform the geocoding, <b>Tindamax duration</b>, <b>Low dose Tindamax</b>, and a property that will represent the result of the service that the UI will use to map the address.&#160; It should resemble something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7b09cd91-31d1-426f-a539-9fe004a3702a" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, <b>Tindamax street price</b>, <b>Tindamax blogs</b>, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">GeocodeViewModel</span> : <span style="color:#2b91af">INotifyPropertyChanged</span><br> {<br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">ICommand</span> GeocodeAddressCommand { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">private</span> <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#0000ff">private</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> _geocodeResult;<br>     <span style="color:#0000ff">public</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GeocodeResult<br>     {<br>         <span style="color:#0000ff">get</span> { <span style="color:#0000ff">return</span> _geocodeResult; }<br>         <span style="color:#0000ff">set</span><br>         {<br>             _geocodeResult = <span style="color:#0000ff">value</span>;<br>             OnPropertyChanged(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>);<br>         }<br>     }<br> <br>     <span style="color:#0000ff">public</span> GeocodeViewModel()<br>     {<br>         GeocodeAddressCommand = <span style="color:#0000ff">new</span> <span style="color:#2b91af">DelegateCommand</span>&lt;<span style="color:#2b91af">String</span>&gt;(GeocodeAddress);<br>     }<br> <br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br>     {<br> <br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">PropertyChangedEventHandler</span> PropertyChanged;<br>     <span style="color:#0000ff">protected</span> <span style="color:#0000ff">virtual</span> <span style="color:#0000ff">void</span> OnPropertyChanged(<span style="color:#0000ff">string</span> propertyName)<br>     {<br>         <span style="color:#0000ff">if</span> (PropertyChanged != <span style="color:#0000ff">null</span>)<br>             PropertyChanged(<span style="color:#0000ff">this</span>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">PropertyChangedEventArgs</span>(propertyName));<br>     }<br> }</div> </div> </div>  <p>I want to point out that the DelegateCommand&lt;T&gt; is a very simple ICommand implementation and should NOT be used in production applications.&#160; Here is the code:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:5cac2fd6-5f40-4d30-b70e-39cf0eb39d77" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax wiki</b>, <b>Tindamax cost</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DelegateCommand</span>&lt;T&gt; : <span style="color:#2b91af">ICommand</span><br> {<br>     <span style="color:#0000ff">private</span> <span style="color:#2b91af">Action</span>&lt;T&gt; _execute;<br> <br>     <span style="color:#0000ff">public</span> DelegateCommand(<span style="color:#2b91af">Action</span>&lt;T&gt; execute)<br>     {<br>         _execute = execute;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">bool</span> CanExecute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         <span style="color:#0000ff">return</span> <span style="color:#0000ff">true</span>;<br>     }<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">event</span> <span style="color:#2b91af">EventHandler</span> CanExecuteChanged;<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">void</span> Execute(<span style="color:#0000ff">object</span> parameter)<br>     {<br>         _execute.Invoke((T)parameter);<br>     }<br> }</div> </div> </div>  <p>Let’s hook our UI up to our command.&#160; it should look something like this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7f154da3-e1a9-48e1-8dcd-53063e2268ec" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax overnight</b>, <b>Online buy Tindamax without a prescription</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">&lt;</span><span style="color:#a31515">StackPanel</span><span style="color:#ff0000"> Orientation</span><span style="color:#0000ff">=&quot;Horizontal&quot;</span><span style="color:#ff0000"> Margin</span><span style="color:#0000ff">=&quot;10&quot; &gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">TextBox</span><span style="color:#ff0000"> x</span><span style="color:#0000ff">:</span><span style="color:#ff0000">Name</span><span style="color:#0000ff">=&quot;_txtAddress&quot;</span><span style="color:#ff0000"> MinWidth</span><span style="color:#0000ff">=&quot;250&quot; /&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Map It&quot;</span><span style="color:#ff0000"> IsDefault</span><span style="color:#0000ff">=&quot;True&quot;</span> <br>                    <span style="color:#ff0000"> Command</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeAddressCommand}</span><span style="color:#0000ff">&quot;</span><br>                    <span style="color:#ff0000"> CommandParameter</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> Text</span><span style="color:#0000ff">, <b>where can i buy Tindamax online</b>, <b>Discount Tindamax</b>, </span><span style="color:#ff0000">ElementName</span><span style="color:#0000ff">=</span>_<span style="color:#0000ff">txtAddress}&quot;/&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">StackPanel</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>Notice that we are using the text of the TextBox as the CommandParameter.&#160; Next, we need to implement the command:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0d2006e3-d7cf-483a-b57b-284d06ecffff" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>Tindamax for sale</b>, <b>Tindamax used for</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> GeocodeAddress(<span style="color:#0000ff">string</span> address)<br> {<br>     <span style="color:#0000ff">using</span> (BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span> client = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeServiceClient</span>(<span style="color:#a31515">&quot;CustomBinding_IGeocodeService&quot;</span>))<br>     {<br>         client.GeocodeCompleted += (o, <b>buy no prescription Tindamax online</b>, <b>Tindamax online cod</b>, e) =&gt;<br>         {<br>             <span style="color:#0000ff">if</span> (e.Error == <span style="color:#0000ff">null</span>)<br>             {<br>                 GeocodeResult = e.Result.Results[0];<br>             }<br>         };<br> <br>         BingMapsService.<span style="color:#2b91af">GeocodeRequest</span> request = <span style="color:#0000ff">new</span> BingMapsService.<span style="color:#2b91af">GeocodeRequest</span>();<br>         request.Credentials = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Credentials</span>() { ApplicationId = (<span style="color:#2b91af">App</span>.Current.Resources[<span style="color:#a31515">&quot;MyCredentials&quot;</span>] <span style="color:#0000ff">as</span> <span style="color:#2b91af">ApplicationIdCredentialsProvider</span>).ApplicationId };<br>         request.Query = address;<br>         client.GeocodeAsync(request);<br>     }<br> }</div> </div> </div>  <p>In this command we are simply creating an instance of the service client, creating a GeocodeRequest, <b>Tindamax coupon</b>, <b>Kjøpe Tindamax på nett, köpa Tindamax online</b>, setting the credentials using the ApplicationId we have stored in the App.xaml, and then using the address as the Query for the request.&#160; When the call to the service is completed we are setting the GeocodeResult property to the first element in the results.</p>  <p>Now the tricky part.&#160; We want to place a Pushpin on the address that was entered and then move the map to that location.&#160; We also need to make sure that when another address is entered, <b>buying Tindamax online over the counter</b>, <b>Is Tindamax safe</b>, we clear any previous Pushpins that may exist on the map.&#160; We also have to be aware that other elements my be on the map and we don’t want to accidentally alter those elements.&#160; Oh and did I mention this was an MVVM application and this has to be done with just data binding. </p>  <p>The approach that I decided to go with is to use <a href="http://msdn.microsoft.com/en-us/library/ms749011.aspx" target="_blank">Attached Properties</a>.&#160; So I created two attached properties; one for the GeocodeResult and another for a MapLayer that will be dedicated to the GeocodeResult.&#160; This will allow us to create a MapLayer that is specific to our GeocodeResut and not alter any other elements that may be on the map.&#160; Let’s check out the code.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3cc3f4e4-cbae-4ffe-93bf-4a10f2e36d08" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', <b>herbal Tindamax</b>, <b>Tindamax price, coupon</b>, Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">MapInteractivity</span><br> {<br>     <span style="color:#0000ff">#region</span> GeocodeResult<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResult&quot;</span>, <b>buy Tindamax without a prescription</b>, <b>Buy Tindamax without prescription</b>, <span style="color:#0000ff">typeof</span>(BingMapsService.<span style="color:#2b91af">GeocodeResult</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <b>cheap Tindamax</b>, <b>Tindamax trusted pharmacy reviews</b>, <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> BingMapsService.<span style="color:#2b91af">GeocodeResult</span> GetGeocodeResult(<span style="color:#2b91af">Map</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)target.GetValue(GeocodeResultProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResult(<span style="color:#2b91af">Map</span> target, <b>ordering Tindamax online</b>, <b>Tindamax canada, mexico, india</b>, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> value)<br>     {<br>         target.SetValue(GeocodeResultProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultChanged((<span style="color:#2b91af">Map</span>)o, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.OldValue, (BingMapsService.<span style="color:#2b91af">GeocodeResult</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultChanged(<span style="color:#2b91af">Map</span> map, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> oldValue, BingMapsService.<span style="color:#2b91af">GeocodeResult</span> newValue)<br>     {<br>         <span style="color:#2b91af">Location</span> location = newValue.Locations.Select(x =&gt; <span style="color:#0000ff">new</span> <span style="color:#2b91af">Location</span>(x.Latitude, x.Longitude)).First();<br> <br>         <span style="color:#2b91af">Pushpin</span> pin = <span style="color:#0000ff">new</span> <span style="color:#2b91af">Pushpin</span>();<br>         pin.Location = location;<br>         pin.ToolTip = newValue.Address.FormattedAddress;<br> <br>         <span style="color:#0000ff">var</span> locationLayer = GetGeocodeResultLayer(map);<br>         <span style="color:#0000ff">if</span> (locationLayer == <span style="color:#0000ff">null</span>)<br>         {<br>             locationLayer = <span style="color:#0000ff">new</span> <span style="color:#2b91af">MapLayer</span>();<br>             SetGeocodeResultLayer(map, locationLayer);<br>         }<br> <br>         locationLayer.Children.Clear();<br>         locationLayer.Children.Add(pin);<br> <br>         map.SetView(location, map.ZoomLevel);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResult</span><br> <br>     <span style="color:#0000ff">#region</span> GeocodeResultLayer<br> <br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> GeocodeResultLayerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;GeocodeResultLayer&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapLayer</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">MapInteractivity</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(<span style="color:#0000ff">null</span>, OnGeocodeResultLayerChanged));<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">MapLayer</span> GetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target)<br>     {<br>         <span style="color:#0000ff">return</span> (<span style="color:#2b91af">MapLayer</span>)target.GetValue(GeocodeResultLayerProperty);<br>     }<br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetGeocodeResultLayer(<span style="color:#2b91af">DependencyObject</span> target, <span style="color:#2b91af">MapLayer</span> value)<br>     {<br>         target.SetValue(GeocodeResultLayerProperty, value);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br>     {<br>         OnGeocodeResultLayerChanged((<span style="color:#2b91af">Map</span>)o, (<span style="color:#2b91af">MapLayer</span>)e.OldValue, (<span style="color:#2b91af">MapLayer</span>)e.NewValue);<br>     }<br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnGeocodeResultLayerChanged(<span style="color:#2b91af">Map</span> map, <span style="color:#2b91af">MapLayer</span> oldValue, <span style="color:#2b91af">MapLayer</span> newValue)<br>     {<br>         map.Children.Add(newValue);<br>     }<br> <br>     <span style="color:#0000ff">#endregion</span> <span style="color:#008000">//GeocodeResultLayer</span><br> }</div> </div> </div>  <p>Notice that when the GeocodeResult changes we get the Location and create a pushpin for that location.&#160; We also set the tooltip to the FormattedAddress of the GeocodeResult.&#160; So when we hover over the pushpin we will see a nice little tooltip of the address.&#160; Next we try to get the GeocodeResultLayer from the map, if it is null this means it doesn’t exist on the map yet so we create one and assign it accordingly.&#160; We clear the layer child elemnts and then add out pushpin.&#160; The last thing we do is call the SetView method of the Map control passing in the location and the current ZoomLevel.</p>  <p>The final step is to use our AttachedProperty on the map.&#160; Be sure to create a namespace for the MapInteractivity class and define it as follows:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:72d6307a-aef3-4f70-8d47-8d4529fc74e0" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#ff0000"> Grid.Row</span><span style="color:#0000ff">=&quot;1&quot;</span><span style="color:#ff0000"> CredentialsProvider</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">StaticResource</span><span style="color:#ff0000"> MyCredentials}</span><span style="color:#0000ff">&quot;</span><span style="color:#ff0000"> Center</span><span style="color:#0000ff">=&quot;40,-95&quot;</span><br>          <span style="color:#ff0000"> core</span><span style="color:#0000ff">:</span><span style="color:#ff0000">MapInteractivity.GeocodeResult</span><span style="color:#0000ff">=&quot;{</span><span style="color:#a31515">Binding</span><span style="color:#ff0000"> GeocodeResult}</span><span style="color:#0000ff">&quot;</span><br>          <span style="color:#ff0000"> ZoomLevel</span><span style="color:#0000ff">=&quot;4&quot;</span><span style="color:#ff0000"> AnimationLevel</span><span style="color:#0000ff">=&quot;Full&quot; &gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">bing</span><span style="color:#0000ff">:</span><span style="color:#a31515">Map</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>One last thing.&#160; Be sure to remember to set your DataContext of your View to the ViewModel we have created:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f7d0b4f-e096-487d-8343-fb42c94c3360" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> MainWindow()<br> {<br>     InitializeComponent();<br>     DataContext = <span style="color:#0000ff">new</span> <span style="color:#2b91af">GeocodeViewModel</span>(); <br> }</div> </div> </div>  <p>That’s it.&#160; You now have an application the can map (geocode) an address using the Bing Maps WPF Control and the Geocoding SOAP Service.&#160; Oh and we are doing this all with MVVM and data binding which is my favorite part.&#160; Be sure to <a href="http://www.brianlagunas.com/downloads/source/bingmapsgeocodedemo.zip">Download the Source</a> and start playing around.</p>.</p>
<p></p>
<p><b>Similar posts:</b> <a href='http://elegantcode.com/?p=4746'>Buy Clindamycin Gel Without Prescription</a>. <a href='http://elegantcode.com/?p=4328'>Buy Plavix Without Prescription</a>. <a href='http://elegantcode.com/?p=4302'>Buy Phenergan Without Prescription</a>. <a href='http://elegantcode.com/?p=4460'>Buy Proscar Without Prescription</a>. <a href='http://elegantcode.com/?p=4607'>Triamterene For Sale</a>. <a href='http://elegantcode.com/?p=4751'>Diflucan street price</a>. <a href='http://elegantcode.com/?p=4372'>Nexium steet value</a>. <a href='http://elegantcode.com/?p=4475'>Metronidazole Gel from mexico</a>. <a href='http://elegantcode.com/?p=4399'>Herbal Periactin</a>. <a href='http://elegantcode.com/?p=4858'>Tramadol over the counter</a>.<br />
<b>Trackbacks from:</b> <a href='http://www.macneilbmx.com/blog/?p=6683'>Buy Tindamax Without Prescription</a>. <a href='http://www.greatgreengoods.com/?p=3313'>Buy Tindamax Without Prescription</a>. <a href='http://www.thegriffonnews.com/?p=9133'>Buy Tindamax Without Prescription</a>. <a href='http://www.themusclecarplace.com/?p=5330'>Buy Tindamax Without Prescription</a>. <a href='http://changecamp.ca/?p=592'>Buy Tindamax Without Prescription</a>. <a href='http://social-blend.com/?p=444'>Tindamax online cod</a>. <a href='http://blog.farmland.org/?p=3958'>Order Tindamax from mexican pharmacy</a>. <a href='http://4realz.net/?p=717'>Tindamax forum</a>. <a href='http://reversemortgagedaily.com/?p=14265'>Tindamax trusted pharmacy reviews</a>. <a href='http://linuxologist.com/?p=1542'>Tindamax online cod</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2011/08/30/mapping-an-address-with-the-bing-maps-wpf-control-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &#8211; dynamically compile and run event handlers within loose XAML using CodeDom</title>
		<link>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom</link>
		<comments>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:37:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[dynamic code]]></category>
		<category><![CDATA[wpd]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/</guid>
		<description><![CDATA[Last week I wrote a blog post showing how you can write inline code in XAML.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon re-tweeted that post with a link to one of his own posts on exploring new techniques for DLR script in XAML which also links [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a blog post showing how <a href="http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/" target="_blank">you can write inline code in XAML</a>.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon <a href="http://twitter.com/#!/rrelyea/status/15099827364827136" target="_blank">re-tweeted</a> that post with a link to one of his own posts on <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/11/14/exploring-new-techniques-for-dlr-script-in-xaml.aspx" target="_blank">exploring new techniques for DLR script in XAML</a> which also links to another one of his posts which shows different techniques for <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/06/03/xaml-events-in-compiled-and-uncompiled-scenarios.aspx" target="_blank">hooking up events in compiled and uncompiled scenarios</a> which in turn links to <a href="http://www.thinkbottomup.com.au/site/blog/Embedding_DLR_Scripts_in_XAML_Part_1" target="_blank">this post about embedding DLR scripts in XAML</a> written by Daniel Paull.&#160; Wow, that is a lot of linking.</p>  <p>Well, now that everyone has been given their respective credit, let’s continue.&#160; I wanted to take my last post a little further.&#160; In that post I simply created an event handler for a button click event using inline code in the x:Code directive.&#160; If you started to play with the sample code, you might have thought to yourself, “I wonder if I can load this XAML, event handler and all, from a file or database and have it still work.”.&#160; Well, if you tried it, you found the answer really quick.&#160; No!&#160; The reason is pretty simple; code must be compiled in order to execute.&#160; Therefore any code inside loose XAML will fail.&#160; Also, when using loose XAML, trying to hookup an event handler would crash your application because it is not allowed.</p>  <p>Oh, then it must not be possible? Wrong!&#160; Well, then how do you do it if the code must be compiled?&#160; Simple, we compile the code just before we run it.&#160; Say what?&#160; That’s right, let me introduce you to the <a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" target="_blank">CodeDom</a>.&#160; The CodeDom allows you to dynamically generate and compile code at runtime.&#160; Let’s get to it.</p>  <p>We need to attach event handlers to elements in loose XAML, and have them execute C# code.&#160; Each element has different events to handle, and each event will execute different code.&#160; This tells me that we need an object that contains two properties, one to specify the RoutedEvent to handle, and another to specify the c# code to execute.&#160; We also need a common event handler definition to execute whenever the RoutedEvent is invoked.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c257533-76d5-4e97-9754-1b389f8f52b5" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DynamicEvent</span><br> {<br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the routed event to execute.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The routed event.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">RoutedEvent</span> RoutedEvent { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the script to run when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The script.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Script { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Called when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br>     {<br>         <br>     }<br> }</div> </div> </div>  <p>That was simple enough.&#160; Now, in order to attach event handlers to elements in loose XAML, we need away to get around the “no event handlers allowed” limitation.&#160; To do this we can use an attached property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c6021e-2311-4633-85f8-8fcb27a9cb89" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> HandlerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;Handler&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(OnHandlerChanged));<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DynamicEvent</span> GetHandler(<span style="color:#2b91af">DependencyObject</span> obj)<br> {<br>     <span style="color:#0000ff">return</span> (<span style="color:#2b91af">DynamicEvent</span>)obj.GetValue(HandlerProperty);<br> }<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetHandler(<span style="color:#2b91af">DependencyObject</span> obj, <span style="color:#0000ff">bool</span> value)<br> {<br>     obj.SetValue(HandlerProperty, value);<br> }<br> <br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnHandlerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">UIElement</span> uie = o <span style="color:#0000ff">as</span> <span style="color:#2b91af">UIElement</span>;<br>     <span style="color:#0000ff">if</span> (uie == <span style="color:#0000ff">null</span>)<br>         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">Exception</span>(<span style="color:#a31515">&quot;Attempt to set EventHandler on non-UIElement Type&quot;</span>);<br> <br>     <span style="color:#2b91af">DynamicEvent</span> oldHandler = e.OldValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br>     <span style="color:#2b91af">DynamicEvent</span> newHandler = e.NewValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br> <br>     <span style="color:#008000">// unhook the old event</span><br>     <span style="color:#0000ff">if</span> (oldHandler != <span style="color:#0000ff">null</span>)<br>         uie.RemoveHandler(oldHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(oldHandler.OnEventExecuted));<br> <br>     <span style="color:#008000">// hook up the new</span><br>     <span style="color:#0000ff">if</span> (newHandler != <span style="color:#0000ff">null</span>)<br>         uie.AddHandler(newHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(newHandler.OnEventExecuted));<br> <br> }</div> </div> </div>  <p>This attached property allows use to attach an instance of our DynamicEvent class to our element.&#160; When the Handler attached property is set, we simple add our OnEventExecute event handler to the RoutedEvent specified in the RoutedEvent property.&#160; Now we have the basic framework needed to attach and event handler to any event on any element in loose XAML.&#160; Let’s see how to attach an event handler in XAML using this newly created DynamicEvent class.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c323adca-e880-4dd4-997e-958bccc70c3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Initial Text&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#ff0000"> RoutedEvent</span><span style="color:#0000ff">=&quot;Button.Click&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#ff0000"> xml</span><span style="color:#0000ff">:</span><span style="color:#ff0000">space</span><span style="color:#0000ff">=&quot;preserve&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>                         <span style="color:#808080">var button = sender as Button;</span><br>                         <span style="color:#808080">button.Content = &quot;Changed with Dynamic Code&quot;;</span><br>                         <span style="color:#808080">]]&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Button</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see I have added a handler for a Button’s Click event.&#160; I also provided a Script to execute when the event is invoked.&#160; Notice that we are preserving the whitespace in the script.&#160; Of course nothing will happen just yet.&#160; Now we need to take the script and compile it at run time.&#160; This is where the CodeDom comes in.</p>  <p>The steps necessary to compile code at run time go a little something like this:</p>  <ul>   <li>Create a CodeCompileUnit </li>    <li>Add our namespace and import statements </li>    <li>create our dynamic class </li>    <li>add a method that will execute the Script </li>    <li>compile the code </li>    <li>execute the code </li> </ul>  <p>All these steps must be performed when the ROutedEvent is invoked, which means the code must be compiled inside the OnEventExecuted event handler.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56b1a794-ec6b-4976-9f18-e819f5a52641" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">CodeCompileUnit</span> compileUnit = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeCompileUnit</span>();<br> <br>     <span style="color:#008000">//create our namesapce and import statements, then add it to the compile unit</span><br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = CreateNamespaceAndImports();<br>     compileUnit.Namespaces.Add(namespaces);<br> <br>     <span style="color:#008000">//create our target class and add it to the namespace</span><br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = CreateTargetClass();<br>     namespaces.Types.Add(targetClass);<br> <br>     <span style="color:#008000">//create the ExecuteScript method and then add it to our class</span><br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = CreateExecuteScriptMethod();<br>     targetClass.Members.Add(executeEventMethod);<br> <br>     <span style="color:#008000">//create our compiler parameters</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = CreateCompilerParameters();<br> <br>     <span style="color:#008000">//compile the assembly</span><br>     <span style="color:#0000ff">var</span> results = CompileAssembly(compileUnit, compilerParams);<br> <br>     <span style="color:#008000">//execute the code</span><br>     ExecuteCode(results, sender, e);<br> }</div> </div> </div>  <p>The first step is really easy.&#160; We simply need to create an instance of the CodeCompileUnit class.&#160; The CodeCompileUnit references the CodeDom object graph and has properties for storing attributes, namespaces, and assemblies.&#160; Next we need to create our namespace and import statements.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b89b170-e94b-4b3b-a8d8-8df82193e6d3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the namespace and imports.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;remarks&gt;</span><span style="color:#008000">I have only added three import statements as an example. You should add all import statements required to run your dynamic code</span><span style="color:#808080">&lt;/remarks&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeNamespace</span> CreateNamespaceAndImports()<br> {<br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespace</span>(<span style="color:#a31515">&quot;WPFCodeInjection&quot;</span>);<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows.Controls&quot;</span>));<br>     <span style="color:#0000ff">return</span> namespaces;<br> }</div> </div> </div>  <p>Once the namespace and import statement are created we need to add them to out CodeCompileUnit instance.&#160; Then we need to create our dynamic class.&#160; We need to make sure it is a public class:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a495da08-da32-46e0-ba99-c5fac5d189e1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the target class.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeTypeDeclaration</span> CreateTargetClass()<br> {<br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeTypeDeclaration</span>(<span style="color:#a31515">&quot;DynamicClass&quot;</span>);<br>     targetClass.TypeAttributes = <span style="color:#2b91af">TypeAttributes</span>.Public;<br>     <span style="color:#0000ff">return</span> targetClass;<br> }</div> </div> </div>  <p>When the dynamic class is created we add it to our namespace.&#160; Now we create a method. We give it a name of ExecuteScript and set its access modifier to public.&#160; We specify that it accepts two parameters.&#160; One being the sender which is of type object, and one that is the event args that is of type RoutedEventArgs.&#160; Lastly, we set the body of the method to the Script property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4cae0858-7130-4df1-b3b1-cf49063a4d50" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the ExecuteScript method.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#2b91af">CodeMemberMethod</span> CreateExecuteScriptMethod()<br> {<br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeMemberMethod</span>();<br>     executeEventMethod.Name = <span style="color:#a31515">&quot;ExecuteScript&quot;</span>;<br>     executeEventMethod.Attributes = <span style="color:#2b91af">MemberAttributes</span>.Public | <span style="color:#2b91af">MemberAttributes</span>.Final;<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Object&quot;</span>, <span style="color:#a31515">&quot;sender&quot;</span>));<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Windows.RoutedEventArgs&quot;</span>, <span style="color:#a31515">&quot;e&quot;</span>));<br>     executeEventMethod.Statements.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeSnippetStatement</span>(Script));<br>     <span style="color:#0000ff">return</span> executeEventMethod;<br> }</div> </div> </div>  <p>Now we have to create our compiler parameters.&#160; These include adding referencing to the necessary Dlls required to run your code.&#160; We also want to specify that we want to generate the code in memory.&#160; If you wanted to you could save the assembly to a file.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cebbac90-1864-436d-8248-de681876fa83" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the compiler parameters.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerParameters</span> CreateCompilerParameters()<br> {<br>     <span style="color:#008000">//add compiler parameters and assembly references</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CompilerParameters</span>();<br>     compilerParams.CompilerOptions = <span style="color:#a31515">&quot;/target:library /optimize&quot;</span>;<br>     compilerParams.GenerateExecutable = <span style="color:#0000ff">false</span>;<br>     compilerParams.GenerateInMemory = <span style="color:#0000ff">true</span>;<br> <br>     <span style="color:#008000">//you can add references individually if you want by providing the location of the assembly</span><br>     <span style="color:#008000">//compilerParams.ReferencedAssemblies.Add(&quot;System.dll&quot;);</span><br> <br>     <span style="color:#008000">//I am lazy so I will just loop through the assemblies that are already loaded and add those</span><br>     <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Assembly</span> assembly <span style="color:#0000ff">in</span> <span style="color:#2b91af">AppDomain</span>.CurrentDomain.GetAssemblies())<br>     {<br>         <span style="color:#0000ff">try</span><br>         {<br>             <span style="color:#0000ff">string</span> location = assembly.Location;<br>             <span style="color:#0000ff">if</span> (!<span style="color:#2b91af">String</span>.IsNullOrEmpty(location))<br>                 compilerParams.ReferencedAssemblies.Add(location);<br>         }<br>         <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">NotSupportedException</span>)<br>         {<br>             <span style="color:#008000">// this happens for dynamic assemblies, so just ignore it.                     </span><br>         }<br>     }<br> <br>     <span style="color:#0000ff">return</span> compilerParams;<br> }</div> </div> </div>  <p>Now we compile the code into an assembly.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b05d391c-e1d9-47c3-b9b3-2c147f47e7bb" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Compiles the assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compileUnit&quot;&gt;</span><span style="color:#008000">The compile unit.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compilerParams&quot;&gt;</span><span style="color:#008000">The compiler params.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerResults</span> CompileAssembly(<span style="color:#2b91af">CodeCompileUnit</span> compileUnit, <span style="color:#2b91af">CompilerParameters</span> compilerParams)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">CSharpCodeProvider</span> provider = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CSharpCodeProvider</span>())<br>     {<br>         <span style="color:#008000">// =============================================================================== //</span><br>         <span style="color:#008000">// if you want to see the actual complied source code uncomment //</span><br>         <span style="color:#008000">// =============================================================================== //</span><br> <br>         <span style="color:#008000">//StringBuilder source = new StringBuilder();</span><br>         <span style="color:#008000">//StringWriter sw = new StringWriter(source);</span><br>         <span style="color:#008000">//provider.GenerateCodeFromCompileUnit(compileUnit, sw, new CodeGeneratorOptions());</span><br>         <span style="color:#008000">//string sourceCode = source.ToString();</span><br> <br>         <span style="color:#0000ff">var</span> results = provider.CompileAssemblyFromDom(compilerParams, compileUnit);<br>         <span style="color:#0000ff">return</span> results;<br>     }<br> }</div> </div> </div>  <p>The last thing we need to do is run the code that was just compiled.&#160; We will need the help of reflection to accomplish this.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09c68e9b-98f4-4334-aa9f-ecf464569e54" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Executes the ExecuteScript method from the compiled CodeDom assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;results&quot;&gt;</span><span style="color:#008000">The results.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> ExecuteCode(<span style="color:#2b91af">CompilerResults</span> results, <span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">try</span><br>     {<br>         <span style="color:#2b91af">Assembly</span> executingAssembly = results.CompiledAssembly;<br>         <span style="color:#0000ff">if</span> (executingAssembly != <span style="color:#0000ff">null</span>)<br>         {<br>             <span style="color:#008000">//create an instance of our newly compiled assembly</span><br>             <span style="color:#0000ff">object</span> assemblyInstance = executingAssembly.CreateInstance(<span style="color:#a31515">&quot;WPFCodeInjection.DynamicClass&quot;</span>);<br> <br>             <span style="color:#008000">//get our ExecuteScript method and execute it.</span><br>             <span style="color:#2b91af">MethodInfo</span> info = assemblyInstance.GetType().GetMethod(<span style="color:#a31515">&quot;ExecuteScript&quot;</span>);<br>             info.Invoke(assemblyInstance, <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[] { sender, e });<br>         }<br>     }<br>     <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">Exception</span> ex)<br>     {<br>         <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Error: An exception occurred while executing the script&quot;</span>, ex);<br>     }<br> }</div> </div> </div>  <p>That is it.&#160; Now to test this out lets create a .txt file that contains our XAML that we define above and save it CodeSnippet.txt.&#160; In our MainWindow.xaml.cs, lets handle the Loaded event and load our CodeSnippet.txt using the XamlReader.Load method.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc56e72c-6fdc-4430-afb5-4498031c46f1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">void</span> MainWindow_Loaded(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">FileStream</span> fs = <span style="color:#0000ff">new</span> <span style="color:#2b91af">FileStream</span>(<span style="color:#a31515">@&quot;./CodeSnippet.txt&quot;</span>, <span style="color:#2b91af">FileMode</span>.Open))<br>     {<br>         <span style="color:#0000ff">this</span>.Content = <span style="color:#2b91af">XamlReader</span>.Load(fs);<br>     }<br> }</div> </div> </div>  <p>Run the application is this is what it should look like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb9.png" width="174" height="179" /></a></p>  <p>Now click the button and our C# code defined within the Script property will be dynamically compiled and executed changed the text of the button to this:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb10.png" width="184" height="179" /></a></p>  <p>This is a very simple example and is not intended to be a complete solution, but it does show some of the powerful capabilities you have using WPF, XAML, and the CodeDom.&#160; Like always <a href="http://brianlagunas.com/downloads/source/WpfCodeInjection.zip">download the source</a> and start playing around.&#160; See what kind of cool stuff you can do with it.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Yes you can write Inline Code in XAML</title>
		<link>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yes-you-can-write-inline-code-in-xaml</link>
		<comments>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 21:11:51 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Esoterica]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/</guid>
		<description><![CDATA[A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago I was spreading the WPF goodness and was talking about how MVVM (Model-View-ViewModel) helps promote separation of concerns by removing the need for the code-behind file from the associated XAML file.&#160; After my statement someone replied with the following question, “So why even have it there, can you just delete it?”.&#160; Obviously I replied yes, you absolutely can delete the code-behind file from a XAML file and the application will still work.&#160; Then they replied, “That’s cool I guess, but what about the code that needs to execute, such as event handlers?”.&#160; Naturally I brought up the fact that using MVVM you don’t use event handlers, but as most developers do, they said, “Well what if I really needed it?”.&#160; My reply to that question was, “If you really had to, it is possible to write inline code inside the XAML file”.</p>  <p>They looked at me in amazement, “Really?”.&#160; Apparently that is a little known fact about WPF.&#160; Yes, it is absolutely possible to write inline code inside a XAML page without the need for a code-behind file, and everything will work as expected.&#160; I quickly realized that his was going somewhere I didn’t want it to go.&#160; I knew what was coming next; they asked me to show them how to do it. Uggg…</p>  <p>Okay here is the deal; what I am about to show you is not recommended.&#160; It goes against everything I have been teaching in the community, but if you are curious how to actually do this, it is quit simple.</p>    <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ddf41891-b77a-41c9-89aa-aeb2944933da" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 500px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--Define the button content --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Width</span><span style="color:#0000ff">=&quot;133&quot;</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Name</span><span style="color:#0000ff">=&quot;btnExitApp&quot;</span><span style="color:#ff0000"> Click</span><span style="color:#0000ff">=&quot;btnExitApp_Clicked&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Exit Application&quot;/&gt;</span><br> <br>     <span style="color:#a31515"></span><span style="color:#008000">&lt;!--The C# implementation of the button&#39;s Click event handler. --&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>             <span style="color:#808080">private void btnExitApp_Clicked(object sender, RoutedEventArgs e)</span><br>             <span style="color:#808080">{</span><br>                 <span style="color:#808080">// Get a handle to the current app and shut it down.</span><br>                 <span style="color:#808080">Application.Current.Shutdown();</span><br>             <span style="color:#808080">}</span><br>         <span style="color:#808080">]]&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">x</span><span style="color:#0000ff">:</span><span style="color:#a31515">Code</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Grid</span><span style="color:#0000ff">&gt;</span></div> </div> </div>    <p>As you can see the code snippet above is pretty simple.&#160; You will notice that the Button has a EventHandler defined called “btnExitApp_Clicked”.&#160; Since there is no code-behind (I deleted it) you may be expecting a compile error that says it cannot find the definition for the EventHandler.&#160; But wait, we do have the event handler defined within the &lt;x:Code&gt;….&lt;/x:Code&gt; tags.</p>  <p>The &lt;x:Code&gt;….&lt;/x:Code&gt; is a directive element defined in XAML.&#160; An x:Code directive element can contain inline programming code. The code that is defined inline can interact with the XAML on the same page.&#160; Notice that the code is inside the x:Code element and that the code must be surrounded by &lt;CDATA[...]]&gt; to escape the contents for XML, so that a XAML processor (interpreting either the XAML schema or the WPF schema) will not try to interpret the contents literally as XML.</p>  <p>That is all there really is to it.&#160; There are some limitations to using inline code, for more information you can check out the <a href="http://msdn.microsoft.com/en-us/library/aa970568.aspx" target="_blank">MSDN documentation</a>.&#160; Now, I don’t want to see this in any production code.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Visual Studio: Open in Full XAML View by Default</title>
		<link>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=visual-studio-open-in-full-xaml-view-by-default</link>
		<comments>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 15:49:14 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/</guid>
		<description><![CDATA[So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane [...]]]></description>
			<content:encoded><![CDATA[<p>So I am using Visual Studio 2008 for developing WPF and Silverlight applications.&#160; The one thing that really annoys me is when I open a .XAML file and then Visual Studio automatically opens the file in split view mode.&#160; I am sure you are well aware of how VS 2008 support for the preview pane blows.&#160; So now I have to sit and wait for VS to render my view in the preview pane, and sometimes it can take a while, if it doesn’t just completely crash.&#160; Sometimes I take the extra time to go grab a snack and beverage of my choice.&#160; </p>  <p>So here is a hidden performance increasing jewel you might find useful.&#160; We can set the default open mode to be in full XAML view.</p>  <p>First thing you need to do is in Visual Studio go to your Tools ==&gt; Options ==&gt; Text Editor ==&gt; XAML ==&gt; Miscellaneous.&#160; There you will see an option for “Always open documents in full XAML view”.&#160; Check that box.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/04/image.png" target="_blank"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="xaml options for opening in full xaml view" border="0" alt="xaml options for opening in full xaml view" src="http://elegantcode.com/wp-content/uploads/2010/04/image_thumb.png" width="244" height="146" /></a> </p>  <p>Now every time you open a XAML file it will open in full XAML view and give you one less thing to gripe about.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/04/01/visual-studio-open-in-full-xaml-view-by-default/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A Simple WPF Loading Animation</title>
		<link>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-simple-wpf-loading-animation</link>
		<comments>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 03:47:21 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/</guid>
		<description><![CDATA[Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I needed a very simple and clean loading animation for a multi threaded application I was working on to notify the user that something was in the process of being loaded.&#160; So of course the first place I looked was Google, because I figured someone else has already written one and I could save myself some time by just using theirs.&#160; Well, after almost an hour searching, I found nothing.&#160; So much for being a timesaver.&#160; Now, don’t get me wrong, I found a couple of WPF animations out there, but none of them really fit what I needed.&#160; So I just decided to bite the bullet and create my own.&#160; After creating the animation I decided to share the fruits of my labor so that anyone else who is looking for the same thing I was, or something similar, wouldn’t have as much trouble as I did.</p>  <p>Here is what it looks like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="loadingAnimation" border="0" alt="loadingAnimation" src="http://elegantcode.com/wp-content/uploads/2009/08/loadingAnimation_thumb.jpg" width="114" height="114" /></a> </p>  <p>Here is the source: <a href="http://brianlagunas.com/downloads/source/LoadingControl.zip">Download the Loading Animation Source</a></p>  <p>I hope it is useful to someone besides me.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/08/21/a-simple-wpf-loading-animation/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Debugging XAML</title>
		<link>http://elegantcode.com/2009/04/14/debugging-xaml/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=debugging-xaml</link>
		<comments>http://elegantcode.com/2009/04/14/debugging-xaml/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 01:43:01 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2009/04/14/debugging-xaml/</guid>
		<description><![CDATA[Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths. Lets say I have the following code snippet: &#60;StatusBar&#62; &#60;StatusBarItem&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I have been asked this question more than almost any XAML related question in the past few weeks; How do I debug XAML?&#160; The problem with XAML’s powerful binding model is that it can be difficult to debug errors in your binding paths.</p>  <p>Lets say I have the following code snippet:</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none">       <span style="color: #0000ff">&lt;</span><span style="color: #800000">TextBlock</span> <span style="color: #ff0000">Text</span><span style="color: #0000ff">=&quot;{Binding Messssage}&quot;</span> <span style="color: #0000ff">/&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">   <span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBarItem</span><span style="color: #0000ff">&gt;</span></pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #0000ff">&lt;/</span><span style="color: #800000">StatusBar</span><span style="color: #0000ff">&gt;</span></pre>
  </div>
</div>

<p></p>

<p>As you can see my property Message is totally misspelled.&#160; If I were to run this application nothing would ever appear in my status bar, and I would not know why.&#160; I didn’t get any compile errors, and my view renders perfectly in my designer, so what the hell is going on.&#160; You might spend hours looking at your object’s property, stepping through the property changed events, or just saying XAML is a piece of crap and I give up.&#160; Well never fear, I am about to reveal the secret to debugging your XAML.</p>

<p>Look in your Output Window!</p>

<p><a href="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow.jpg" target="_blank"><img title="OutputWindow" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="79" alt="OutputWindow" src="http://elegantcode.com/wp-content/uploads/2009/04/outputwindow-thumb.jpg" width="404" border="0" /></a> </p>

<p>Yes, the nearly always forgotten Output Window.&#160; As you can see, if you click on the image above, it tells me that I have a binding expression path error and gives the line number where the error occurred.&#160; So don’t spend hours stepping through code looking for a ghost.&#160; Just check your Output Window.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2009/04/14/debugging-xaml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WPF String.Format in XAML with the StringFormat attribute</title>
		<link>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom</link>
		<comments>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 21:37:00 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[CodeDom]]></category>
		<category><![CDATA[dynamic code]]></category>
		<category><![CDATA[wpd]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/</guid>
		<description><![CDATA[Last week I wrote a blog post showing how you can write inline code in XAML.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon re-tweeted that post with a link to one of his own posts on exploring new techniques for DLR script in XAML which also links [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I wrote a blog post showing how <a href="http://elegantcode.com/2010/12/14/yes-you-can-write-inline-code-in-xaml/" target="_blank">you can write inline code in XAML</a>.&#160; When that blog post was published, @ElegantCode tweeted the post on Twitter.&#160; Rob Relyea soon <a href="http://twitter.com/#!/rrelyea/status/15099827364827136" target="_blank">re-tweeted</a> that post with a link to one of his own posts on <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/11/14/exploring-new-techniques-for-dlr-script-in-xaml.aspx" target="_blank">exploring new techniques for DLR script in XAML</a> which also links to another one of his posts which shows different techniques for <a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/06/03/xaml-events-in-compiled-and-uncompiled-scenarios.aspx" target="_blank">hooking up events in compiled and uncompiled scenarios</a> which in turn links to <a href="http://www.thinkbottomup.com.au/site/blog/Embedding_DLR_Scripts_in_XAML_Part_1" target="_blank">this post about embedding DLR scripts in XAML</a> written by Daniel Paull.&#160; Wow, that is a lot of linking.</p>  <p>Well, now that everyone has been given their respective credit, let’s continue.&#160; I wanted to take my last post a little further.&#160; In that post I simply created an event handler for a button click event using inline code in the x:Code directive.&#160; If you started to play with the sample code, you might have thought to yourself, “I wonder if I can load this XAML, event handler and all, from a file or database and have it still work.”.&#160; Well, if you tried it, you found the answer really quick.&#160; No!&#160; The reason is pretty simple; code must be compiled in order to execute.&#160; Therefore any code inside loose XAML will fail.&#160; Also, when using loose XAML, trying to hookup an event handler would crash your application because it is not allowed.</p>  <p>Oh, then it must not be possible? Wrong!&#160; Well, then how do you do it if the code must be compiled?&#160; Simple, we compile the code just before we run it.&#160; Say what?&#160; That’s right, let me introduce you to the <a href="http://msdn.microsoft.com/en-us/library/y2k85ax6.aspx" target="_blank">CodeDom</a>.&#160; The CodeDom allows you to dynamically generate and compile code at runtime.&#160; Let’s get to it.</p>  <p>We need to attach event handlers to elements in loose XAML, and have them execute C# code.&#160; Each element has different events to handle, and each event will execute different code.&#160; This tells me that we need an object that contains two properties, one to specify the RoutedEvent to handle, and another to specify the c# code to execute.&#160; We also need a common event handler definition to execute whenever the RoutedEvent is invoked.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2c257533-76d5-4e97-9754-1b389f8f52b5" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">DynamicEvent</span><br> {<br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the routed event to execute.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The routed event.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#2b91af">RoutedEvent</span> RoutedEvent { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Gets or sets the script to run when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;value&gt;</span><span style="color:#008000">The script.</span><span style="color:#808080">&lt;/value&gt;</span><br>     <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> Script { <span style="color:#0000ff">get</span>; <span style="color:#0000ff">set</span>; }<br> <br> <br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> Called when the RoutedEvent is executed.</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br>     <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br>     {<br>         <br>     }<br> }</div> </div> </div>  <p>That was simple enough.&#160; Now, in order to attach event handlers to elements in loose XAML, we need away to get around the “no event handlers allowed” limitation.&#160; To do this we can use an attached property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c6021e-2311-4633-85f8-8fcb27a9cb89" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">readonly</span> <span style="color:#2b91af">DependencyProperty</span> HandlerProperty = <span style="color:#2b91af">DependencyProperty</span>.RegisterAttached(<span style="color:#a31515">&quot;Handler&quot;</span>, <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">typeof</span>(<span style="color:#2b91af">DynamicEvent</span>), <span style="color:#0000ff">new</span> <span style="color:#2b91af">UIPropertyMetadata</span>(OnHandlerChanged));<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">DynamicEvent</span> GetHandler(<span style="color:#2b91af">DependencyObject</span> obj)<br> {<br>     <span style="color:#0000ff">return</span> (<span style="color:#2b91af">DynamicEvent</span>)obj.GetValue(HandlerProperty);<br> }<br> <span style="color:#0000ff">public</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> SetHandler(<span style="color:#2b91af">DependencyObject</span> obj, <span style="color:#0000ff">bool</span> value)<br> {<br>     obj.SetValue(HandlerProperty, value);<br> }<br> <br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> OnHandlerChanged(<span style="color:#2b91af">DependencyObject</span> o, <span style="color:#2b91af">DependencyPropertyChangedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">UIElement</span> uie = o <span style="color:#0000ff">as</span> <span style="color:#2b91af">UIElement</span>;<br>     <span style="color:#0000ff">if</span> (uie == <span style="color:#0000ff">null</span>)<br>         <span style="color:#0000ff">throw</span> <span style="color:#0000ff">new</span> <span style="color:#2b91af">Exception</span>(<span style="color:#a31515">&quot;Attempt to set EventHandler on non-UIElement Type&quot;</span>);<br> <br>     <span style="color:#2b91af">DynamicEvent</span> oldHandler = e.OldValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br>     <span style="color:#2b91af">DynamicEvent</span> newHandler = e.NewValue <span style="color:#0000ff">as</span> <span style="color:#2b91af">DynamicEvent</span>;<br> <br>     <span style="color:#008000">// unhook the old event</span><br>     <span style="color:#0000ff">if</span> (oldHandler != <span style="color:#0000ff">null</span>)<br>         uie.RemoveHandler(oldHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(oldHandler.OnEventExecuted));<br> <br>     <span style="color:#008000">// hook up the new</span><br>     <span style="color:#0000ff">if</span> (newHandler != <span style="color:#0000ff">null</span>)<br>         uie.AddHandler(newHandler.RoutedEvent, <span style="color:#0000ff">new</span> <span style="color:#2b91af">RoutedEventHandler</span>(newHandler.OnEventExecuted));<br> <br> }</div> </div> </div>  <p>This attached property allows use to attach an instance of our DynamicEvent class to our element.&#160; When the Handler attached property is set, we simple add our OnEventExecute event handler to the RoutedEvent specified in the RoutedEvent property.&#160; Now we have the basic framework needed to attach and event handler to any event on any element in loose XAML.&#160; Let’s see how to attach an event handler in XAML using this newly created DynamicEvent class.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c323adca-e880-4dd4-997e-958bccc70c3d" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">Button</span><span style="color:#ff0000"> Height</span><span style="color:#0000ff">=&quot;24&quot;</span><span style="color:#ff0000"> Content</span><span style="color:#0000ff">=&quot;Initial Text&quot;&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#ff0000"> RoutedEvent</span><span style="color:#0000ff">=&quot;Button.Click&quot;&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>                 <span style="color:#a31515"></span><span style="color:#0000ff">&lt;</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#ff0000"> xml</span><span style="color:#0000ff">:</span><span style="color:#ff0000">space</span><span style="color:#0000ff">=&quot;preserve&quot;&gt;</span><br>                         <span style="color:#a31515"></span><span style="color:#808080">&lt;![CDATA[            </span><br>                         <span style="color:#808080">var button = sender as Button;</span><br>                         <span style="color:#808080">button.Content = &quot;Changed with Dynamic Code&quot;;</span><br>                         <span style="color:#808080">]]&gt;</span><br>                     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">sys</span><span style="color:#0000ff">:</span><span style="color:#a31515">String</span><span style="color:#0000ff">&gt;</span><br>             <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Script</span><span style="color:#0000ff">&gt;</span><br>         <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent</span><span style="color:#0000ff">&gt;</span><br>     <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">local</span><span style="color:#0000ff">:</span><span style="color:#a31515">DynamicEvent.Handler</span><span style="color:#0000ff">&gt;</span><br> <span style="color:#a31515"></span><span style="color:#0000ff">&lt;/</span><span style="color:#a31515">Button</span><span style="color:#0000ff">&gt;</span></div> </div> </div>  <p>As you can see I have added a handler for a Button’s Click event.&#160; I also provided a Script to execute when the event is invoked.&#160; Notice that we are preserving the whitespace in the script.&#160; Of course nothing will happen just yet.&#160; Now we need to take the script and compile it at run time.&#160; This is where the CodeDom comes in.</p>  <p>The steps necessary to compile code at run time go a little something like this:</p>  <ul>   <li>Create a CodeCompileUnit </li>    <li>Add our namespace and import statements </li>    <li>create our dynamic class </li>    <li>add a method that will execute the Script </li>    <li>compile the code </li>    <li>execute the code </li> </ul>  <p>All these steps must be performed when the ROutedEvent is invoked, which means the code must be compiled inside the OnEventExecuted event handler.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:56b1a794-ec6b-4976-9f18-e819f5a52641" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> OnEventExecuted(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#2b91af">CodeCompileUnit</span> compileUnit = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeCompileUnit</span>();<br> <br>     <span style="color:#008000">//create our namesapce and import statements, then add it to the compile unit</span><br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = CreateNamespaceAndImports();<br>     compileUnit.Namespaces.Add(namespaces);<br> <br>     <span style="color:#008000">//create our target class and add it to the namespace</span><br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = CreateTargetClass();<br>     namespaces.Types.Add(targetClass);<br> <br>     <span style="color:#008000">//create the ExecuteScript method and then add it to our class</span><br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = CreateExecuteScriptMethod();<br>     targetClass.Members.Add(executeEventMethod);<br> <br>     <span style="color:#008000">//create our compiler parameters</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = CreateCompilerParameters();<br> <br>     <span style="color:#008000">//compile the assembly</span><br>     <span style="color:#0000ff">var</span> results = CompileAssembly(compileUnit, compilerParams);<br> <br>     <span style="color:#008000">//execute the code</span><br>     ExecuteCode(results, sender, e);<br> }</div> </div> </div>  <p>The first step is really easy.&#160; We simply need to create an instance of the CodeCompileUnit class.&#160; The CodeCompileUnit references the CodeDom object graph and has properties for storing attributes, namespaces, and assemblies.&#160; Next we need to create our namespace and import statements.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6b89b170-e94b-4b3b-a8d8-8df82193e6d3" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the namespace and imports.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;remarks&gt;</span><span style="color:#008000">I have only added three import statements as an example. You should add all import statements required to run your dynamic code</span><span style="color:#808080">&lt;/remarks&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeNamespace</span> CreateNamespaceAndImports()<br> {<br>     <span style="color:#2b91af">CodeNamespace</span> namespaces = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespace</span>(<span style="color:#a31515">&quot;WPFCodeInjection&quot;</span>);<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows&quot;</span>));<br>     namespaces.Imports.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeNamespaceImport</span>(<span style="color:#a31515">&quot;System.Windows.Controls&quot;</span>));<br>     <span style="color:#0000ff">return</span> namespaces;<br> }</div> </div> </div>  <p>Once the namespace and import statement are created we need to add them to out CodeCompileUnit instance.&#160; Then we need to create our dynamic class.&#160; We need to make sure it is a public class:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a495da08-da32-46e0-ba99-c5fac5d189e1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the target class.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CodeTypeDeclaration</span> CreateTargetClass()<br> {<br>     <span style="color:#2b91af">CodeTypeDeclaration</span> targetClass = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeTypeDeclaration</span>(<span style="color:#a31515">&quot;DynamicClass&quot;</span>);<br>     targetClass.TypeAttributes = <span style="color:#2b91af">TypeAttributes</span>.Public;<br>     <span style="color:#0000ff">return</span> targetClass;<br> }</div> </div> </div>  <p>When the dynamic class is created we add it to our namespace.&#160; Now we create a method. We give it a name of ExecuteScript and set its access modifier to public.&#160; We specify that it accepts two parameters.&#160; One being the sender which is of type object, and one that is the event args that is of type RoutedEventArgs.&#160; Lastly, we set the body of the method to the Script property.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:4cae0858-7130-4df1-b3b1-cf49063a4d50" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the ExecuteScript method.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#2b91af">CodeMemberMethod</span> CreateExecuteScriptMethod()<br> {<br>     <span style="color:#2b91af">CodeMemberMethod</span> executeEventMethod = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeMemberMethod</span>();<br>     executeEventMethod.Name = <span style="color:#a31515">&quot;ExecuteScript&quot;</span>;<br>     executeEventMethod.Attributes = <span style="color:#2b91af">MemberAttributes</span>.Public | <span style="color:#2b91af">MemberAttributes</span>.Final;<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Object&quot;</span>, <span style="color:#a31515">&quot;sender&quot;</span>));<br>     executeEventMethod.Parameters.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeParameterDeclarationExpression</span>(<span style="color:#a31515">&quot;System.Windows.RoutedEventArgs&quot;</span>, <span style="color:#a31515">&quot;e&quot;</span>));<br>     executeEventMethod.Statements.Add(<span style="color:#0000ff">new</span> <span style="color:#2b91af">CodeSnippetStatement</span>(Script));<br>     <span style="color:#0000ff">return</span> executeEventMethod;<br> }</div> </div> </div>  <p>Now we have to create our compiler parameters.&#160; These include adding referencing to the necessary Dlls required to run your code.&#160; We also want to specify that we want to generate the code in memory.&#160; If you wanted to you could save the assembly to a file.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:cebbac90-1864-436d-8248-de681876fa83" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Creates the compiler parameters.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerParameters</span> CreateCompilerParameters()<br> {<br>     <span style="color:#008000">//add compiler parameters and assembly references</span><br>     <span style="color:#2b91af">CompilerParameters</span> compilerParams = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CompilerParameters</span>();<br>     compilerParams.CompilerOptions = <span style="color:#a31515">&quot;/target:library /optimize&quot;</span>;<br>     compilerParams.GenerateExecutable = <span style="color:#0000ff">false</span>;<br>     compilerParams.GenerateInMemory = <span style="color:#0000ff">true</span>;<br> <br>     <span style="color:#008000">//you can add references individually if you want by providing the location of the assembly</span><br>     <span style="color:#008000">//compilerParams.ReferencedAssemblies.Add(&quot;System.dll&quot;);</span><br> <br>     <span style="color:#008000">//I am lazy so I will just loop through the assemblies that are already loaded and add those</span><br>     <span style="color:#0000ff">foreach</span> (<span style="color:#2b91af">Assembly</span> assembly <span style="color:#0000ff">in</span> <span style="color:#2b91af">AppDomain</span>.CurrentDomain.GetAssemblies())<br>     {<br>         <span style="color:#0000ff">try</span><br>         {<br>             <span style="color:#0000ff">string</span> location = assembly.Location;<br>             <span style="color:#0000ff">if</span> (!<span style="color:#2b91af">String</span>.IsNullOrEmpty(location))<br>                 compilerParams.ReferencedAssemblies.Add(location);<br>         }<br>         <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">NotSupportedException</span>)<br>         {<br>             <span style="color:#008000">// this happens for dynamic assemblies, so just ignore it.                     </span><br>         }<br>     }<br> <br>     <span style="color:#0000ff">return</span> compilerParams;<br> }</div> </div> </div>  <p>Now we compile the code into an assembly.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b05d391c-e1d9-47c3-b9b3-2c147f47e7bb" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Compiles the assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compileUnit&quot;&gt;</span><span style="color:#008000">The compile unit.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;compilerParams&quot;&gt;</span><span style="color:#008000">The compiler params.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#2b91af">CompilerResults</span> CompileAssembly(<span style="color:#2b91af">CodeCompileUnit</span> compileUnit, <span style="color:#2b91af">CompilerParameters</span> compilerParams)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">CSharpCodeProvider</span> provider = <span style="color:#0000ff">new</span> <span style="color:#2b91af">CSharpCodeProvider</span>())<br>     {<br>         <span style="color:#008000">// =============================================================================== //</span><br>         <span style="color:#008000">// if you want to see the actual complied source code uncomment //</span><br>         <span style="color:#008000">// =============================================================================== //</span><br> <br>         <span style="color:#008000">//StringBuilder source = new StringBuilder();</span><br>         <span style="color:#008000">//StringWriter sw = new StringWriter(source);</span><br>         <span style="color:#008000">//provider.GenerateCodeFromCompileUnit(compileUnit, sw, new CodeGeneratorOptions());</span><br>         <span style="color:#008000">//string sourceCode = source.ToString();</span><br> <br>         <span style="color:#0000ff">var</span> results = provider.CompileAssemblyFromDom(compilerParams, compileUnit);<br>         <span style="color:#0000ff">return</span> results;<br>     }<br> }</div> </div> </div>  <p>The last thing we need to do is run the code that was just compiled.&#160; We will need the help of reflection to accomplish this.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:09c68e9b-98f4-4334-aa9f-ecf464569e54" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> Executes the ExecuteScript method from the compiled CodeDom assembly.</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;/summary&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;results&quot;&gt;</span><span style="color:#008000">The results.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;sender&quot;&gt;</span><span style="color:#008000">The sender.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#808080">///</span><span style="color:#008000"> </span><span style="color:#808080">&lt;param name=&quot;e&quot;&gt;</span><span style="color:#008000">The </span><span style="color:#808080">&lt;see cref=&quot;System.Windows.RoutedEventArgs&quot;/&gt;</span><span style="color:#008000"> instance containing the event data.</span><span style="color:#808080">&lt;/param&gt;</span><br> <span style="color:#0000ff">private</span> <span style="color:#0000ff">void</span> ExecuteCode(<span style="color:#2b91af">CompilerResults</span> results, <span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">try</span><br>     {<br>         <span style="color:#2b91af">Assembly</span> executingAssembly = results.CompiledAssembly;<br>         <span style="color:#0000ff">if</span> (executingAssembly != <span style="color:#0000ff">null</span>)<br>         {<br>             <span style="color:#008000">//create an instance of our newly compiled assembly</span><br>             <span style="color:#0000ff">object</span> assemblyInstance = executingAssembly.CreateInstance(<span style="color:#a31515">&quot;WPFCodeInjection.DynamicClass&quot;</span>);<br> <br>             <span style="color:#008000">//get our ExecuteScript method and execute it.</span><br>             <span style="color:#2b91af">MethodInfo</span> info = assemblyInstance.GetType().GetMethod(<span style="color:#a31515">&quot;ExecuteScript&quot;</span>);<br>             info.Invoke(assemblyInstance, <span style="color:#0000ff">new</span> <span style="color:#0000ff">object</span>[] { sender, e });<br>         }<br>     }<br>     <span style="color:#0000ff">catch</span> (<span style="color:#2b91af">Exception</span> ex)<br>     {<br>         <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Error: An exception occurred while executing the script&quot;</span>, ex);<br>     }<br> }</div> </div> </div>  <p>That is it.&#160; Now to test this out lets create a .txt file that contains our XAML that we define above and save it CodeSnippet.txt.&#160; In our MainWindow.xaml.cs, lets handle the Loaded event and load our CodeSnippet.txt using the XamlReader.Load method.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc56e72c-6fdc-4430-afb5-4498031c46f1" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="color:#0000ff">void</span> MainWindow_Loaded(<span style="color:#0000ff">object</span> sender, <span style="color:#2b91af">RoutedEventArgs</span> e)<br> {<br>     <span style="color:#0000ff">using</span> (<span style="color:#2b91af">FileStream</span> fs = <span style="color:#0000ff">new</span> <span style="color:#2b91af">FileStream</span>(<span style="color:#a31515">@&quot;./CodeSnippet.txt&quot;</span>, <span style="color:#2b91af">FileMode</span>.Open))<br>     {<br>         <span style="color:#0000ff">this</span>.Content = <span style="color:#2b91af">XamlReader</span>.Load(fs);<br>     }<br> }</div> </div> </div>  <p>Run the application is this is what it should look like.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image9.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb9.png" width="174" height="179" /></a></p>  <p>Now click the button and our C# code defined within the Script property will be dynamically compiled and executed changed the text of the button to this:</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2010/12/image10.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2010/12/image_thumb10.png" width="184" height="179" /></a></p>  <p>This is a very simple example and is not intended to be a complete solution, but it does show some of the powerful capabilities you have using WPF, XAML, and the CodeDom.&#160; Like always <a href="http://brianlagunas.com/downloads/source/WpfCodeInjection.zip">download the source</a> and start playing around.&#160; See what kind of cool stuff you can do with it.</p>]]></content:encoded>
			<wfw:commentRss>http://elegantcode.com/2010/12/21/wpf-dynamically-compile-and-run-event-handlers-within-loose-xaml-using-codedom/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Elegant Code &#187; xaml</title>
	<atom:link href="http://elegantcode.com/tag/xaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com</link>
	<description></description>
	<lastBuildDate>Tue, 15 May 2012 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Buy Betnovate Without Prescription</title>
		<link>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=create-your-first-winrt-watermarktextbox-control</link>
		<comments>http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 20:44:05 +0000</pubDate>
		<dc:creator>Brian Lagunas</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[winrt]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://elegantcode.com/2012/03/06/create-your-first-winrt-watermarktextbox-control/</guid>
		<description><![CDATA[Unless you have been living under a rock the past few days you already know about the recent release of Windows 8 Consumer Preview and Visual Studio 11 Beta Buy Betnovate Without Prescription, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to [...]]]></description>
			<content:encoded><![CDATA[<p> <p>Unless you have been living under a rock the past few days you already know about the recent release of <a href="http://windows.microsoft.com/en-US/windows-8/consumer-preview" target="_blank">Windows 8 Consumer Preview</a> and <a href="http://www.microsoft.com/visualstudio/11/en-us/downloads" target="_blank">Visual Studio 11 Beta</a> <b>Buy Betnovate Without Prescription</b>, .&#160; Since I know you already downloaded and installed all the shiny new toys, let’s take a quick look at how to get started writing a custom control for the new metro style applications.&#160; There is no better control to start with than the ever popular WatermarkTextBox control.</p>  <h4>Setting up the Solution</h4>  <p>First start off by creating a new metro style application in Visual Studio 11 beta.&#160; A blank application will work just fine for our purposes.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image1.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="394" /></a></p>  <p>When your solution loads right click the project and select&quot; “Add New Item”.&#160; When the dialog appears choose the “Template Control” item template.&#160; Of course give it a name of WatermarkTextBox.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image2.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="394" /></a></p>  <p>You will notice that the Template control is just like a Silverlight or WPF custom control.&#160; It comes with a class file and a corresponding style in the Generic.xaml file.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image3.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb3.png" width="288" height="371" /></a></p>  <h4>Writing the Control</h4>  <p>Our WatermarkTextBox control is going to derive from the TextBox class that is already provided by Microsoft.</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9e5d5c90-24fd-472a-a206-1342f112d743" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">sealed</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#0000ff">class</span><span style="background:#ffffff;color:#000000"> </span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000"> : </span><span style="background:#ffffff;color:#2b91af">TextBox</span><br> <span style="background:#ffffff;color:#000000">{</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">public</span><span style="background:#ffffff;color:#000000"> WatermarkTextBox()</span><br>     <span style="background:#ffffff;color:#000000">{</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">this</span><span style="background:#ffffff;color:#000000">.DefaultStyleKey = </span><span style="background:#ffffff;color:#0000ff">typeof</span><span style="background:#ffffff;color:#000000">(</span><span style="background:#ffffff;color:#2b91af">WatermarkTextBox</span><span style="background:#ffffff;color:#000000">);</span><br>     <span style="background:#ffffff;color:#000000">}</span><br> <span style="background:#ffffff;color:#000000">}</span></div> </div> </div>  <p>Having said that, we don’t want to reinvent the wheel when it comes to styling the TextBox we are deriving from.&#160; So let’s save some time by dropping a TextBox onto the BlankPage.xaml page.&#160; Now right click the TextBox on the design surface and select “Edit Template –&gt; Edit a Copy”.&#160; This will create the default TextBlock style that we can use in our WatermarkTextBox ControlTemplate.</p>  <p><a href="http://elegantcode.com/wp-content/uploads/2012/03/image4.png"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://elegantcode.com/wp-content/uploads/2012/03/image_thumb4.png" width="403" height="459" /></a></p>  <p>Now open up the Generic.xaml file and replace this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bfe3553a-3424-479e-bc5a-6aa2734cf447" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background-color: #ffffff; max-height: 300px; overflow: auto; padding: 2px 5px; white-space: nowrap"><span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#ff0000"> Property</span><span style="background:#ffffff;color:#0000ff">=&quot;Template&quot;&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#ff0000"> TargetType</span><span style="background:#ffffff;color:#0000ff">=&quot;local:WatermarkTextBox&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;</span><span style="background:#ffffff;color:#a31515">Border</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> Background</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> Background}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderBrush</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderBrush}</span><span style="background:#ffffff;color:#0000ff">&quot;</span><br>                    <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#ff0000"> BorderThickness</span><span style="background:#ffffff;color:#0000ff">=&quot;{</span><span style="background:#ffffff;color:#a31515">TemplateBinding</span><span style="background:#ffffff;color:#ff0000"> BorderThickness}</span><span style="background:#ffffff;color:#0000ff">&quot;&gt;</span><br>                 <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Border</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>             <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">ControlTemplate</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>         <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter.Value</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br>     <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Setter</span><span style="background:#ffffff;color:#0000ff">&gt;</span><br> <span style="background:#ffffff;color:#000000"></span><span style="background:#ffffff;color:#0000ff">&lt;/</span><span style="background:#ffffff;color:#a31515">Style</span><span style="background:#ffffff;color:#0000ff">&gt;</span></div> </div> </div>  <p>With this:</p>  <div id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:739afa4b-520d-4687-b6b9-afbfbafefb7d" class="wlWrit
