<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Silverlight on Ash Tewari</title><link>https://www.tewari.info/category/silverlight/</link><description>Recent content in Silverlight on Ash Tewari</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Tue, 07 Jun 2011 11:23:52 +0000</lastBuildDate><atom:link href="https://www.tewari.info/category/silverlight/feed.xml" rel="self" type="application/rss+xml"/><item><title>ChildWindow Positioning</title><link>https://www.tewari.info/2011/06/07/childwindow-positioning/</link><pubDate>Tue, 07 Jun 2011 11:23:52 +0000</pubDate><guid>https://www.tewari.info/2011/06/07/childwindow-positioning/</guid><description>&lt;p&gt;Silverlight &lt;a class="link" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.childwindow%28v=vs.95%29.aspx" title="MSDN_Silverlight_ChildWindow"&#10; target="_blank" rel="noopener"&#10; &gt;ChildWindow&lt;/a&gt; is centered over the parent control. I have extended ChildWindow to open it at a specific position.&lt;/p&gt;&#10;&lt;figure&gt;&lt;img src="https://www.tewari.info/images/PositionedChildWindow-screenshot.png"&#10;&#9;&#9;&#9;alt="Positioned ChildWindow"&gt;&lt;figcaption&gt;&#10;&#9;&#9;&#9;&lt;p&gt;Positioned ChildWindow&lt;/p&gt;&#10;&#9;&#9;&lt;/figcaption&gt;&#10;&lt;/figure&gt;&#10;&#10;&lt;p&gt;Here is a live demo : &lt;a class="link" href="https://www.tewari.info/childwindow-positioning-demo/" &gt;childwindow-positioning-demo&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;And here is the code :&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;public partial class ChildWindowEx : ChildWindow&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Point _pt = new Point(0,0);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; public ChildWindowEx()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; InitializeComponent();&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; public ChildWindowEx(Point pt) : this()&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; _pt = pt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; protected override Size ArrangeOverride(Size finalSize)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Grid grid = Utils.FindChild(this, &amp;#34;ContentRoot&amp;#34;);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; if (grid != null)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; grid.Arrange(new Rect(_pt.X, _pt.Y, grid.DesiredSize.Width, grid.DesiredSize.Height));&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; return finalSize;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; return base.ArrangeOverride(finalSize);&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Visual Studio 2010 Solution : &lt;a class="link" href="https://www.tewari.info/downloads/PositionedChildWindow.zip" &gt;download&lt;/a&gt;&lt;/p&gt;&#10;</description></item><item><title>Remove ListBoxItem Highlighting</title><link>https://www.tewari.info/2011/04/29/remove-listboxitem-highlighting/</link><pubDate>Sat, 30 Apr 2011 03:25:58 +0000</pubDate><guid>https://www.tewari.info/2011/04/29/remove-listboxitem-highlighting/</guid><description>&lt;p&gt;A Silverlight/Wpf ListBoxItem is highlighted when selected or when the mouse hovers over it.&lt;/p&gt;&#10;&lt;p&gt;I need to display a list of items that are not highlighted when selected. This is a common scenario when displaying an inactive list for simply listing out some information.&lt;/p&gt;&#10;&lt;p&gt;ListBoxItem&amp;rsquo;s default template can be easily inspected and modified using Expression Blend - Select a ListBoxItem in Objects and Timeline pane, Right click and select Edit template &amp;gt; Edit a Copy. Name you template and save it at the scope of your choice.&lt;/p&gt;&#10;&lt;p&gt;This will create a copy of the template and allow you to modify it. Switch to the xaml view. Locate the VisualStates of MouseOver, Selected and Focused, and blank them out -&lt;/p&gt;&#10;&lt;p&gt;&lt;img alt="de-highlighted-xaml" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://www.tewari.info/wp-content/2011-04-29_2257.png"&gt;&lt;/p&gt;&#10;&lt;p&gt;The style is applied to the ListBoxItems using ItemContainerStyle -&lt;/p&gt;&#10;&lt;p&gt;&lt;img alt="applying-style-to-listboxitems" loading="lazy" sizes="(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px" src="https://www.tewari.info/wp-content/2011-04-29_2307.png"&gt;&lt;/p&gt;&#10;&lt;p&gt;Here is the xaml style for the ListBoxItem -&lt;/p&gt;&#10;&lt;p&gt;After the style is applied, the ListBoxItems are not highlighted when selected or focused. Here is a live demo of a ListBox that does not highlight when items are selected : &lt;a class="link" href="https://www.tewari.info/remove-listboxitem-highlighting-demo/" &gt;remove-listboxitem-hlighting-demo&lt;/a&gt;&lt;/p&gt;&#10;</description></item></channel></rss>