<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
  <channel>
    <title>Valeri Hristov's blog</title>
    <description>Valeri Hristov's blog</description>
    <link>http://blogs.telerik.com/ValeriHristov/Posts.aspx</link>
    <docs>http://backend.userland.com/rss</docs>
    <item>
      <title>TreeView in a ComboBox dropdown using RadControls for Silverlight</title>
      <description>&lt;p&gt;As far as I can tell from the experience of my colleagues with RadControls for ASP.NET AJAX, one of the common feature requests for RadComboBox and RadTreeView is combining them into one piece. Recently we started to receive similar requests for RadComboBox and RadTreeView for Silverlight. Placing a TreeView in a ComboBox sometimes makes a lot of sense, so I decided to research the best way to do it. &lt;br /&gt;
 &lt;br /&gt;
The first, the simplest and most obvious way is to place a RadTreeView as content of RadComboBox:&lt;/p&gt;
&lt;pre&gt;&amp;lt;input:RadComboBox&amp;gt;&lt;br /&gt; &amp;lt;nav:RadTreeView &lt;br /&gt; ItemTemplate="{StaticResource ItemTemplate}" &lt;br /&gt; ItemsSource="{StaticResource ItemsSource}" /&amp;gt;&lt;br /&gt;&amp;lt;/input:RadComboBox&amp;gt;&lt;/pre&gt;
&lt;p&gt;However, it has one important limitation: RadComboBox cannot display the RadTreeView selected item. The problem is that RadTreeView is actually inside a RadComboBoxItem and RadComboBox displays only the content of its items. I think that you could create a special ContentPresenter that will display the SelectedItem property of the inner TreeView, but in addition, you should search for ways to avoid other UI glitches, such as RadComboBoxItem highlight around the whole TreeView.&lt;br /&gt;
 &lt;br /&gt;
I abandoned this approach and created completely different prototype, that follows a WPF article I found on the Internet several months ago (I am unable to find it again, so if you know it, post a comment here with a link and I will give credit to the author). The idea is to replace the RadComboBox ItemsPresenter with a RadTreeView. To do this, I copied the two RadComboBox control templates into a separate XAML file, effectively creating a new RadComboBox skin (this is something that I will describe in detail in another article). You can see how it works in the attached source. To keep this article short, I removed most of the code, leaving only the elements that demonstrate the idea:&lt;/p&gt;
&lt;pre&gt;&amp;lt;!-- NonEditableComboBoxTemplate --&amp;gt;&lt;br /&gt;&amp;lt;ControlTemplate x:Key="NonEditableComboBox" TargetType="input:RadComboBox"&amp;gt;&lt;br /&gt; &amp;lt;Grid Name="MainGrid"&amp;gt;&lt;br /&gt;  &amp;lt;ToggleButton x:Name="DropDownButton" /&amp;gt;&lt;br /&gt;  &amp;lt;ContentPresenter /&amp;gt;&lt;br /&gt;  &amp;lt;Popup x:Name="PART_Popup"&amp;gt;&lt;br /&gt;   &amp;lt;ScrollViewer x:Name="PART_ScrollViewer"&amp;gt;&lt;br /&gt;    &amp;lt;nav:RadTreeView ItemsSource="{TemplateBinding ItemsSource}"&lt;br /&gt;     ItemTemplate="{TemplateBinding ItemTemplate}"&lt;br /&gt;     ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"&lt;br /&gt;     ItemContainerStyle="{TemplateBinding ItemContainerStyle}"&lt;br /&gt;     ItemContainerStyleSelector="{TemplateBinding ItemContainerStyleSelector}"&lt;br /&gt;     SelectedValuePath="{TemplateBinding SelectedValuePath}"&lt;br /&gt;     system:ScrollViewer.HorizontalScrollBarVisibility="Disabled"&lt;br /&gt;     system:ScrollViewer.VerticalScrollBarVisibility="Disabled" /&amp;gt;&lt;br /&gt;   &amp;lt;/ScrollViewer&amp;gt;&lt;br /&gt;  &amp;lt;/Popup&amp;gt;&lt;br /&gt;  &amp;lt;Rectangle x:Name="DisabledVisual" /&amp;gt;&lt;br /&gt; &amp;lt;/Grid&amp;gt;&lt;br /&gt;&amp;lt;/ControlTemplate&amp;gt;&lt;/pre&gt;
&lt;p&gt;I bound all data related properties of the RadTreeView with the corresponding properties of RadComboBox. I also disabled the integrated scrollbars of RadTreeView. The only thing left is to synchronize RadComboBox.SelectedItem and RadTreeView.SelectedItem. To do that I created a simple class, containing one attached property:&lt;/p&gt;
&lt;pre&gt;using Telerik.Windows;&lt;br /&gt;public class ComboBoxExtensions&lt;br /&gt;{&lt;br /&gt; public static bool GetEnableInnerTreeView(DependencyObject obj)&lt;br /&gt; {&lt;br /&gt;  return (bool)obj.GetValue(EnableInnerTreeViewProperty);&lt;br /&gt; }&lt;/pre&gt;
&lt;pre&gt; public static void SetEnableInnerTreeView(DependencyObject obj, bool value)&lt;br /&gt; {&lt;br /&gt;  obj.SetValue(EnableInnerTreeViewProperty, value);&lt;br /&gt; }&lt;/pre&gt;
&lt;pre&gt; public static readonly DependencyProperty EnableInnerTreeViewProperty =&lt;br /&gt;  DependencyProperty.RegisterAttached("EnableInnerTreeView", typeof(bool), typeof(ComboBoxExtensions),&lt;br /&gt;  new System.Windows.PropertyMetadata(InitializeTreeView));&lt;/pre&gt;
&lt;pre&gt; private static void InitializeTreeView(DependencyObject d,&lt;br /&gt;    DependencyPropertyChangedEventArgs args)&lt;br /&gt; {&lt;br /&gt;  RadComboBox combo = d as RadComboBox;&lt;br /&gt;  if (combo != null)&lt;br /&gt;  {&lt;br /&gt;   combo.AddHandler(RadTreeView.SelectionChangedEvent, &lt;br /&gt;    new Telerik.Windows.Controls.SelectionChangedEventHandler(&lt;br /&gt;    delegate(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)&lt;br /&gt;    {&lt;br /&gt;     RadTreeView tree = e.OriginalSource as RadTreeView;&lt;br /&gt;     if (tree != null)&lt;br /&gt;     {&lt;br /&gt;      combo.SelectedItem = tree.SelectedItem;&lt;br /&gt;      combo.IsDropDownOpen = false;&lt;br /&gt;     }&lt;br /&gt;    }));&lt;br /&gt;  }&lt;br /&gt; }&lt;br /&gt;}&lt;/pre&gt;
&lt;p&gt;When you set the attached property on RadComboBox, ComboBoxExtensions attaches a &lt;a href="http://blogs.telerik.com/HristoHristov/Posts/08-07-23/Routed_Events_in_Silverlight_2.aspx" title="Custom RoutedEvent for Silverlight"&gt;RoutedEvent handler&lt;/a&gt; to the RadTreeView's SelectionChanged event. The handler synchronizes the TreeView and the ComboBox, and closes the ComboBox dropdown when you change the selection in the treeview. The following code demonstrates the RadComboBox declaration:&lt;/p&gt;
&lt;pre&gt;&amp;lt;input:RadComboBox &lt;br /&gt; telerik:RadControl.Theme="{StaticResource TreeInCombo}"&lt;br /&gt; SelectedValuePath="Text"&lt;br /&gt; ItemsSource="{StaticResource ItemsSource}"&lt;br /&gt; ItemTemplate="{StaticResource ItemTemplate}"&lt;br /&gt; local:ComboBoxExtensions.EnableInnerTreeView="True" /&amp;gt;&lt;/pre&gt;
&lt;p&gt; &lt;br /&gt;
For completeness, here is the hierarchical ItemTemplate, applied on RadComboBox:&lt;/p&gt;
&lt;pre&gt;&amp;lt;DataTemplate x:Key="SubItem"&amp;gt;&lt;br /&gt; &amp;lt;TextBlock Text="{Binding Text}" /&amp;gt;&lt;br /&gt;&amp;lt;/DataTemplate&amp;gt;&lt;/pre&gt;
&lt;pre&gt;&amp;lt;telerik:HierarchicalDataTemplate x:Key="ItemTemplate" &lt;br /&gt;  ItemsSource="{Binding Children}"&lt;br /&gt;  ItemTemplate="{StaticResource SubItem}"&amp;gt;&lt;br /&gt; &amp;lt;TextBlock Text="{Binding Text}" /&amp;gt;&lt;br /&gt;&amp;lt;/telerik:HierarchicalDataTemplate&amp;gt;&lt;/pre&gt;
&lt;p&gt;You may ask "Why not bind the SelectedItem properties of the two controls?". The answer is - RadTreeView's SelectedItem property is read-only and Silverlight does not provide the needed instruments (Triggers) to bind a read-only property. "Why SelectedItem is read-only?" you may ask - the answer is "Because RadTreeView is hierarchical control".&lt;/p&gt;
&lt;p&gt;Here is the source:&lt;/p&gt;
&lt;p&gt;&lt;a href="/Libraries/Valeri Hristov/TreeInCombo.sflb"&gt;TreeInCombo&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope this article helps. Let me know if you have questions, you know how to find me :)&lt;/p&gt;
</description>
      <link>http://blogs.telerik.com/ValeriHristov/Posts/08-11-08/TreeView_in_a_ComboBox_dropdown_using_RadControls_for_Silverlight.aspx</link>
      <author>Valeri Hristov</author>
      <comments>http://blogs.telerik.com/ValeriHristov/Posts/08-11-08/TreeView_in_a_ComboBox_dropdown_using_RadControls_for_Silverlight.aspx</comments>
      <guid isPermaLink="false">0fcdef87-b140-4f55-822a-79d0e965a042</guid>
      <pubDate>Sat, 08 Nov 2008 13:13:09 GMT</pubDate>
    </item>
    <item>
      <title>RadControls for Silverlight Demo with ADO.NET Data Services</title>
      <description>&lt;p&gt;Yesterday I wrote about how to databind RadTreeView for Silverlight to ADO.NET Data Service and use Load on Demand. The simple application from yesterday was upgraded to a small back-end application for the Northwind database, that allows editing and deleting products. This time I decided to give it to one of our designers and our new Silverlight front end developer and they implemented this slick design: &lt;br /&gt;
&lt;a href="http://blogs.telerik.com/Libraries/MetaBlog/WindowsLiveWriter-NorthwindBackEnd_2.sflb"&gt;&lt;img width="586" height="484" style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="NorthwindBackEnd" src="http://blogs.telerik.com/Libraries/MetaBlog/WindowsLiveWriter-NorthwindBackEnd_thumb.sflb" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The application is available online:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://demos.telerik.com/silverlight/northwindbackend/Default.aspx"&gt;http://demos.telerik.com/silverlight/northwindbackend/Default.aspx&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The source code can be downloaded from here: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.telerik.com/Libraries/Valeri%20Hristov/NorthwindBackend.sflb"&gt;NorthwindBackend.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In addition to yesterday's application, NorthwindBackend has extended data source, that provides simple undo mechanism and ability to update and delete products in the database through the ADO.NET Data Service. Product updates and deletes are really simple: &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; UpdateSelectedProduct() 
{ 
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;.SelectedProduct != &lt;span class="kwrd"&gt;null&lt;/span&gt;) 
    { 
        Service.UpdateObject(&lt;span class="kwrd"&gt;this&lt;/span&gt;.SelectedProduct); 
        Service.SetLink(&lt;span class="kwrd"&gt;this&lt;/span&gt;.SelectedProduct, &lt;span class="str"&gt;"Supplier"&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.SelectedProduct.Supplier); 
        Service.BeginSaveChanges(&lt;span class="kwrd"&gt;null&lt;/span&gt;, &lt;span class="kwrd"&gt;null&lt;/span&gt;); 
    } 
} 

&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DeleteSelectedProduct() 
{ 
    Service.DeleteObject(&lt;span class="kwrd"&gt;this&lt;/span&gt;.SelectedProduct); 
    Service.BeginSaveChanges((IAsyncResult result) =&amp;gt; 
    { 
        SelectedProduct.Category.Products.Remove(SelectedProduct); 
        SelectedProduct = &lt;span class="kwrd"&gt;null&lt;/span&gt;; 
    }, &lt;span class="kwrd"&gt;null&lt;/span&gt;); 
} &lt;/pre&gt;
&lt;style type="text/css"&gt;
    .csharpcode {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    MARGIN: 0em
    }
    .csharpcode .rem {
    COLOR: #008000
    }
    .csharpcode .kwrd {
    COLOR: #0000ff
    }
    .csharpcode .str {
    COLOR: #006080
    }
    .csharpcode .op {
    COLOR: #0000c0
    }
    .csharpcode .preproc {
    COLOR: #cc6633
    }
    .csharpcode .asp {
    BACKGROUND-COLOR: #ffff00
    }
    .csharpcode .html {
    COLOR: #800000
    }
    .csharpcode .attr {
    COLOR: #ff0000
    }
    .csharpcode .alt {
    BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
    }
    .csharpcode .lnum {
    COLOR: #606060
    }
&lt;/style&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Since deleting of rows in the database can be dangerous in a real-life application, I demonstrate how to implement simple confirmation, using RadWindow: &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ButtonDelete_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, System.Windows.RoutedEventArgs e) 
{ 
    RadWindow.Confirm(&lt;span class="str"&gt;"Are you sure you want to delete this product?"&lt;/span&gt;, 
        (&lt;span class="kwrd"&gt;object&lt;/span&gt; window, WindowClosedEventArgs args) =&amp;gt; 
        { 
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (args.DialogResult.HasValue &amp;amp;&amp;amp; args.DialogResult.Value) 
            { 
                &lt;span class="kwrd"&gt;this&lt;/span&gt;.DataSource.DeleteSelectedProduct(); 
            } 
        }); 
} &lt;/pre&gt;
&lt;style type="text/css"&gt;
    .csharpcode {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    MARGIN: 0em
    }
    .csharpcode .rem {
    COLOR: #008000
    }
    .csharpcode .kwrd {
    COLOR: #0000ff
    }
    .csharpcode .str {
    COLOR: #006080
    }
    .csharpcode .op {
    COLOR: #0000c0
    }
    .csharpcode .preproc {
    COLOR: #cc6633
    }
    .csharpcode .asp {
    BACKGROUND-COLOR: #ffff00
    }
    .csharpcode .html {
    COLOR: #800000
    }
    .csharpcode .attr {
    COLOR: #ff0000
    }
    .csharpcode .alt {
    BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
    }
    .csharpcode .lnum {
    COLOR: #606060
    }
&lt;/style&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The second parameter of the RadWindow.Confirm method is an event handler, that will be executed when the window closes. There we provide the code that checks whether the user clicked OK or Cancel and then proceed accordingly. &lt;/p&gt;
&lt;p&gt;In this application I also modified the generated code for the ADO.NET Data Service in order to change the collections' types. The new thing this time is that I added partial classes that implement &lt;strong&gt;INotifyPropertyChanged&lt;/strong&gt; for each entity. You can find those classes in the Data folder of the NorthwindBackend application. The &lt;strong&gt;INotifyPropertyChanged&lt;/strong&gt; interface is needed because I am using TwoWay bindings to implement the editing functionality of the application without writing code-behind: &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;input:RadComboBox&lt;/span&gt; &lt;span class="attr"&gt;ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Suppliers}"&lt;/span&gt; 
    &lt;span class="attr"&gt;SelectedItem&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding SelectedProduct.Supplier, Mode=TwoWay}"&lt;/span&gt; 
    &lt;span class="attr"&gt;DisplayMemberPath&lt;/span&gt;&lt;span class="kwrd"&gt;="ContactName"&lt;/span&gt; &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="26"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;style type="text/css"&gt;
    .csharpcode {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    MARGIN: 0em
    }
    .csharpcode .rem {
    COLOR: #008000
    }
    .csharpcode .kwrd {
    COLOR: #0000ff
    }
    .csharpcode .str {
    COLOR: #006080
    }
    .csharpcode .op {
    COLOR: #0000c0
    }
    .csharpcode .preproc {
    COLOR: #cc6633
    }
    .csharpcode .asp {
    BACKGROUND-COLOR: #ffff00
    }
    .csharpcode .html {
    COLOR: #800000
    }
    .csharpcode .attr {
    COLOR: #ff0000
    }
    .csharpcode .alt {
    BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
    }
    .csharpcode .lnum {
    COLOR: #606060
    }
&lt;/style&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;There is one more trick, that I want to show. I am using a converter to show/hide the product properties panel, depending on the SelectedProduct property of the data source: &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; VisibilityNullConverter : IValueConverter 
{ 
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; Convert(&lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;, Type targetType, &lt;span class="kwrd"&gt;object&lt;/span&gt; parameter, CultureInfo culture) 
    { 
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt; == &lt;span class="kwrd"&gt;null&lt;/span&gt; ? Visibility.Collapsed : Visibility.Visible; 
    } 

    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;object&lt;/span&gt; ConvertBack(&lt;span class="kwrd"&gt;object&lt;/span&gt; &lt;span class="kwrd"&gt;value&lt;/span&gt;, Type targetType, &lt;span class="kwrd"&gt;object&lt;/span&gt; parameter, CultureInfo culture) 
    { 
        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; NotImplementedException(); 
    } 
} &lt;/pre&gt;
&lt;style type="text/css"&gt;
    .csharpcode {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    MARGIN: 0em
    }
    .csharpcode .rem {
    COLOR: #008000
    }
    .csharpcode .kwrd {
    COLOR: #0000ff
    }
    .csharpcode .str {
    COLOR: #006080
    }
    .csharpcode .op {
    COLOR: #0000c0
    }
    .csharpcode .preproc {
    COLOR: #cc6633
    }
    .csharpcode .asp {
    BACKGROUND-COLOR: #ffff00
    }
    .csharpcode .html {
    COLOR: #800000
    }
    .csharpcode .attr {
    COLOR: #ff0000
    }
    .csharpcode .alt {
    BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
    }
    .csharpcode .lnum {
    COLOR: #606060
    }
&lt;/style&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The panel is bound to the SelectedProduct property: &lt;/p&gt;
&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Border&lt;/span&gt; &lt;span class="attr"&gt;x:Name&lt;/span&gt;&lt;span class="kwrd"&gt;="ProductInfoPanel"&lt;/span&gt; 
    &lt;span class="attr"&gt;Visibility&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding SelectedProduct, Converter={StaticResource VisibilityNullConverter}}"&lt;/span&gt; 
    &lt;span class="attr"&gt;Margin&lt;/span&gt;&lt;span class="kwrd"&gt;="330,50,110,50"&lt;/span&gt; 
    &lt;span class="attr"&gt;CornerRadius&lt;/span&gt;&lt;span class="kwrd"&gt;="10,10,10,10"&lt;/span&gt; 
    &lt;span class="attr"&gt;BorderThickness&lt;/span&gt;&lt;span class="kwrd"&gt;="1,1,1,1"&lt;/span&gt; 
    &lt;span class="attr"&gt;Height&lt;/span&gt;&lt;span class="kwrd"&gt;="260"&lt;/span&gt; 
    &lt;span class="attr"&gt;BorderBrush&lt;/span&gt;&lt;span class="kwrd"&gt;="#FFB1C69E"&lt;/span&gt; 
    &lt;span class="attr"&gt;Background&lt;/span&gt;&lt;span class="kwrd"&gt;="#19FFF200"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;style type="text/css"&gt;
    .csharpcode {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    BACKGROUND-COLOR: #ffffff; FONT-FAMILY: consolas, "Courier New", courier, monospace; COLOR: black; FONT-SIZE: small
    }
    .csharpcode PRE {
    MARGIN: 0em
    }
    .csharpcode .rem {
    COLOR: #008000
    }
    .csharpcode .kwrd {
    COLOR: #0000ff
    }
    .csharpcode .str {
    COLOR: #006080
    }
    .csharpcode .op {
    COLOR: #0000c0
    }
    .csharpcode .preproc {
    COLOR: #cc6633
    }
    .csharpcode .asp {
    BACKGROUND-COLOR: #ffff00
    }
    .csharpcode .html {
    COLOR: #800000
    }
    .csharpcode .attr {
    COLOR: #ff0000
    }
    .csharpcode .alt {
    BACKGROUND-COLOR: #f4f4f4; MARGIN: 0em; WIDTH: 100%
    }
    .csharpcode .lnum {
    COLOR: #606060
    }
&lt;/style&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;When the SelectedProduct is null, the converter will return Visibility.Collapsed and the Border and its content will be hidden. When the SelectedProduct becomes not null, the binding will automatically update the Visibility property of the Border, thanks to the &lt;strong&gt;INotifyPropertyChanged&lt;/strong&gt; interface, that is implemented in the data source. &lt;/p&gt;
</description>
      <link>http://blogs.telerik.com/ValeriHristov/Posts/08-10-09/RadControls_for_Silverlight_Demo_with_ADO_NET_Data_Services.aspx</link>
      <author>Valeri Hristov</author>
      <comments>http://blogs.telerik.com/ValeriHristov/Posts/08-10-09/RadControls_for_Silverlight_Demo_with_ADO_NET_Data_Services.aspx</comments>
      <guid isPermaLink="false">05d93835-f0f5-4f42-9fd7-9b3b902a507a</guid>
      <pubDate>Thu, 09 Oct 2008 10:31:03 GMT</pubDate>
    </item>
    <item>
      <title>Silverlight TreeView Load on Demand</title>
      <description>&lt;p&gt;Today I created a really simple application that demonstrates &amp;quot;best practice&amp;quot; for using RadTreeView with load on demand and ADO.NET Data Service. &lt;/p&gt;  &lt;p&gt;The application uses the Northwind database, that can be &lt;a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?FamilyID=06616212-0356-46A0-8DA2-EEBC53A68034&amp;amp;displaylang=en"&gt;downloaded here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The tricky part is that in order to create almost codeless application we need to modify the automatically generated code of the service reference. To do that you will need to show all files in the Silverlight application (click the Show All Files in the Solution Explorer title bar) and then open Reference.cs:&lt;/p&gt;  &lt;p&gt;&lt;img style="border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px" border="0" alt="SolutionExplorer" src="http://blogs.telerik.com/Libraries/MetaBlog/WindowsLiveWriter-SilverlightTreeViewLoadonDemand_C704-SolutionExplorer_3%20(1).sflb" width="362" height="352" /&gt; &lt;/p&gt;  &lt;p&gt;In this file replace all occurrences of &amp;quot;System.Collections.ObjectModel.Collection&amp;quot; with &amp;quot;System.Collections.ObjectModel.ObservableCollection&amp;quot;. This probably will be changed in the RTM of Silverlight, but at the moment, there is no way to choose the data type of the collections in the generated code for ADO.NET data service. Note that you will have to repeat the replacement every time you update the service reference! &lt;/p&gt;  &lt;p&gt;The rest of the application is really simple: a RadTreeView, bound to a data source object, that has a property Categories; when the LoadOnDemand event of RadTreeView is fired, the selected category asynchronously loads its related products:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; RadTreeView_LoadOnDemand(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, &lt;br /&gt;    Telerik.Windows.RadRoutedEventArgs e)
{
    RadTreeViewItem item = e.OriginalSource &lt;span class="kwrd"&gt;as&lt;/span&gt; RadTreeViewItem;

    Category category = item.Item &lt;span class="kwrd"&gt;as&lt;/span&gt; Category;
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (category != &lt;span class="kwrd"&gt;null&lt;/span&gt;)
    {
        NorthwindDataSource.BeginLoadingProducts(category);
    }
    &lt;span class="kwrd"&gt;else&lt;/span&gt;
    {
        item.IsLoadOnDemandEnabled = &lt;span class="kwrd"&gt;false&lt;/span&gt;;
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The hierarchy of the treeview is defined in its item template:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;ProductTemplate&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{Binding ProductName}&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;DataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;telerik:HierarchicalDataTemplate&lt;/span&gt; &lt;span class="attr"&gt;x:Key&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;CategoryTemplate&amp;quot;&lt;/span&gt; &lt;span class="attr"&gt;ItemsSource&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{Binding Products}&amp;quot;&lt;/span&gt;
        &lt;span class="attr"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{StaticResource ProductTemplate}&amp;quot;&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextBlock&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;=&amp;quot;{Binding CategoryName}&amp;quot;&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;telerik:HierarchicalDataTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;

    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, "Courier New", courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Since the first load of the categories is also asynchronous, it takes some time to display the treeview for the first time. I added a simple loading animation, that stops when the treeview is filled with items.&lt;/p&gt;

&lt;p&gt;Download the source from here: &lt;a href="/Libraries/Valeri Hristov/TreeViewLoadOnDemand.sflb"&gt;TreeViewLoadOnDemand&lt;/a&gt;&lt;/p&gt;</description>
      <link>http://blogs.telerik.com/ValeriHristov/Posts/08-10-08/Silverlight_TreeView_Load_on_Demand.aspx</link>
      <author>valeri</author>
      <comments>http://blogs.telerik.com/ValeriHristov/Posts/08-10-08/Silverlight_TreeView_Load_on_Demand.aspx</comments>
      <guid isPermaLink="false">dc28e3bf-dad6-43ff-8322-058b5da86d00</guid>
      <pubDate>Wed, 08 Oct 2008 02:00:00 GMT</pubDate>
    </item>
    <item>
      <title>Adding Mouse Wheel support in Silverlight. The easy way.</title>
      <description>&lt;p&gt;One of the best uses of &lt;a href="http://blogs.telerik.com/HristoHristov/Posts/08-07-23/Routed_Events_in_Silverlight_2.aspx?ReturnURL=%2fBlogs.aspx" title="Routed Events for Silverlight"&gt;our Routed Event extension&lt;/a&gt; is implementing missing system events in Silverlight, such as MouseWheel and RightButtonUp/Down. The API we provide is the same as WPF, so when Silverlight eventually gets support for those events, most probably you will not have to change much. Other good thing is that you do not need to write any JavaScript, or to know what's going on beneath. The bad thing is that you will have to &lt;a href="http://msdn.microsoft.com/en-us/library/cc189089(VS.95).aspx#object_optionalparameters" title="Silverlight Object optional parameters reference"&gt;enable the windowless mode&lt;/a&gt; of the Silverlight plug-in, which will slightly decrease the performance of your application.&lt;/p&gt;
&lt;p&gt;To attach a Routed Event handler for the MouseWheel event on a ScrollViewer you need to add the following code in the constructor of your Silverlight Page:&lt;/p&gt;
&lt;div style="border-right: #7f9db9 1px solid; font-size: 11px; border-top: #7f9db9 1px solid; overflow: auto; border-left: #7f9db9 1px solid; line-height: 100%! important; border-bottom: #7f9db9 1px solid; font-family: courier new; height: 50px; background-color: white"&gt;
&lt;table style="border-top-width: 0px; border-left-width: 0px; margin: 2px 0px; width: 99%; border-bottom: #eee 0px solid; border-collapse: collapse; background-color: #fff; border-right-width: 0px" cellspacing="0" cellpadding="0"&gt;
    &lt;colgroup&gt;&lt;col style="padding-left: 10px; font-size: 11px; border-bottom: #f7f7f7 1px solid; font-family: courier new; white-space: nowrap" /&gt;&lt;/colgroup&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size: 11px"&gt;Mouse.AddMouseWheelHandler(ScrollViewer1, &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;span style="font-size: 11px"&gt; EventHandler&amp;lt;MouseWheelEventArgs&amp;gt;(OnMouseWheelHandler));  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt; &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Additionaly, you will have to declare the OnMouseWheelHandler method:&lt;/p&gt;
&lt;div style="border-right: #7f9db9 1px solid; font-size: 11px; border-top: #7f9db9 1px solid; overflow: auto; border-left: #7f9db9 1px solid; line-height: 100%! important; border-bottom: #7f9db9 1px solid; font-family: courier new; background-color: white"&gt;
&lt;table style="border-top-width: 0px; border-left-width: 0px; margin: 2px 0px; width: 99%; border-bottom: #eee 0px solid; border-collapse: collapse; background-color: #fff; border-right-width: 0px" cellspacing="0" cellpadding="0"&gt;
    &lt;colgroup&gt;&lt;col style="padding-left: 10px; font-size: 11px; border-bottom: #f7f7f7 1px solid; font-family: courier new; white-space: nowrap" /&gt;&lt;/colgroup&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size: 11px"&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;static&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;void&lt;/span&gt;&lt;span style="font-size: 11px"&gt; OnMouseWheelHandler(&lt;/span&gt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&lt;span style="font-size: 11px"&gt; sender, MouseWheelEventArgs args)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;{  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    &lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="font-size: 11px"&gt; (e.Handled)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    {  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;        &lt;span style="color: blue"&gt;return&lt;/span&gt;&lt;span style="font-size: 11px"&gt;;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    }  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    ScrollViewer scrollViewer = sender &lt;span style="color: blue"&gt;as&lt;/span&gt;&lt;span style="font-size: 11px"&gt; ScrollViewer;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    &lt;span style="color: blue"&gt;int&lt;/span&gt;&lt;span style="font-size: 11px"&gt; scrollDelta = 40 * args.Delta / 3;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    &lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="font-size: 11px"&gt; (scrollViewer.ComputedVerticalScrollBarVisibility == Visibility.Visible)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    {  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;        scrollViewer.ScrollToVerticalOffset(  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;            Math.Min(scrollViewer.ScrollableHeight,  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;                 scrollViewer.VerticalOffset - scrollDelta));  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;        e.Handled = &lt;span style="color: blue"&gt;true&lt;/span&gt;&lt;span style="font-size: 11px"&gt;;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    }  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    &lt;span style="color: blue"&gt;else&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="font-size: 11px"&gt; (scrollViewer.ComputedHorizontalScrollBarVisibility == Visibility.Visible)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    {  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;        scrollViewer.ScrollToHorizontalOffset(  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;            Math.Min(scrollViewer.ScrollableWidth,  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;                 scrollViewer.HorizontalOffset - scrollDelta));  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;        e.Handled = &lt;span style="color: blue"&gt;true&lt;/span&gt;&lt;span style="font-size: 11px"&gt;;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    }  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;}  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt; &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately, the method above is not suitable for enhancing controls which have internal ScrollViewer, such as the standard ListBox, because you cannot get a reference to its ScrollViewer, in order to attach the Routed Event handler. In this case you could create a Class Handler for the ScrollViewer type:&lt;/p&gt;
&lt;div style="border-right: #7f9db9 1px solid; font-size: 11px; border-top: #7f9db9 1px solid; overflow: auto; border-left: #7f9db9 1px solid; line-height: 100%! important; border-bottom: #7f9db9 1px solid; font-family: courier new; background-color: white"&gt;
&lt;table style="border-top-width: 0px; border-left-width: 0px; margin: 2px 0px; width: 99%; border-bottom: #eee 0px solid; border-collapse: collapse; background-color: #fff; border-right-width: 0px" cellspacing="0" cellpadding="0"&gt;
    &lt;colgroup&gt;&lt;col style="padding-left: 10px; font-size: 11px; border-bottom: #f7f7f7 1px solid; font-family: courier new; white-space: nowrap" /&gt;&lt;/colgroup&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size: 11px"&gt;EventManager.RegisterClassHandler(&lt;/span&gt;&lt;span style="color: blue"&gt;typeof&lt;/span&gt;&lt;span style="font-size: 11px"&gt;(ScrollViewer), Mouse.MouseWheelEvent, &lt;/span&gt;&lt;span style="color: blue"&gt;new&lt;/span&gt;&lt;span style="font-size: 11px"&gt; EventHandler&amp;lt;MouseWheelEventArgs&amp;gt;(OnMouseWheelHandler));  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt; &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In this case, since it will affect ALL ScrollViewer controls on the page, the OnMouseWheelHandler method should be slightly different in order to avoid interference with the Telerik controls, which already have mouse wheel support:&lt;/p&gt;
&lt;div style="border-right: #7f9db9 1px solid; font-size: 11px; border-top: #7f9db9 1px solid; overflow: auto; border-left: #7f9db9 1px solid; line-height: 100%! important; border-bottom: #7f9db9 1px solid; font-family: courier new; background-color: white"&gt;
&lt;table style="border-top-width: 0px; border-left-width: 0px; margin: 2px 0px; width: 99%; border-bottom: #eee 0px solid; border-collapse: collapse; background-color: #fff; border-right-width: 0px" cellspacing="0" cellpadding="0"&gt;
    &lt;colgroup&gt;&lt;col style="padding-left: 10px; font-size: 11px; border-bottom: #f7f7f7 1px solid; font-family: courier new; white-space: nowrap" /&gt;&lt;/colgroup&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size: 11px"&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;private&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;static&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;void&lt;/span&gt;&lt;span style="font-size: 11px"&gt; OnMouseWheelHandler(&lt;/span&gt;&lt;span style="color: blue"&gt;object&lt;/span&gt;&lt;span style="font-size: 11px"&gt; sender, MouseWheelEventArgs args)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;{  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    &lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="font-size: 11px"&gt; (e.Handled || !ListBox1.IsAncestorOf(scrollViewer))   &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    {  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;        &lt;span style="color: blue"&gt;return&lt;/span&gt;&lt;span style="font-size: 11px"&gt;;   &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    }   &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    ...  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;}  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt; &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The check could be modified to exclude certain controls, e.g. if you have only a couple of Telerik controls on your page and lots ot other controls, containing ScrollViwers, you could disable the handler only for the Telerik controls and enhance all other ScrollViwers on the page.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;IsAncestorOf&lt;/strong&gt; method is an extension method, that you could declare in some static class in your application as:&lt;/p&gt;
&lt;div style="border-right: #7f9db9 1px solid; font-size: 11px; border-top: #7f9db9 1px solid; overflow: auto; border-left: #7f9db9 1px solid; line-height: 100%! important; border-bottom: #7f9db9 1px solid; font-family: courier new; background-color: white"&gt;
&lt;table style="border-top-width: 0px; border-left-width: 0px; margin: 2px 0px; width: 99%; border-bottom: #eee 0px solid; border-collapse: collapse; background-color: #fff; border-right-width: 0px" cellspacing="0" cellpadding="0"&gt;
    &lt;colgroup&gt;&lt;col style="padding-left: 10px; font-size: 11px; border-bottom: #f7f7f7 1px solid; font-family: courier new; white-space: nowrap" /&gt;&lt;/colgroup&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td&gt;&lt;span style="font-size: 11px"&gt;&lt;/span&gt;&lt;span style="color: blue"&gt;public&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;static&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;bool&lt;/span&gt;&lt;span style="font-size: 11px"&gt; IsAncestorOf(&lt;/span&gt;&lt;span style="color: blue"&gt;this&lt;/span&gt;&lt;span style="font-size: 11px"&gt; FrameworkElement target, FrameworkElement element)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;{  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    &lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="font-size: 11px"&gt; (target == element)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    {   &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;        &lt;span style="color: blue"&gt;return&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;true&lt;/span&gt;&lt;span style="font-size: 11px"&gt;;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    }  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    FrameworkElement parent = VisualTreeHelper.GetParent(element) &lt;span style="color: blue"&gt;as&lt;/span&gt;&lt;span style="font-size: 11px"&gt; FrameworkElement;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    &lt;span style="color: blue"&gt;while&lt;/span&gt;&lt;span style="font-size: 11px"&gt; (parent != &lt;/span&gt;&lt;span style="color: blue"&gt;null&lt;/span&gt;&lt;span style="font-size: 11px"&gt;)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    {  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;        &lt;span style="color: blue"&gt;if&lt;/span&gt;&lt;span style="font-size: 11px"&gt; (parent == target)  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;        {  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;            &lt;span style="color: blue"&gt;return&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;true&lt;/span&gt;&lt;span style="font-size: 11px"&gt;;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;        }  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;        parent = VisualTreeHelper.GetParent(parent) &lt;span style="color: blue"&gt;as&lt;/span&gt;&lt;span style="font-size: 11px"&gt; FrameworkElement;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;    }  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt;    &lt;span style="color: blue"&gt;return&lt;/span&gt;&lt;span style="font-size: 11px"&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;false&lt;/span&gt;&lt;span style="font-size: 11px"&gt;;  &lt;/span&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td&gt;}  &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td style="background-color: #f7f7f7"&gt; &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Of course, the MouseWheel event is not limited to just scrolling ScrollViewer controls. For example, RadSlider and RadNumericUpDown use the MouseWheel event to change their values, you could zoom-in/out a DeepZoom image, etc. The possibilities are endless.&lt;/p&gt;
&lt;p&gt;Attached is the &lt;a href="/Libraries/Valeri Hristov/WheelScroller.sflb"&gt;source&lt;/a&gt;, containing the refactored code from the above. Happly MouseWheeling :)&lt;/p&gt;
</description>
      <link>http://blogs.telerik.com/ValeriHristov/Posts/08-07-24/Adding_Mouse_Wheel_support_in_Silverlight_The_easy_way.aspx</link>
      <author>Valeri Hristov</author>
      <comments>http://blogs.telerik.com/ValeriHristov/Posts/08-07-24/Adding_Mouse_Wheel_support_in_Silverlight_The_easy_way.aspx</comments>
      <guid isPermaLink="false">358fe672-d7b1-4a3b-a8f5-6d403da3adf2</guid>
      <pubDate>Thu, 24 Jul 2008 00:00:00 GMT</pubDate>
    </item>
    <item>
      <title>Disabling Full Row Selection in Vista Explorer</title>
      <description>&lt;p&gt;One of the things that irritates me the most in Vista is the enabled by default Full Row Selection in Explorer. To see what I'm talking about open an Explorer window in Details View and try to select files with dragging a rectangle. I googled a bit and found that there is a solution for the problem:&lt;/p&gt;
&lt;span id="_ctl0_MainContent_PostFlatView"&gt;&lt;span&gt;
&lt;div&gt;Under the key:&lt;/div&gt;
&lt;div&gt; [HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;Create a new REG_DWORD value named FullRowSelect. Leave it's data as 0x0 and you are set. &lt;/div&gt;
&lt;div&gt; &lt;/div&gt;
&lt;div&gt;After some more digging, I found several scripts which will automatically set and unset this key for you:&lt;/div&gt;
&lt;div&gt;&lt;a href="http://home.mchsi.com/~k.miller79/" title="Windows Vista Explorer Scripts"&gt;Keith Miller' Windows Stuff&lt;/a&gt; &lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I hope this helps.&lt;/p&gt;
</description>
      <link>http://blogs.telerik.com/ValeriHristov/Posts/08-07-22/Disabling_Full_Row_Selection_in_Vista_Explorer.aspx</link>
      <author>Valeri Hristov</author>
      <comments>http://blogs.telerik.com/ValeriHristov/Posts/08-07-22/Disabling_Full_Row_Selection_in_Vista_Explorer.aspx</comments>
      <guid isPermaLink="false">d4431e7e-6515-4bec-82cd-2086b2a877cb</guid>
      <pubDate>Tue, 22 Jul 2008 02:59:33 GMT</pubDate>
    </item>
    <item>
      <title>Increasing the compression ratio of the XAP files</title>
      <description>&lt;p&gt;Today I was hacking around with a Silverlight application and decided to check if it is possible to recompress its XAP file in order to save some bytes. As you might already know, the XAP files are just renamed ZIP files and you can open and view their contents with almost any archiver.&lt;br /&gt;
&lt;br /&gt;
I created a simple batch file that extracts an archive to a temp folder, deletes it and then compresses the extracted files into a new archive with the same name as the original (I am using the open source archiver &lt;a href="http://www.7-zip.org/"&gt;7-Zip&lt;/a&gt;, which was installed in its default location):&lt;/p&gt;
&lt;pre&gt;@if exist %temp%\%2 rd /s /q %temp%\%2&lt;br /&gt;
@"c:\program files\7-zip\7z.exe" x -r -o%temp%\%2\ %2 *.*&amp;nbsp; &lt;br /&gt;
@del /q %2&lt;br /&gt;
@"c:\program files\7-zip\7z.exe" a -r -tzip -mx%1 %2 %temp%\%2\*.*&lt;/pre&gt;
&lt;p&gt;If you name the file recompress.bat, you could use it the following way:&lt;/p&gt;
&lt;pre&gt;recompress N SilverlightApplication1.xap&lt;/pre&gt;
&lt;p&gt;where N specifies the desired compression ratio and could be 1, 3, 5, 7 or 9. Note that in order to use the command line above, you should copy the batch file to the folder, where the application XAP file is located, usually &amp;lt;Project Root&amp;gt;\ClientBin.&lt;br /&gt;
&lt;br /&gt;
For testing I used our &lt;a href="http://www.telerik.com/demos/silverlight/QSFEngine/index.html"&gt;online demo&lt;/a&gt;, which has a 3.2MB XAP file:&lt;/p&gt;
&lt;p&gt;
&lt;table cellspacing="0" cellpadding="0" border="1" style="border: medium none ; border-collapse: collapse;"&gt;
    &lt;tbody&gt;
        &lt;tr&gt;
            &lt;td width="145" valign="top" style="border: 1pt solid black; padding: 0in 5.4pt; width: 108.9pt; background-color: transparent;"&gt;
            &lt;p style="margin: 0in 0in 0pt; line-height: normal;"&gt;Compression Ratio&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="84" valign="top" style="border-color: black black black rgb(212, 208, 200); border-top: 1pt solid black; border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 63pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;1 and 3&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="66" valign="top" style="border-color: black black black rgb(212, 208, 200); border-top: 1pt solid black; border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 49.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;5&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="66" valign="top" style="border-color: black black black rgb(212, 208, 200); border-top: 1pt solid black; border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 49.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;7&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="78" valign="top" style="border-color: black black black rgb(212, 208, 200); border-top: 1pt solid black; border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 58.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;9&lt;span&gt; (Max)&lt;/span&gt;&lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td width="145" valign="top" style="border-color: rgb(212, 208, 200) black black; border-left: 1pt solid black; border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 108.9pt; background-color: transparent;"&gt;
            &lt;p style="margin: 0in 0in 0pt; line-height: normal;"&gt;Compression Speed&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="84" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 63pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;Very Fast&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="66" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 49.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;Fast&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="66" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 49.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;Slow&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="78" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 58.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;Slower&lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
            &lt;td width="145" valign="top" style="border-color: rgb(212, 208, 200) black black; border-left: 1pt solid black; border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 108.9pt; background-color: transparent;"&gt;
            &lt;p style="margin: 0in 0in 0pt; line-height: normal;"&gt;Archive Size&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="84" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 63pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;2253kB&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="66" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 49.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;2184kB&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="66" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 49.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;2164kB&lt;/p&gt;
            &lt;/td&gt;
            &lt;td width="78" valign="top" style="border-color: rgb(212, 208, 200) black black rgb(212, 208, 200); border-right: 1pt solid black; border-bottom: 1pt solid black; padding: 0in 5.4pt; width: 58.5pt; background-color: transparent;"&gt;
            &lt;p align="center" style="margin: 0in 0in 0pt; line-height: normal; text-align: center;"&gt;2155kB&lt;/p&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    &lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;The batch file operation reduced the original XAP file size with more than a &lt;strong&gt;megabyte&lt;/strong&gt; with any compression ratio! Since the time to recompress with most ratios was less than a second, I decided to create a simple post-build command to process my application XAP file after each build. To use it copy (or move) the recompress.bat file into your project root folder and enter the following text in the "Post-build event command line" text box in the Build Events property pages of your Silverlight application:&lt;/p&gt;
&lt;pre&gt;pushd clientbin&lt;br /&gt;
..\recompress 3 $(projectname).xap&lt;br /&gt;
popd&lt;/pre&gt;
&lt;p&gt;I hope this helps :)&lt;/p&gt;
</description>
      <link>http://blogs.telerik.com/ValeriHristov/Posts/08-05-13/Increasing_the_compression_ratio_of_the_XAP_files.aspx</link>
      <author>Valeri Hristov</author>
      <comments>http://blogs.telerik.com/ValeriHristov/Posts/08-05-13/Increasing_the_compression_ratio_of_the_XAP_files.aspx</comments>
      <guid isPermaLink="false">17b5ee93-d43e-42cc-a791-7b906862b65c</guid>
      <pubDate>Tue, 13 May 2008 10:36:38 GMT</pubDate>
    </item>
  </channel>
</rss>