Ken Tucker Ken Tucker's Silverlight Help Blog http://silverlight-help.com/Tips/KenTucker.aspx http://backend.userland.com/rss Silverlight 3 Could Not download the silverlight Application <p>I created a simple Silverlight 3 app.</p> <p>&#160;</p> <p>&lt;UserControl x:Class=&quot;SilverlightApplication2.MainPage&quot; <br />&#160;&#160;&#160; xmlns=&quot;<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;">http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;</a> <br />&#160;&#160;&#160; xmlns:x=&quot;<a href="http://schemas.microsoft.com/winfx/2006/xaml&quot;">http://schemas.microsoft.com/winfx/2006/xaml&quot;</a> <br />&#160;&#160;&#160; xmlns:d=&quot;<a href="http://schemas.microsoft.com/expression/blend/2008&quot;">http://schemas.microsoft.com/expression/blend/2008&quot;</a> xmlns:mc=&quot;<a href="http://schemas.openxmlformats.org/markup-compatibility/2006&quot;">http://schemas.openxmlformats.org/markup-compatibility/2006&quot;</a> <br />&#160;&#160;&#160; mc:Ignorable=&quot;d&quot; d:DesignWidth=&quot;640&quot; d:DesignHeight=&quot;480&quot;&gt; <br />&#160;&#160;&#160; &lt;Grid x:Name=&quot;LayoutRoot&quot;&gt; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;TextBlock Text=&quot;Hello World!&quot; &gt;&lt;/TextBlock&gt; <br />&#160;&#160;&#160; &lt;/Grid&gt; <br />&lt;/UserControl&gt;</p> <p>&#160;</p> <p>When I run it I get this error</p> <p><a href="http://www.silverlight-help.com/Libraries/MetaBlogLib/WindowsLiveWriter-Silverlight3CouldNotdownloadthesilverlig_5FF5-image_2.sflb.ashx"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.silverlight-help.com/Libraries/MetaBlogLib/WindowsLiveWriter-Silverlight3CouldNotdownloadthesilverlig_5FF5-image_thumb.sflb.ashx" width="244" height="163" /></a> </p> <p>Line: 56 <br />Error: Unhandled Error in Silverlight Application <br />Code: 2104&#160;&#160;&#160; <br />Category: InitializeError&#160;&#160;&#160;&#160;&#160;&#160; <br />Message: Could not download the Silverlight application. Check web server settings&#160;&#160;&#160; </p> <p>&#160;</p> <p>Well if you look in the ClientBin folder you will see it is empty so the xap file is not available to be used</p> <p>&#160;</p> <p>To fix this right click on the web application and select Build Order.&#160; On the Dependencies tab make sure the Checkbox next to the Silverlight app is checked.</p> <p><a href="http://www.silverlight-help.com/Libraries/MetaBlogLib/WindowsLiveWriter-Silverlight3CouldNotdownloadthesilverlig_5FF5-image_4.sflb.ashx"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.silverlight-help.com/Libraries/MetaBlogLib/WindowsLiveWriter-Silverlight3CouldNotdownloadthesilverlig_5FF5-image_thumb_1.sflb.ashx" width="244" height="233" /></a></p> http://silverlight-help.com/Tips/KenTucker/09-07-15/Silverlight_3_Could_Not_download_the_silverlight_Application.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-07-15/Silverlight_3_Could_Not_download_the_silverlight_Application.aspx a57cd687-20d8-4584-947a-209084eda88c Wed, 15 Jul 2009 05:47:15 GMT John Papa speaking at Space Coast .Net <h5><a _tesavedurl="http://www.scdnug.org/#" href="http://www.scdnug.org/#">John Papa - Ado.Net Data Services</a></h5> <p>6/17/2009 6:30:00 PM </p> <p>6/17/2009 8:00:00 PM </p> <h3>About</h3> <p><a _tesavedurl="http://johnpapa.net/files/media/image/WindowsLiveWriter/About_AF62/jp2_2.jpg" href="http://johnpapa.net/files/media/image/WindowsLiveWriter/About_AF62/jp2_2.jpg"><img height="133" width="100" _tesavedurl="http://johnpapa.net/files/media/image/WindowsLiveWriter/About_AF62/jp2_thumb.jpg" src="http://johnpapa.net/files/media/image/WindowsLiveWriter/About_AF62/jp2_thumb.jpg" alt="jp2" title="jp2" /></a> </p> <p>John Papa is a <a _tesavedurl="https://mvp.support.microsoft.com/profile=7D3BBCB7-E956-4730-B3E0-24BD7EAD0D5D" href="https://mvp.support.microsoft.com/profile=7D3BBCB7-E956-4730-B3E0-24BD7EAD0D5D">Microsoft C# MVP</a>, <a _tesavedurl="http://www.ineta.org/DesktopDefault.aspx?tabindex=2&amp;tabid=14" href="http://www.ineta.org/DesktopDefault.aspx?tabindex=2&amp;tabid=14">INETA speaker</a>, member of the WPF and Silverlight Insiders, consultant, speaker, author, and trainer for <a _tesavedurl="http://www.aspsoft.com/" href="http://www.aspsoft.com/">ASPSOFT</a> who specializes in professional application development with Microsoft technologies including Silverlight, WPF, C#, .NET and SQL Server. John has written over 70 articles and authored 9 books including his latest book <a _tesavedurl="http://www.amazon.com/exec/obidos/ASIN/0596523092/johnpanet-20" href="http://www.amazon.com/exec/obidos/ASIN/0596523092/johnpanet-20">Data Driven Services with Silverlight 2</a> by O’Reilly Media. John is currently working on a follow up to his Silverlight book, with a working title of Silverlight for Business. </p> <p>He can often be found speaking at industry conferences such as <a _tesavedurl="http://www.visitmix.com/" href="http://www.visitmix.com/">MIX</a>,&nbsp; <a _tesavedurl="http://www.vslive.com/" href="http://www.vslive.com/">VSLive</a> and <a _tesavedurl="http://www.devconnections.com/" href="http://www.devconnections.com/">DevConnections</a>, speaking at user groups around the country, and viewed on MSDN Web Casts. John also spearheaded the 1<sup>st</sup> annual Silverlight MIXer, a gathering of some of the most influential members of the Silverlight community for a great night a MIX09. You can always find John at <a _tesavedurl="http://www.johnpapa.net/" href="http://www.johnpapa.net/">johnpapa.net</a>. </p> <p>John Papa will be showing Astoria using Silverlight 3 beta as the client. </p> <p>ADO.NET Data Services (codenamed Astoria) exposes entity models through RESTful services. It can dramatically simplify the code required to expose business objects through web services and reduce a tremendous amount of code. This session will show how to expose entity models using ADO.NET Data Services, how to consume and save data, and how to debug the communications using various tools. When the technology does not quite do what you need out of the box, it also allows for customizations to create custom service operations, intercept queries, and enforce permissions. Attendees will walk away with an understanding of the capabilities of ADO.NET Data Services, how to use them with Silverlight, and when and where it is ideal to use in an application architecture and when there are better options. </p> <p>Street: 8045 N. Wickham Road <br /> City: melbourne<br /> Country: USA<br /> State: Florida </p> http://silverlight-help.com/Tips/KenTucker/09-06-15/John_Papa_speaking_at_Space_Coast_Net.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-06-15/John_Papa_speaking_at_Space_Coast_Net.aspx abd427d3-d35e-4afd-b731-aaabb02914ae Mon, 15 Jun 2009 11:56:00 GMT 2009 Orlando Code Camp <p>I attended and spoke at the 2009 Orlando Code Camp today.  Thanks Jessica and Fabio for doing such a great job organizing the code camp.  There were some really great speakers there today.  There was some great silverlight content at todays code camp</p> <p><a href="http://www.orlandocodecamp.com/">http://www.orlandocodecamp.com/</a></p> <p>&nbsp;</p> <p>You can download the slides and sample code from my Silverlight 2 Databinding presentation here</p> <p><a href="http://www.silverlight-help.com/Libraries/Downloads/Silverlight_DataBinding.sflb.ashx?download=true">http://www.silverlight-help.com/Libraries/Downloads/Silverlight_DataBinding.sflb.ashx?download=true</a></p> <p>&nbsp;</p> http://silverlight-help.com/Tips/KenTucker/09-03-28/2009_Orlando_Code_Camp.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-03-28/2009_Orlando_Code_Camp.aspx e09b3275-663a-4010-96d1-af788eb14bec Sat, 28 Mar 2009 19:43:49 GMT Formatting bound data in Silverlight 2 <p>To format a bound item you need to use a class that implements the IValueConverter interface.</p> <p>&#160;</p> <p>First lets create a simple class to bind to</p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:779ac1d6-8ac2-4e2b-b270-af796490f439" class="wlWriterEditableSmartContent"><pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4; toolbar: true; "> public class BindTo : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } private string _Name; public string Name { get { return _Name; } set { if (value != _Name) { _Name = value; NotifyPropertyChanged(&quot;Name&quot;); } } } private double _Price; public double Price { get { return _Price; } set { if (value != _Price) { _Price = value; NotifyPropertyChanged(&quot;Price&quot;); } } } }</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160;</p> <p>Now lets create the IValueConverter to display the price as currency. The convert has 2 functions we must implement&#160; Convert and ConvertBack. In covert we will convert the decimal to a string.&#160; In the convertBack we will remove the $ so the text can be converted to a decimal</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:0a09619b-b157-44e8-b378-9850719f36d5" class="wlWriterEditableSmartContent"><pre class="brush: csharp; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Data; using System.Globalization; namespace SilverlightApplication8 { public class CurrencyConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { double d; if (double.TryParse(value.ToString(), out d)) { if (d &gt;= 0.0) { return d.ToString(&quot;c&quot;); } } return value; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { double d; string s = value.ToString(); if (s.StartsWith(&quot;$&quot;)) { s = s.Substring(1); } if (double.TryParse(s, out d)) { return d; } return value; } } } </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160;</p> <p>To use an IValueConverter we need to register it as a StaticResource for the page</p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:b04cbaf9-ad58-448d-a99b-44039935f119" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; "> &lt;UserControl.Resources&gt; &lt;local:CurrencyConverter x:Key=&quot;MyConverter&quot;&gt;&lt;/local:CurrencyConverter&gt; &lt;/UserControl.Resources&gt;</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160;</p> <p>In the binding we can specify the converter</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:275142f1-57dc-448e-8dd3-10f062fadcb2" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; "> &lt;TextBox Text=&quot;{Binding Price, Mode=TwoWay, Converter={StaticResource MyConverter}, NotifyOnValidationError=true, ValidatesOnExceptions=true}&quot; Grid.Column=&quot;1&quot; Grid.Row=&quot;1&quot; Margin=&quot;5,5,5,120&quot;&gt;&lt;/TextBox&gt;</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>Pages complete xaml</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:6ec6972d-6f1c-4185-b7c2-43d5ff87c312" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;UserControl x:Class=&quot;SilverlightApplication8.Page&quot; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; xmlns:local=&quot;clr-namespace:SilverlightApplication8&quot; Width=&quot;400&quot; Height=&quot;300&quot;&gt; &lt;UserControl.Resources&gt; &lt;local:CurrencyConverter x:Key=&quot;MyConverter&quot;&gt;&lt;/local:CurrencyConverter&gt; &lt;/UserControl.Resources&gt; &lt;Grid x:Name=&quot;LayoutRoot&quot; Background=&quot;White&quot;&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition&gt;&lt;/ColumnDefinition&gt; &lt;ColumnDefinition&gt;&lt;/ColumnDefinition&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition&gt;&lt;/RowDefinition&gt; &lt;RowDefinition&gt;&lt;/RowDefinition&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock Text=&quot;Product Name&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;0&quot;&gt;&lt;/TextBlock&gt; &lt;TextBlock Text=&quot;Unit Price&quot; Grid.Column=&quot;0&quot; Grid.Row=&quot;1&quot;&gt;&lt;/TextBlock&gt; &lt;TextBox Text=&quot;{Binding Name, Mode=TwoWay}&quot; Grid.Column=&quot;1&quot; Grid.Row=&quot;0&quot; Margin=&quot;5,5,5,120&quot;&gt;&lt;/TextBox&gt; &lt;TextBox Text=&quot;{Binding Price, Mode=TwoWay, Converter={StaticResource MyConverter}, NotifyOnValidationError=true, ValidatesOnExceptions=true}&quot; Grid.Column=&quot;1&quot; Grid.Row=&quot;1&quot; Margin=&quot;5,5,5,120&quot;&gt;&lt;/TextBox&gt; &lt;/Grid&gt; &lt;/UserControl&gt;</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160;</p> <p></p> <p></p> <p></p> <p></p> <p>Here is the code for page which creates the object and binds it</p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:ee4fd1b5-32dc-4de9-acbd-6de38f407d35" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; "> public partial class Page : UserControl { BindTo b = new BindTo(); public Page() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Page_Loaded); } void Page_Loaded(object sender, RoutedEventArgs e) { b.Name=&quot;Apple Juice&quot;; b.Price = 1.39; LayoutRoot.DataContext = b; } }</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> http://silverlight-help.com/Tips/KenTucker/09-03-27/Formatting_bound_data_in_Silverlight_2.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-03-27/Formatting_bound_data_in_Silverlight_2.aspx bc9be671-bda0-4956-ad72-47005f314672 Fri, 27 Mar 2009 20:39:12 GMT Microsoft Patterns &amp; Practices&rsquo; Composite Application Guidance for WPF and Silverlight now in VB.NET! <p>The Patterns and Practices team has released VB versions of the Quick Starts, Hands on Labs, and How to Topics. You can download them here</p> <p>&#160;</p> <p><a title="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=537da1cd-43e1-4799-88e7-a1da9166fb46" href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=537da1cd-43e1-4799-88e7-a1da9166fb46">http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;FamilyID=537da1cd-43e1-4799-88e7-a1da9166fb46</a></p> http://silverlight-help.com/Tips/KenTucker/09-03-25/Microsoft_Patterns_amp_Practices_rsquo_Composite_Application_Guidance_for_WPF_and_Silverlight_now_in_VB_NET.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-03-25/Microsoft_Patterns_amp_Practices_rsquo_Composite_Application_Guidance_for_WPF_and_Silverlight_now_in_VB_NET.aspx 378c8d18-2c9f-49a6-ad70-af69780790a1 Wed, 25 Mar 2009 05:37:37 GMT Rendering problems with IE8 <p>Microsoft released IE8 during Mix 2009.&#160; Microsoft spent a lot of time making IE8 comply with the browser standards.&#160; When you upgrade your browser to IE8 if you find the web site does not render right.&#160; Do not worry there is a simple fix for this.&#160; </p> <p>&#160;</p> <p>There is a tag you can place in the Head section of your webpage which will force IE8 into IE7 compatibility mode.</p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:eda71b80-bc51-4870-aeaf-3053dda77d82" class="wlWriterEditableSmartContent"><pre class="brush: plain; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;html&gt; &lt;head&gt; &lt;!-- Mimic Internet Explorer 7 --&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=EmulateIE7&quot; /&gt; &lt;title&gt;My Web Page&lt;/title&gt; &lt;/head&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160;</p> <p>&#160;</p> <p> <br />For more info on IE8 compatibility read this article </p> <p><a href="http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx">http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx</a></p> <p>&#160;</p> <p>Hope this helps</p> http://silverlight-help.com/Tips/KenTucker/09-03-24/Rendering_problems_with_IE8.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-03-24/Rendering_problems_with_IE8.aspx b54cc478-74b3-422e-896a-1f5151204e62 Tue, 24 Mar 2009 20:17:02 GMT Silverlight 2.0 Interacting with html <p>With SilverLight 2.0 you can interact and handle events with the html elements on your page.&#160; Here is a simple example that places a select (drop down control) on a web page which will change the color of a ellipse on a SilverLight app.&#160; So lets start with the html</p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:e1b1bef2-4d64-4308-aa56-65e61acc323a" class="wlWriterEditableSmartContent"><pre class="brush: plain; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;body style=&quot;height: 100%; margin: 0;&quot;&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot; style=&quot;height: 100%;&quot;&gt; &lt;asp:ScriptManager ID=&quot;ScriptManager1&quot; runat=&quot;server&quot;&gt; &lt;/asp:ScriptManager&gt; &lt;br /&gt; &lt;span&gt;Select a Color &lt;/span&gt; &lt;select id=&quot;ddColor&quot;&gt; &lt;option&gt;Red&lt;/option&gt; &lt;option&gt;Blue&lt;/option&gt; &lt;option&gt;Green&lt;/option&gt; &lt;/select&gt; &lt;br /&gt; &lt;br /&gt; &lt;div style=&quot;height: 100%;&quot;&gt; &lt;asp:Silverlight ID=&quot;Xaml1&quot; runat=&quot;server&quot; Source=&quot;~/ClientBin/HtmlAndSilverlight.xap&quot; MinimumVersion=&quot;2.0.30923.0&quot; Width=&quot;100%&quot; Height=&quot;100%&quot; /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160;</p> <p>&#160;</p> <p>Now the XAML</p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:4882ec46-b917-46fe-b325-913ae03dfb78" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;body style=&quot;height: 100%; margin: 0;&quot;&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot; style=&quot;height: 100%;&quot;&gt; &lt;asp:ScriptManager ID=&quot;ScriptManager1&quot; runat=&quot;server&quot;&gt; &lt;/asp:ScriptManager&gt; &lt;br /&gt; &lt;span&gt;Select a Color &lt;/span&gt; &lt;select id=&quot;ddColor&quot;&gt; &lt;option&gt;Red&lt;/option&gt; &lt;option&gt;Blue&lt;/option&gt; &lt;option&gt;Green&lt;/option&gt; &lt;/select&gt; &lt;br /&gt; &lt;br /&gt; &lt;div style=&quot;height: 100%;&quot;&gt; &lt;asp:Silverlight ID=&quot;Xaml1&quot; runat=&quot;server&quot; Source=&quot;~/ClientBin/HtmlAndSilverlight.xap&quot; MinimumVersion=&quot;2.0.30923.0&quot; Width=&quot;100%&quot; Height=&quot;100%&quot; /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160;</p> <p>&#160;</p> <p>Now build the app so we have intellisense for the controls.&#160; Ok first off lets get access to the drop down (select) on the web page. Then we can use AttachEvent to handle the onchange event.&#160;&#160;&#160; </p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:54c3354f-86f8-4ed9-927c-a75941d2c6dd" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Dim cbo As HtmlElement Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded cbo = HtmlPage.Document.GetElementById(&quot;ddColor&quot;) cbo.AttachEvent(&quot;onchange&quot;, AddressOf ColorChanged) End Sub </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160; </p> <p>Once the user selects a color we will change the color of the ellipse.&#160; Here is the complete code listing </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:1646d533-61de-48c1-b008-eade7046e236" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Imports System.Windows.Browser Partial Public Class Page Inherits UserControl Public Sub New() InitializeComponent() End Sub Dim cbo As HtmlElement Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded cbo = HtmlPage.Document.GetElementById(&quot;ddColor&quot;) cbo.AttachEvent(&quot;onchange&quot;, AddressOf ColorChanged) End Sub Private Sub ColorChanged(ByVal sender As Object, ByVal e As HtmlEventArgs) Dim x = CInt(cbo.GetAttribute(&quot;selectedIndex&quot;).ToString) Select Case x Case 0 el.Fill = New SolidColorBrush(Colors.Red) Case 1 el.Fill = New SolidColorBrush(Colors.Blue) Case 2 el.Fill = New SolidColorBrush(Colors.Green) End Select End Sub End Class </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p></p> <p>&#160;</p> <p>Hope this helps</p> http://silverlight-help.com/Tips/KenTucker/09-03-11/Silverlight_2_0_Interacting_with_html.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-03-11/Silverlight_2_0_Interacting_with_html.aspx 61f34837-8970-4dd2-981f-e898517d04a9 Wed, 11 Mar 2009 01:00:00 GMT Silverlight 2 GDR released <p>This week Microsoft Release an GDR to silverlight 2 which included some minor fixes. </p> <p>  </p> <p>Here is a list of the main changes in the GDR (build 2.0.40115.0): </p> <ul> <li>Fixes problems that were caused by Silverlight and McAfee scanning tools interactions </li> <li>UI automation stability fixes, including: <ul> <li>graceful failures when attempting to use features that require .NET Framework 3.0 or 3.5 on machines that do not have either framework installed </li> <li>improved Tablet support </li> </ul> </li> <li>Fixes an issue that arises when Mac users customize their environment by removing Arial and Verdana fonts </li> <li>Fixes a known issue with Isolated Storage IncreaseQuotaTo method (see <a href="http://silverlight.net/forums/p/51485/135114.aspx">this post for more information</a>) </li> </ul> <p>The one fix which bothered me a lot is the graceful failures when attempting to use features that require .Net framework 3.0 or 3.5 on machines that do that nave either framework installed. Silverlight 2 has its own version of the .net framework why should it use .net 3.0 or 3.5 and of course the .net framework is not available for the mac.  Well after looking around some I found this in the comments on Tim Sneath's Blog </p> <p>  " apologies - we could probably be clearer here on what this means. Essentially, this was a bug that could be triggered in certain situations where you were using the accessibility tools (e.g. magnifier) on Silverlight content on a machine without .NET Framework installed. In short, the bug was an accidental dependency that has now been removed." - Tim Sneath </p> <p>  <a href="http://blogs.msdn.com/tims/archive/2009/02/18/silverlight-2-gdr1-now-available.aspx">http://blogs.msdn.com/tims/archive/2009/02/18/silverlight-2-gdr1-now-available.aspx</a> </p> <p>For More info on the Update please check out Tim Heuer's Blog entry </p> <p> <a href="http://timheuer.com/blog/archive/2009/02/19/silverlight-2-gets-minor-update-gdr1.aspx">http://timheuer.com/blog/archive/2009/02/19/silverlight-2-gets-minor-update-gdr1.aspx</a> </p> http://silverlight-help.com/Tips/KenTucker/09-02-21/Silverlight_2_GDR_released.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/09-02-21/Silverlight_2_GDR_released.aspx 7b0aa2d3-af6b-4faa-aea3-cb5adb3155e2 Sat, 21 Feb 2009 11:12:00 GMT Silverlight 2 RC0 DataGrid CommittingEdit work around <p>In Silverlight 2 Beta 2 DataGrid had a CommittingEdit event which was a great event to update the data in an ado.net dataservice.&#160;&#160; Unfortunately this event was removed in the RC0 of the datagrid.&#160; As a work around Jonathan Shen suggested using a template column and using the LostFocus event to update your dataservice data. </p> <p>&#160; </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:f3282ef9-cc64-42e3-abe0-75012c52ea93" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; "> &lt;data:DataGridTemplateColumn Header=&quot;Command&quot;&gt; &lt;data:DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;TextBlock Text=&quot;{Binding FirstName}&quot;&gt;&lt;/TextBlock&gt; &lt;/DataTemplate&gt; &lt;/data:DataGridTemplateColumn.CellTemplate&gt; &lt;data:DataGridTemplateColumn.CellEditingTemplate&gt; &lt;DataTemplate&gt; &lt;TextBox Text=&quot;{Binding FirstName}&quot; LostFocus=&quot;TextBox_LostFocus&quot;&gt;&lt;/TextBox&gt; //you can detect other events. &lt;/DataTemplate&gt; &lt;/data:DataGridTemplateColumn.CellEditingTemplate&gt; &lt;/data:DataGridTemplateColumn&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160; </p> <p>Well this works fine but I don't want to have to define all my columns this way.&#160; Sometimes it is nice to just let the datagrid autogenerate the columns. So I decided to use the DataGrid's PreparingCellForEdit to add the handler for the LostFocus event.&#160; Couple of other things you need to do.&#160; First Remove the old event handler so the event does not fire multiple times.&#160; Second we need a variable to keep track of the item that was edited when the lost focus event is fired we will be on another record. </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:f4cd287f-e949-4030-8f7a-9df276eda384" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Dim prod As Northwind.Products Private Sub dgProducts_PreparingCellForEdit(ByVal sender As Object, ByVal e As System.Windows.Controls.DataGridPreparingCellForEditEventArgs) Handles dgProducts.PreparingCellForEdit RemoveHandler e.EditingElement.LostFocus, AddressOf Textbox_LostFocus AddHandler e.EditingElement.LostFocus, AddressOf Textbox_LostFocus prod = DirectCast(dgProducts.SelectedItem, Northwind.Products) End Sub Friend Sub Textbox_LostFocus(ByVal sender As Object, ByVal e As EventArgs) proxy.UpdateObject(prod) End Sub </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160; </p> <p>Here is the complete code </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:3995c186-63dc-4fbe-9a19-52e19d0e31b6" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Imports System.Collections.ObjectModel Imports System.Data.Services.Client Imports System.Diagnostics Partial Public Class Page Inherits UserControl Public Sub New() InitializeComponent() End Sub Dim q As DataServiceQuery(Of Northwind.Products) Dim proxy As Northwind.NorthwindEntities Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded Dim address = New Uri(Application.Current.Host.Source, &quot;../WebDataService1.svc&quot;) proxy = New Northwind.NorthwindEntities(address) Dim qry = From p In proxy.Products Select p q = CType(qry, Global.System.Data.Services.Client.DataServiceQuery(Of Northwind.Products)) q.BeginExecute(AddressOf ProductsLoaded, Nothing) End Sub Friend Sub ProductsLoaded(ByVal ar As System.IAsyncResult) Dim c = q.EndExecute(ar) Dim d As New ObservableCollection(Of Northwind.Products) For Each p In c d.Add(p) Next Dim GetOnRightThread As New SetTheDataSource(AddressOf SetDataSource) Dispatcher.BeginInvoke(GetOnRightThread, New Object() {d}) End Sub Delegate Sub SetTheDataSource(ByVal d As ObservableCollection(Of Northwind.Products)) Friend Sub SetDataSource(ByVal d As ObservableCollection(Of Northwind.Products)) dgProducts.ItemsSource = d End Sub Dim prod As Northwind.Products Private Sub dgProducts_PreparingCellForEdit(ByVal sender As Object, ByVal e As System.Windows.Controls.DataGridPreparingCellForEditEventArgs) Handles dgProducts.PreparingCellForEdit RemoveHandler e.EditingElement.LostFocus, AddressOf Textbox_LostFocus AddHandler e.EditingElement.LostFocus, AddressOf Textbox_LostFocus prod = DirectCast(dgProducts.SelectedItem, Northwind.Products) End Sub Friend Sub Textbox_LostFocus(ByVal sender As Object, ByVal e As EventArgs) proxy.UpdateObject(prod) End Sub Friend Sub SaveComplete(ByVal ar As System.IAsyncResult) proxy.EndSaveChanges(ar) End Sub Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnSave.Click proxy.BeginSaveChanges(AddressOf SaveComplete, Nothing) End Sub End Class </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p></p> <br /><a href="http://www.dotnetkicks.com/kick/?url=http://www.onteorasoftware.net/post/Silverlight-2-RC0-DataGrid-CommittingEdit-work-around.aspx"><img style="border-bottom: 0px solid; border-left: 0px solid; border-top: 0px solid; border-right: 0px solid" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://www.onteorasoftware.net/post/Silverlight-2-RC0-DataGrid-CommittingEdit-work-around.aspx" /></a> http://silverlight-help.com/Tips/KenTucker/08-11-04/Silverlight_2_RC0_DataGrid_CommittingEdit_work_around.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/08-11-04/Silverlight_2_RC0_DataGrid_CommittingEdit_work_around.aspx 48f5dd4b-e5bf-4aa7-aa5b-a7982006f876 Tue, 04 Nov 2008 10:58:25 GMT Silverlight 2.0 Create a context menu <p>Silverlight 2 does not come with a context menu control.&#160; You could always handle the html document's oncontextmenu event and open a popcontrol to use as a context menu.&#160; This sample should help you get started. </p> <p>&#160;</p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:69e4cd5d-5308-47e0-bacd-ce248d7dc38b" class="wlWriterEditableSmartContent"><pre class="brush: plain; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;UserControl x:Class=&quot;SilverlightContextMenu.Page&quot; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; Width=&quot;400&quot; Height=&quot;300&quot;&gt; &lt;Grid&gt; &lt;Rectangle x:Name=&quot;LayoutRoot&quot; Fill =&quot;Green&quot; &gt;&lt;/Rectangle &gt; &lt;Popup x:Name=&quot;menu&quot;&gt; &lt;StackPanel&gt; &lt;Button x:Name=&quot;btnRed&quot; Content=&quot;Red&quot;&gt;&lt;/Button&gt; &lt;Button x:Name=&quot;btnWhite&quot; Content=&quot;White&quot;&gt;&lt;/Button&gt; &lt;Button x:Name=&quot;btnBlue&quot; Content=&quot;Blue&quot;&gt;&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/Popup&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:bb423a86-7014-4342-ab12-78355a8135ac" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Imports System.Windows.Browser Partial Public Class Page Inherits UserControl Dim WithEvents cm As ContextMenuCatcher Public Sub New() InitializeComponent() End Sub Private Sub btnBlue_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnBlue.Click LayoutRoot.fill = New SolidColorBrush(Colors.Blue) menu.IsOpen = False End Sub Private Sub btnRed_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnRed.Click LayoutRoot.fill = New SolidColorBrush(Colors.Red) menu.IsOpen = False End Sub Private Sub btnWhite_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnWhite.Click LayoutRoot.fill = New SolidColorBrush(Colors.White) menu.IsOpen = False End Sub Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded cm = New ContextMenuCatcher(LayoutRoot) menu.IsOpen = False End Sub Private Sub cm_RightClick(ByVal sender As Object, ByVal e As RightClickEventArgs) Handles cm.RightClick menu.HorizontalOffset = e.AbsolutePoint.X menu.VerticalOffset = e.AbsolutePoint.Y menu.IsOpen = True End Sub Private Sub menu_MouseLeave(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles menu.MouseLeave menu.IsOpen = False End Sub End Class Public Class ContextMenuCatcher Public Event RightClick(ByVal sender As Object, ByVal e As RightClickEventArgs) Dim ctrl As UIElement Public Sub New(ByVal c As UIElement) ctrl = c HtmlPage.Document.AttachEvent(&quot;oncontextmenu&quot;, AddressOf OnContextMenu) End Sub Private Sub OnContextMenu(ByVal sender As Object, ByVal e As HtmlEventArgs) System.Diagnostics.Debug.WriteLine(e.OffsetX.ToString) System.Diagnostics.Debug.WriteLine(e.OffsetY.ToString) Dim pt As New Point(e.OffsetX, e.OffsetY) e.PreventDefault() e.StopPropagation() RaiseEvent RightClick(Me, New RightClickEventArgs(ctrl, pt)) End Sub End Class Public Class RightClickEventArgs Dim m_Source As UIElement Public Property Source() As UIElement Get Return m_Source End Get Set(ByVal value As UIElement) m_Source = value End Set End Property Dim m_RelativePoint As Point Public Property RelativePoint() As Point Get Return m_RelativePoint End Get Set(ByVal value As Point) m_RelativePoint = value End Set End Property Dim m_AbsolutePoint As Point Public Property AbsolutePoint() As Point Get Return m_AbsolutePoint End Get Set(ByVal value As Point) m_AbsolutePoint = value End Set End Property Friend Sub New(ByVal source As UIElement, ByVal absolutePoint As Point) Me.Source = source Me.AbsolutePoint = absolutePoint Me.RelativePoint = GetPosition(source) End Sub Public Function GetPosition(ByVal relativeTo As UIElement) As Point Dim transform As GeneralTransform = Application.Current.RootVisual.TransformToVisual(relativeTo) Return transform.Transform(AbsolutePoint) End Function End Class</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <pre>&#160;</pre> <pre>You also have to make the silverlight control windowless for this to work</pre> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:7f80d084-8e50-45e2-a98a-41d0063e8ad9" class="wlWriterEditableSmartContent"><pre class="brush: plain; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;asp:Silverlight ID=&quot;Xaml1&quot; runat=&quot;server&quot; Source=&quot;~/ClientBin/SilverlightContextMenu.xap&quot; MinimumVersion=&quot;2.0.30923.0&quot; Width=&quot;100%&quot; Height=&quot;100%&quot; Windowless=&quot;true&quot; /&gt;</pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> http://silverlight-help.com/Tips/KenTucker/08-10-22/Silverlight_2_0_Create_a_context_menu.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/08-10-22/Silverlight_2_0_Create_a_context_menu.aspx 64fa33b7-de57-45b1-abf4-f48d53615e38 Wed, 22 Oct 2008 10:41:11 GMT Publishing a VB Silverlight 2 app which uses a WCF service <p>Note this works with the released version of Silverlight 2 </p> <p>&#160; </p> <p>I created a Silverlight 2 app which uses a WCF Silverlight service which worked fine localy but did call the service when I published it to my web host.&#160; After playing around with the different settings I finally came across an entry in the Silverlight Forums by sladapter with a solution.&#160; </p> <p>&#160; </p> <p><a title="http://silverlight.net/forums/t/19021.aspx" href="http://silverlight.net/forums/t/19021.aspx">http://silverlight.net/forums/t/19021.aspx</a>&#160; </p> <p>&#160; </p> <p>So lets create a simple Silverlight 2 App to demo how to do this.&#160; I created a silverlight app with a web application project.&#160;&#160; I prefer web applications to web sites but a web site will work the same.&#160;&#160; </p> <p>&#160; </p> <p>Add a WCF Silverlight- enabled service named&#160; service1 to the web application.&#160; </p> <p>&#160; </p> <p>This is the code I am using for the service </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:99fb640b-dbff-4b51-a0d8-a8e5df45a266" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Imports System.ServiceModel Imports System.ServiceModel.Activation &lt;ServiceContract(Namespace:=&quot;&quot;)&gt; _ &lt;AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)&gt; _ Public Class Service1 &lt;OperationContract()&gt; _ Public Function SayHello() As String ' Add your operation implementation here Return &quot;Hello World&quot; End Function End Class </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160; </p> <p>Lets add a TextBlock to the Page.xaml to display our message. </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:ab618f87-9bf4-41c7-bcc8-86c14e1a1dcc" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Imports System.ServiceModel Imports System.ServiceModel.Activation &lt;ServiceContract(Namespace:=&quot;&quot;)&gt; _ &lt;AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)&gt; _ Public Class Service1 &lt;OperationContract()&gt; _ Public Function SayHello() As String ' Add your operation implementation here Return &quot;Hello World&quot; End Function End Class </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160; </p> <p>Now run the app.&#160; Once that is done we can add a service reference to our silverlight app.&#160; Press the arrow on the Discover button and select services in the solution.&#160; You should windup with something like this. </p> <p>&#160; </p> <p><a href="http://www.silverlight-help.com/Libraries/MetaBlogLib/WindowsLiveWriter-PublishingaVBSilverlight2Beta2appwhichus_117FE-image_4.sflb.ashx"><img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" alt="image" src="http://www.silverlight-help.com/Libraries/MetaBlogLib/WindowsLiveWriter-PublishingaVBSilverlight2Beta2appwhichus_117FE-image_thumb_1.sflb.ashx" width="244" height="200" /></a> </p> <p>&#160; </p> <p>In the silverlight app open up the file ServiceReferences.ClientConfig </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:e415451c-51ed-46c0-94d4-987eaba48c8f" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;configuration&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name=&quot;BasicHttpBinding_Service1&quot; maxBufferSize=&quot;65536&quot; maxReceivedMessageSize=&quot;65536&quot;&gt; &lt;security mode=&quot;None&quot; /&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address=&quot;http://localhost:1205/Service1.svc&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BasicHttpBinding_Service1&quot; contract=&quot;ServiceReference1.Service1&quot; name=&quot;BasicHttpBinding_Service1&quot; /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160; </p> <p>In the endpoint address change the contract to include the project name. </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:d8e69b5a-4cdf-4eaa-9e01-06114805929c" class="wlWriterEditableSmartContent"><pre class="brush: xml; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">&lt;configuration&gt; &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;basicHttpBinding&gt; &lt;binding name=&quot;BasicHttpBinding_Service1&quot; maxBufferSize=&quot;65536&quot; maxReceivedMessageSize=&quot;65536&quot;&gt; &lt;security mode=&quot;None&quot; /&gt; &lt;/binding&gt; &lt;/basicHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address=&quot;http://localhost:1205/Service1.svc&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BasicHttpBinding_Service1&quot; contract=&quot;SilverlightApplication2.ServiceReference1.Service1&quot; name=&quot;BasicHttpBinding_Service1&quot; /&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; &lt;/configuration&gt; </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p>&#160; </p> <p>Now lets add some code to call the service. Page.Xaml.VB </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:9b1dc49c-7b98-44a7-aaaa-54bcbd904e5a" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Partial Public Class Page Inherits UserControl Dim current As String Public Sub New() InitializeComponent() End Sub Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded Dim ws As New ServiceReference1.Service1Client AddHandler ws.SayHelloCompleted, AddressOf HelloComplete ws.SayHelloAsync() End Sub Private Sub HelloComplete(ByVal sender As Object, ByVal e As ServiceReference1.SayHelloCompletedEventArgs) txt.Text = e.Result End Sub End Class </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p></p> <p>&#160; </p> <p>Now if we run the app you should see Hello World but when published you will only see loading.&#160;&#160; So lets change how we create the service so that this will work once deployed.&#160; Basically we tell the service to use the current web address. </p> <p>&#160; </p> <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:DFDE9937-D816-47f4-A306-7B60D5CE5AC0:66d1f761-534d-46a5-89b4-ac0e7347ab66" class="wlWriterEditableSmartContent"><pre class="brush: vb; gutter: false; first-line: 1; tab-size: 4; toolbar: true; ">Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded Dim address = New Uri(Application.Current.Host.Source, &quot;../Service1.svc&quot;) Dim ws As New ServiceReference1.Service1Client(&quot;BasicHttpBinding_Service1&quot;, address.AbsoluteUri) AddHandler ws.SayHelloCompleted, AddressOf HelloComplete ws.SayHelloAsync() End Sub </pre><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin. http://dunnhq.com --></div> <p></p> <p>&#160; </p> <p>Hope this helps </p> http://silverlight-help.com/Tips/KenTucker/08-09-29/Publishing_a_VB_Silverlight_2_app_which_uses_a_WCF_service.aspx Ken Tucker http://silverlight-help.com/Tips/KenTucker/08-09-29/Publishing_a_VB_Silverlight_2_app_which_uses_a_WCF_service.aspx f4301865-ba09-4512-9124-afe1717d89b5 Mon, 29 Sep 2008 11:18:58 GMT