<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jaime Rodriguez  : wpfdiscussion</title><link>http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx</link><description>Tags: wpfdiscussion</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>WPF discussions, 091101</title><link>http://blogs.msdn.com/jaimer/archive/2009/11/02/wpf-discussions-091101.aspx</link><pubDate>Mon, 02 Nov 2009 08:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9916056</guid><dc:creator>jaimer</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/9916056.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=9916056</wfw:commentRss><description>&lt;P&gt;As usual, raw, unedited, useful info from the Microsoft’s internal WPF discussions lists. 
&lt;HR&gt;
&lt;B&gt;Subject:&lt;/B&gt; All keys don't work in a WPF window when it is calling from a WinForm project. &lt;BR&gt;We had a big project developed in WinForm. Now I'm adding a new window to the project using WPF. The WPF window is now part of the project, i.e. it is not a separate project or dll. What happened now is any control that is supposed to accept keyboard inputs, such as textbox, does not respond to my keyboard input. The window only responds to mouse. 
&lt;P&gt;&lt;FONT color=#008000&gt;&lt;STRONG&gt;Answer: &lt;BR&gt;&lt;/STRONG&gt;You must use call the &lt;/FONT&gt;&lt;A href="http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.enablemodelesskeyboardinterop.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.enablemodelesskeyboardinterop.aspx"&gt;&lt;FONT color=#008000&gt;EnableModelessKeyboardInterop&lt;/FONT&gt;&lt;/A&gt;&lt;FONT color=#008000&gt; method for keyboard to work. &lt;BR&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;
&lt;STRONG&gt;Subject: Precision on WPF animations&lt;BR&gt;&lt;/STRONG&gt;This question was from a partner. they have some synchronization issue between their own animation and WPF animation. The difference of ~0.2 can happen because WPF animation precision depends on rendering timing, doesn’t it ? 
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer:&lt;/FONT&gt; &lt;BR&gt;&lt;/STRONG&gt;&lt;FONT color=#008000&gt;That's right - we do a number of things to sync with rendering.&amp;nbsp; &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;Time only "changes" at the start of a render pass, which is scheduled differently based on a number of factors (Desktop Window Manager present and enabled? Monitor refresh rate, desired framerate for animations, etc), and then too the time chosen is actually "in the future" a bit because we're trying to produce a set of changes that will be correct &lt;EM&gt;when they hit the screen&lt;/EM&gt;.&amp;nbsp; To do this, we estimate the future presentation time for a given UI thread's render pass.&amp;nbsp; My guess is that this is what they're seeing in this case&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;
&lt;B&gt;Subject:&lt;/B&gt;&amp;nbsp; Using Blend Behavior in Style? &lt;BR&gt;Why am I getting an error when setting a Behavior in a style. Isn’t Blend Interaction an AttachedProperty? 
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer:&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color=#008000&gt;Blend’s behaviors are an attached property, but publicly they are not exposed as a DP- you can do attached properties that are not DP’s by having just the static GetProperty/SetProperty.&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;We use this syntax to keep the behavior syntax smaller- by not using a real DP here we were able to default the collection to having a value and remove 2 lines of XAML. If this were a real DP then you’d have to add the collection to the XAML as well:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;lt;Button&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp; &amp;lt;i:Interaction.Behaviors&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;lt;i:BehaviorCollection&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:SimpleBehavior/&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;lt;/i:BehaviorCollection&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp; &amp;lt;/i:Interaction.Behaviors&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;lt;/Button&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;In addition behaviors cannot be used inside of styles; the core issue is that we intentionally made behaviors not sharable- you can’t apply the same behavior to multiple elements. The reason is that if you use the WPF animation API as an example that it adds a ton of complexity to make the types sharable and it really detracts from the level of simplicity that we were looking for in Behaviors.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;In WPF, everything applied through a style is shared&amp;nbsp; across each element that it’s applied to. To get around this in early prototypes I used a trick with Freezables and the CoerceValueCallback to clone the behaviors every time they’re applied to an element and are already applied to something else, but none of this is present in SL and it can lead to some unexpected runtime behavior.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;
&lt;B&gt;Subject:&lt;/B&gt; Best Match for ICO in WPF? &lt;BR&gt;Is there a built-in way in the WPF 4.0 imaging classes to get a “best match” for a multi-frame ICO? 
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer:&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color=#008000&gt;We don’t have any automatic selection logic. You can iterate over all of the frames and find the one you want based upon each frame’s properties. You should be able to get them all from a frame by doing frame.Decoder.Frames. Alternatively, you can just do BitmapDecoder.Create and read the frames that way rather than indirectly through BitmapFrame.Create.&lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;Note: pre-Win7 WIC does not support Vista’s PNG icon frames. If you hit a PNG frame you will get an exception on Vista and XP.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;
&lt;B&gt;Subject:&lt;/B&gt; Binding and Custom Type Descriptors &lt;BR&gt;In WPF we’re binding an object that has a custom type descriptor and are wondering if there is a way to get around a couple issues: 
&lt;P&gt;1. Is there a way to get WPF to listen to these changes given that WPF does not appear to subscribe to change events via PropertyDescriptor.AddValueChanged? &lt;BR&gt;It appears that WPF will bind to the properties offered through the type descriptor, but WPF does not monitor that type descriptor for value changes.&amp;nbsp;&amp;nbsp;&amp;nbsp; It does appear to listen to INotifyPropertyChanged events, but this is not that useful if we are extending and object with custom properties. &lt;/P&gt;
&lt;P&gt;2. Is there a way to have WPF bypass ICustomTypeDescriptor.GetProperties() when setting up a binding? In this case, custom types may hide the thing we actually want to bind to, so it would be useful to force WPF not to use the custom descriptor during binding.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer:&lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color=#008000&gt;1. WPF &lt;I&gt;will&lt;/I&gt; listen to ValueChanged if the object doesn’t implement INotifyPropertyChanged.&amp;nbsp; If both are available we only listen to INPC, to avoid duplicate notifications.&amp;nbsp; There are objects that expose both – chiefly ADO.Net’s DataRowView – so it’s a real issue.&amp;nbsp;&amp;nbsp; If you have appropriate access, you can get the object to raise the PropertyChanged event with a property name for your custom property.&amp;nbsp; But if it’s not your object (and its OnPropertyChanged method is private), you’re out of luck.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;2. No.&amp;nbsp; We actually call TypeDescriptor.GetProperties(item), which in turn calls ICTD.GetProperties, so it’s out of our hands.&amp;nbsp; Usually people want the custom descriptor to override the native one;&amp;nbsp; we don’t have any way to ask for the other way around.&amp;nbsp; (I’m curious what your scenario is, though.&amp;nbsp; This is the first time someone’s asked for this.)&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;FONT color=#008000&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Subject:&lt;/B&gt; Binding to dictionary with multiple indexers &lt;BR&gt;If I add a second indexer to a collection class, it will no longer bind to WPF FrameworkElement such that its index path can be referenced. &lt;BR&gt;The following works fine on regular collection, But I add a second indexer, or if the collection is keyed, the binding no longer works:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Path=[0].&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer: &lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color=#008000&gt;Your two indexers have different signatures, probably something like&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public object this[int index] { …}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public object this[string s] {…}&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;The property path is declared in XAML, where everything is a string.&amp;nbsp; So when you say “Path=[0]”, WPF has to decide whether you mean the first indexer with argument (int)0, or the second indexer with argument (string)”0”.&amp;nbsp;&amp;nbsp; There’s nothing in the XAML to indicate which one you mean, so I think we choose the line of least resistance and pick the second indexer – it requires no type conversion.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;At any rate, you can provide the missing guidance by saying&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Path=[(sys:Int32)0]&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;assuming you’ve previously declared&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:sys=”clr-namespace:System;assembly=mscorlib”&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;This says what you think it does:&amp;nbsp; “use the indexer that takes an int argument”.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;B&gt;Subject:&lt;/B&gt; SketchFlow transitions between screens? &lt;BR&gt;Is it possible to create transitions between screens in SketchFlow?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer: &lt;BR&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color=#008000&gt;It should be doing this by default. The default transition is a fade, if you right-click a navigation connection in the map, there are a few more to choose from “Transition Styles”.&lt;/FONT&gt; &lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;B&gt;Subject:&lt;/B&gt; RE: How to improve the text rendering of your .NET 4.0 WPF Applications&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&lt;STRONG&gt;Answer: &lt;BR&gt;&lt;/STRONG&gt;Important caveat: Do not use TextFormattingMode=”Display” on text that is going to be scaled by a RenderTransform (or scaled in any way other than by changing the font size). It will end up blurry. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;Some more recommendations: &lt;/FONT&gt;&lt;A href="http://blogs.msdn.com/text/archive/2009/08/24/wpf-4-0-text-stack-improvements.aspx" mce_href="http://blogs.msdn.com/text/archive/2009/08/24/wpf-4-0-text-stack-improvements.aspx"&gt;&lt;FONT color=#008000&gt;http://blogs.msdn.com/text/archive/2009/08/24/wpf-4-0-text-stack-improvements.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;B&gt;Subject:&lt;/B&gt; RE: Partner's question about WPF-Image convert &amp;amp; Flash support&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;There are external EMF-&amp;gt;XAML converters:&lt;BR&gt;&lt;/FONT&gt;&lt;A href="http://www.wpf-graphics.com/Paste2Xaml.aspx" mce_href="http://www.wpf-graphics.com/Paste2Xaml.aspx"&gt;&lt;FONT color=#008000&gt;http://www.wpf-graphics.com/Paste2Xaml.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;BR&gt;&lt;A href="http://www.verydoc.com/emf2vector/emf-to-xps.html" mce_href="http://www.verydoc.com/emf2vector/emf-to-xps.html"&gt;&lt;FONT color=#008000&gt;http://www.verydoc.com/emf2vector/emf-to-xps.html&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;Indeed, WPF does not provide any native flash rendering.&amp;nbsp; I doubt we ever will.&amp;nbsp; Some options: &lt;BR&gt;&lt;/FONT&gt;&lt;FONT color=#008000&gt;1) Host a web browser.&amp;nbsp; Yes this is HWND interop code, so there are some compromises: the infamous airspace issues being the most prominent.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;2) For display only, you might look at a DirectShow filter, like: &lt;/FONT&gt;&lt;A href="http://www.medialooks.com/products/directshow_filters/flash_source.html" mce_href="http://www.medialooks.com/products/directshow_filters/flash_source.html"&gt;&lt;FONT color=#008000&gt;http://www.medialooks.com/products/directshow_filters/flash_source.html&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;B&gt;Subject:&lt;/B&gt; Property increment value i nBlend &lt;BR&gt;If you expose a numeric property on a type and it is available in the&amp;nbsp; property window you can change the value by dragging the cursor up, down, left and right.&amp;nbsp; Is there a way to tell Blend what the incremental value should be?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;Yes, you need to supply a design-time assembly that uses the NumberIncrementsAttribute. &lt;BR&gt;&lt;BR&gt;&lt;/FONT&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;public sealed class &lt;B&gt;&lt;A href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://Microsoft.Windows.Design.Interaction:4.0.0.0:b03f5f7f11d50a3a/Microsoft.Windows.Design.PropertyEditing.NumberIncrementsAttribute" mce_href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://Microsoft.Windows.Design.Interaction:4.0.0.0:b03f5f7f11d50a3a/Microsoft.Windows.Design.PropertyEditing.NumberIncrementsAttribute"&gt;NumberIncrementsAttribute&lt;/A&gt;&lt;/B&gt; : &lt;/FONT&gt;&lt;A href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Attribute" mce_href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://mscorlib:2.0.0.0:b77a5c561934e089/System.Attribute"&gt;&lt;FONT color=#008000&gt;Attribute&lt;/FONT&gt;&lt;/A&gt;&lt;FONT color=#008000&gt;, &lt;/FONT&gt;&lt;A href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://Microsoft.Windows.Design.Interaction:4.0.0.0:b03f5f7f11d50a3a/Microsoft.Windows.Design.PropertyEditing.IIndexableAttribute" mce_href="http://www.aisto.com/roeder/dotnet/Default.aspx?Target=code://Microsoft.Windows.Design.Interaction:4.0.0.0:b03f5f7f11d50a3a/Microsoft.Windows.Design.PropertyEditing.IIndexableAttribute"&gt;&lt;FONT color=#008000&gt;IIndexableAttribute&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width="8%"&gt;
&lt;P&gt;&lt;B&gt;&lt;FONT color=#008000&gt;Name:&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD vAlign=top&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;Microsoft.Windows.Design.PropertyEditing.NumberIncrementsAttribute&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width="8%"&gt;
&lt;P&gt;&lt;B&gt;&lt;FONT color=#008000&gt;Assembly:&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;&lt;/TD&gt;
&lt;TD vAlign=top&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;Microsoft.Windows.Design.Interaction, Version=4.0.0.0&lt;/FONT&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/unnir/archive/2009/03/22/writing-a-design-time-experience-for-a-silverlight-control.aspx" mce_href="http://blogs.msdn.com/unnir/archive/2009/03/22/writing-a-design-time-experience-for-a-silverlight-control.aspx"&gt;&lt;FONT color=#008000&gt;http://blogs.msdn.com/unnir/archive/2009/03/22/writing-a-design-time-experience-for-a-silverlight-control.aspx&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;B&gt;Subject:&lt;/B&gt; pack: registration?&lt;/P&gt;
&lt;P&gt;I forget, how do you open a pack: URI? &lt;BR&gt;I tried using WebRequest.Create, but that gave me an error saying that pack: wasn’t registered… Then I tried using PackUriHelper to cause it’s static cctor to run, to try and get the prefix registered… PackWebRequest isn’t constructable (from what I can see)… &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;[Multiple interesting data points] &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;#1 System.Windows.Application has a static ctor where ResourceContainer package is added to PreloadedPackages so that downstream PackWebRequestFactory can find it. So you need to be running in the context of an Avalon application to get this.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;#2&amp;nbsp; If you use PackUriHelper class, the “pack:” prefix gets registered with the System.Uri class and this helps in performing the correct parsing and construction of System.Uri objects for pack Uris.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;The other registration is of the pack: scheme with WebRequest so that you can use WebRequest.Create method to return the PackWebRequest object. This can be done in your code. PackWebRequestFactory does not register it. You could use PackWebRequestFactory directly to get the PackWebRequest too –&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;PackWebRequest request = (PackWebRequest)((IWebRequestCreate)new PackWebRequestFactory()).Create(packUri);&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;STRONG&gt;Subject:&lt;/STRONG&gt; RichTextBox viewable area&lt;/P&gt;
&lt;P&gt;Is there any way to get the viewable area in a RichTextBox?&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer: &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;TextPointer upperLeftCorner = rtb.GetPositionFromPoint(new Point(0, 0), true /* snapToText */); TextPointer lowerRightCorner = rtb.GetPositionFromPoint(new Point(rtb.ActualWidth, rtb.ActualHeight), true /* snapToText */);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;You could refine this to get a tighter fit by looking at RichTextBox.ViewportWidth/ViewportHeight, to omit space for surrounding chrome like the possibly visible ScollViewer or Border. But for optimizing a property set on the viewable area first, including a small amount of extra content around the viewport is probably fine.&lt;/FONT&gt;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;&lt;B&gt;Subject:&lt;/B&gt; ValidatesOnDataErrors not working on bindings inside an ItemsControl.&lt;/P&gt;
&lt;P&gt;I noticed that ValidatesOnDataErrors is not working on bindings inside an ItemsControl.ItemTemplate. I confirmed this problem has been fixed in Framework 4.0 but our target is 3.5.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color=#008000&gt;Answer: &lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;the workaround is to use the “long” form of ValidatesOnDataErrors:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;lt;Binding.ValidationRules&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;DataErrorValidationRule/&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&amp;lt;/Binding.ValidationRules&amp;gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#008000&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR&gt;

&lt;P&gt;Happy coding!! &lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9916056" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx">wpfdiscussion</category></item><item><title>WPF Discussion 090922</title><link>http://blogs.msdn.com/jaimer/archive/2009/09/22/wpf-discussion-090922.aspx</link><pubDate>Tue, 22 Sep 2009 10:52:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9897892</guid><dc:creator>jaimer</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/9897892.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=9897892</wfw:commentRss><description>&lt;p&gt;Raw, unedited, insightful and deep content from our internal WPF discussion… &lt;/p&gt;  &lt;hr /&gt;&lt;b&gt;Subject:&lt;/b&gt; Any chance of INotifyCollectionChanged moving to the core .NET libraries?   &lt;p&gt;The&amp;#160; System.Collections.Specialized.INotifyCollectionChanged interface is defined in WindowsBase.dll (primarily a WPF assembly) but my customer believes it should be pushed down into the core BCL so that other project types can benefit from it without requiring a reference to WPF/WindowsBase.&lt;/p&gt;  &lt;p&gt;Is this planned for 4.0 or later?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;INotifyCollectionChanged, ObservableCollection&amp;lt;T&amp;gt;, and ReadOnlyObservableCollection&amp;lt;T&amp;gt; have been type forwarded into System.dll for .NET 4.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Why TextRange.Load(MemoryStream, DataFormats.Xaml) can not work?&lt;/p&gt;  &lt;p&gt;I am trying to load a flowdocument from a Xaml file using TextRange.Load(MemoryStream, DataFormats.Xaml) method, but the following code does not work:&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; FlowDocument f = new FlowDocument();&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; TextRange range = new TextRange(f.ContentStart, f.ContentEnd);&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; StreamReader sr = new StreamReader(@&amp;quot;TextFile1.xaml&amp;quot;);&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; string aa = sr.ReadToEnd();&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; MemoryStream ms = new MemoryStream(System.Text.Encoding.Default.GetBytes(aa));&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; range.Load(ms, System.Windows.DataFormats.Xaml);&lt;/p&gt;  &lt;p&gt;I know if I use XamlReader.Load method will do the trick, but I don’t understand why the above code can’t work. Is this a bug or I am missing something?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;DataFormats.Xaml (and XamlPackage) are misleading – when consumed by TextRange.Load they only work on a subset of xaml generated by TextRange.Save.&amp;#160; The TextRange.Save/Load api is intended for editing scenarios where you need to persist arbitrary selections that may cross element boundaries (e.g., you need to save half of a Paragraph).&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;For your scenario, where you’re loading loose xaml from a file, XamlReader is the way to go.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; What is &amp;quot;Unlabeled time&amp;quot; in Visual Proiler that is part of Performance Profiling Tools for WPF?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Any CPU time that we aren’t able to attribute to a specific WPF operation goes in the unlabeled bucket.&amp;#160; This includes time spent in CLR operations such as garbage collection and time spent in the application’s own code.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Accessibility issue with WPF DataGrid and NewItemPlaceholder&lt;/p&gt;  &lt;p&gt;We’ve run into an accessibility issue with the WPF DataGrid concerning the NewItemPlaceholder.&amp;#160; Specifically, we’re re-templating the placeholder control in order to add a “real” click-here-to-add-a-new-item button.&amp;#160; However, none of the UI elements in the new template are available to accessibility-based automation (i.e. the button does not show up in UISpy or AccExplorer).&amp;#160; The template is set during the DataGrid LoadingRow event and looks like this:&lt;/p&gt;  &lt;p&gt;&amp;lt;ControlTemplate x:Key=&amp;quot;SafeControlNewRowControlTemplate&amp;quot; TargetType=&amp;quot;{x:Type DataGridRow}&amp;quot;&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;SelectiveScrollingGrid&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;Button Content=&amp;quot;Click here to add a new item.&amp;quot; Margin=&amp;quot;5,5,0,0&amp;quot; x:Uid=&amp;quot;AssemblyDialogWindow_SafeControlAddNewItem&amp;quot; Click=&amp;quot;OnSafeControlNewRowButtonClicked&amp;quot;/&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;/SelectiveScrollingGrid&amp;gt;&lt;/p&gt;  &lt;p&gt;&amp;lt;/ControlTemplate&amp;gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Yeah the AutomationPeers for all of the DataGrid components are structured around rows and cells. In your scenario you are retemplating a row (NewItemPlaceHolder row) so it does not have cells. Unfortunately the AutomationPeers do not recognize this. So you will in fact need to jump through some hoops to enable this scenario.&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font color="#008000"&gt;Subclass DataGridRowAutomationPeer and override GetChildrenCore to special case NewItemPlaceHolder row and return the visual children instead of the cells.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Subclass DataGridRow and override OnCreateAutomationPeer to return the subclassed DataGridRowAutomationPeer.&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Subclass DataGrid and override GetContainerForItemOverride to return the subclassed DataGridRow.&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Adding ContextMenu to DataGrid header&lt;/p&gt;  &lt;p&gt;I am using WPF 4.0 DataGrid and want to add context menu only to the header. The way that I found to do is to add a ContextMenu setter property to a style and assign the style to the DataGrid.ColumnHeaderStyle.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;font color="#008000"&gt;Answer: This is the right way of setting the context menu on DataGridColumnHeader (either using an implicit style for DataGridColumnHeader or setting it explicitly using ColumnHeaderStyle property).&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;But this puts restriction that a style needs to be added to the ColumnHeader. Performing SetValue on “DataGridColumnHeader.ContextMenuProperty” somehow sets it for the entire grid. The context menu should only be for the header.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;font color="#008000"&gt;Answer:&amp;#160; This won’t work. When one uses ‘DataGridColumnHeader.ContextMenu’ property, note that one is using the property which internally happens to be the same for DataGrid too (because ContextMenu is defined on FrameworkElement and all controls share the same property definition). Hence that would end up setting the value of DataGrid itself.&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;Is there any way to add context menu only to the header w/o having to set ColumnHeaderStyle?&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;font color="#008000"&gt;Answer:&amp;#160; Use implicit style for DataGridColumnHeader. But honestly I don’t see any difference from using ColumnHeaderStyle.&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Adding HierarchicalDataTemplate via UI?&lt;/p&gt;  &lt;p&gt;How can I add a HierarchicalDataTemplate for Silverlight 3 via the Blend 3 UI (without typing in the class in XAML)?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Steps:      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;1. Create a new sample data      &lt;br /&gt;2. Click on the triangle of&amp;#160; “add simple property”, select “convert to Hierarchical Collection”       &lt;br /&gt;3. Drag the converted Hierarchical Collection to artboard       &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;View the xaml, notice the Blend generated HierarchicalDataTemplate is bound to the generated tree view.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Here is a more complete TreeView editing experience write-up:      &lt;br /&gt;&lt;/font&gt;&lt;a href="http://shawnoster.com/Blog/Silverlight-TreeView-Connecting-Lines-And-Blend-3-Support-for-HierarchicalDataTemplates"&gt;&lt;font color="#008000"&gt;http://shawnoster.com/Blog/Silverlight-TreeView-Connecting-Lines-And-Blend-3-Support-for-HierarchicalDataTemplates&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; debugging an unmanaged exception in WPF app. &lt;/p&gt;  &lt;p&gt;tried to debug my application I saw the following message &lt;i&gt;“The debugger does not support debugging managed and native code at the same time on this platform.”&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;How could I enable only native code debugger without managed one?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;There may be other ways, but this should work.       &lt;br /&gt;Right-Click on the solution, select&amp;#160; “Add Existing Project” and select the compiled exe.       &lt;br /&gt;Set the exe project as the startup project.       &lt;br /&gt;Right-Click, go to Properties and set “Debugger Type” to “Native Only”&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; API that can determine whether a keystroke yields printable characters or not     &lt;br /&gt;I have a KeyDown event and System.Windows.Input.KeyEventArgs event arg e.     &lt;br /&gt;Is there any API that I can use to determine whether this e.Key is printable or not? Or is there any API I can get the character of this keystroke?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Generally, no. KeyDown to text conversion is pretty stateful, and you don’t have access to this state. Most of it is maintained by the OS.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; XBAP and multi touch in Windows7&lt;/p&gt;  &lt;p&gt;Will all multi touch features in WPF 4 be available when running on Windows 7 as XBAPs as well?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Yes, manipulation and touch events are available in PT. However you cannot implement your own touch device.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; X:Name and Name property&lt;/p&gt;  &lt;p&gt;I have a quick question on why do we have Name for some of the Classes and have to use x:Name for the classes related to Animation/Timelines. Why is this difference in the framework and no uniformity?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;XAML uses [RuntimeNameProperty(“somePropName”)] on classes to signify when a property is the “Name” property (and thus aliased with x:Name).      &lt;br /&gt;XAML treats the two interchangeably when a type does have a RutimeName declared.       &lt;br /&gt;If a tag has both, that is an error.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Reasons for where we ended up:      &lt;br /&gt;· We wanted WPF to not have to require 2 namespaces to have a Named object.       &lt;br /&gt;· We didn’t want to hard code all “Name” properties as the Name.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; WPF colour depth rendering support&lt;/p&gt;  &lt;p&gt;Hi all,&lt;/p&gt;  &lt;p&gt;I'm working on an application that displays DICOM images, the spec allows for images to have greater than 8 bits per channel which most if not all of my test data does have and is very common in medical images. I read on &lt;a href="http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx"&gt;http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx&lt;/a&gt; that &amp;quot;The WPF rasterizer only natively renders bitmaps in Bgr32 and PBgra32 formats&amp;quot; (In the 'WIC in WPF' section, 5th paragraph), is there any way to have a WPF application render an image in PixelFormats.Prgba64 or PixelFormats.Gray16 (or an equivalent)?&lt;/p&gt;  &lt;p&gt;Thanks,&lt;/p&gt; &lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;  &lt;p&gt;&lt;font color="#008000"&gt;No. As Dwayne’s blog notes, the WPF rendering pipeline operates in 32-bit only, so all images are format converted to that before being processed.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Workaround for IsDeferredScrollingEnabled bug&lt;/p&gt;  &lt;p&gt;When using a ComboBox inside of a ScrollViewer with IsDeferredScrollingEnabled=true scrolling in the ComboBox does not work correctly.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;You’ve certainly hit a bug and we are recording one for this scenario. As for a workaround, you can set IsDeferredScrollingEnabled to true for the ComboBox as well to get all the scrollviewers to work correctly. Like this.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;StackPanel.Resources&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;Style TargetType=&amp;quot;ComboBox&amp;quot;&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160; &amp;lt;Setter Property=&amp;quot;ScrollViewer.IsDeferredScrollingEnabled&amp;quot; Value=&amp;quot;true&amp;quot; /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;/Style&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;/StackPanel.Resources&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; WindowStyle.None + ResizeMode.CanResize vs. NoResize&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFDiscussion_3FE/clip_image002_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" hspace="12" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFDiscussion_3FE/clip_image002_thumb.jpg" width="70" height="244" /&gt;&lt;/a&gt;I’m trying to recreate a window like the volume window, where there’s minimal chrome and cannot be resized.&lt;/p&gt;  &lt;p&gt;WindowStyle.None renders a window without a title bar. ResizeMode.NoResize will make a window not resize (surprise, surprise). Unfortunately, when you use them both together, there is no window chrome at all. I’ve tried setting the min/max height/width, which works, but I still get the resize mouse icon when I hover over the window border. Is it possible to render a minimal chrome without the resize icon?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;I think you should be able to use what you have and p/invoke to set the Window's native style to include WS_BORDER.      &lt;br /&gt;There isn't a combination in WPF's Window that supports what you're trying to express.&lt;/font&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Window chrome size&lt;/p&gt;  &lt;p&gt;Is there a way to get the height of the title bar and width of little border on the left in a window. I’m trying to create an overlay window via databinding (would use popup, but it doesn’t seem to respect bindings like Window does) so I need to add in the chrome size to find the global position of the window’s client area. Or maybe there is an easier way? &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;You might try Visual.PointToScreen to see if it does what you want.&amp;#160; I think it gives coordinates in actual device pixels, so if you need to position your overlay using WPF's 1/96&amp;quot; units, you'll have to multiply by 96/systemDPI.&amp;#160; With some effort, you can get this scale factor from HwndTarget.TransformFromDevice.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: Viewing WPF applications over Citrix&lt;/p&gt;  &lt;p&gt;What would be the implications of running WPF over Citrix. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;All versions of WPF since WPF 3.5 SP1 have remoted (both with Remote Desktop and Terminal Server) using Bitmap Remoting.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Bitmap remoting works as follows:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font color="#008000"&gt;The application is rendered on the server using WPF’s software rasterizer&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;As the application runs, the server keeps track of which regions of the application’s window are newly dirty and need to be updated&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;When a region needs to be updated, the server creates a compressed bitmap of just the dirty region and sends that to the client&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Once the client has drawn that bitmap to the appropriate place on its own window, the client window is up-to-date&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Given how this remoting mechanism works, performance can be maximized in several ways:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font color="#008000"&gt;Dirty regions should be kept as small as possible so the least amount of data is sent over the wire&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Ambient animations should be turned off.&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;For instance, setting a window background to an animating gradient would cause the entire window to be invalidated / redrawn every frame&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;The system does not optimize away occluded parts of the application&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;For instance, an animation that is completely hidden behind some other opaque element will &lt;i&gt;still&lt;/i&gt; cause dirty region invalidation / bitmap generation to occur.&amp;#160; Remove these from your application.&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Dirty regions should be created as infrequently as possible&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Turn off as many animations as possible&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;For those animations that can’t be eliminated completely, lower the animation framerate using the DesiredFramerate property&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Dirty Region Bitmaps should be as simple as possible to maximize their compression&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Application running over TS should favor solid colors over gradients or other exotic fills (unnecessary images, etc), especially for application pieces that will be redrawn frequently&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Avoid operations that are especially slow when rendered in software&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;BitmapEffects / Effects / ShaderEffects, especially blurs and drop shadows with large radii, are quite slow in software&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;&lt;font color="#008000"&gt;3D – the 3D software rasterizer is substantially slower than rendering in hardware&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Spell checker does not pick up the current input language if it changes&lt;/p&gt;  &lt;p&gt;If I create an empty application, with:    &lt;br /&gt;&amp;lt;TextBox SpellCheck.IsEnabled=&amp;quot;True&amp;quot; /&amp;gt;     &lt;br /&gt;And I enter text in English, all is good. If I delete all my text in that textbox, change my input language to German (for example), and input German words, it will still be spell checking in English. If I restart the app with my input language set to German, it will spell check correctly.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;It’s by design.&amp;#160; TextBox doesn’t track input language (unlike RichTextBox, which will tag every character entered with the current input language).&amp;#160; TextBox can’t track the input language of individual characters because it contains nothing but Unicode.&amp;#160; So,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;1. If TextBox.Language is set, the speller will respect it.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;2. If TextBox.Language is unset/default (en-us), the speller uses a heuristic, reading the input language set when spelling is enabled.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Language is an inheritable property, so setting it on any parent element will affect a TextBox.&amp;#160; The speller will honor any Language value that is not default -- local, inherited, or styled.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; turn off bitmap effects?     &lt;br /&gt;Is there a registry setting to turn off bitmap effects?&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;No there isn’t. But in 4.0 all the *BitmapEffect classes are either no-opd or redirected to their *Effect equivalents (for the case of DropShadow and Blur).&lt;/font&gt; &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RadioButton/ToggleButtons with DataBinding&lt;/p&gt;  &lt;p&gt;Does anyone have an example of a group of RadioButtons or ToggleButtons working with DataBinding?    &lt;br /&gt;We've found it quite difficult to get this working in a straightforward way.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Ralph, yes there are known issues about RadioButtons and other Controls setting local values upon user interaction and hence clobbering app set Bindings in .Net 3.5&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;I've worked around this issue in .NET 3.5 SP1.&amp;#160; Here's how I data bind a group of radio buttons to an enum-valued property:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;StackPanel&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;RadioButton Content=&amp;quot;New folder&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IsChecked=&amp;quot;{Binding Path=PublishTarget,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Converter={StaticResource equalityConverter},&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ConverterParameter={x:Static local:PublishTarget.NewServerFolder},&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Mode=TwoWay}&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;GroupName=&amp;quot;1&amp;quot;/&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160; &amp;lt;RadioButton Content=&amp;quot;Existing folder&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IsChecked=&amp;quot;{Binding Path=PublishTarget,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Converter={StaticResource equalityConverter},&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;ConverterParameter={x:Static local:PublishTarget.ExistingServerFolder},&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Mode=TwoWay}&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; GroupName=&amp;quot;2&amp;quot;/&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160; &amp;lt;RadioButton Content=&amp;quot;Local folder&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;IsChecked=&amp;quot;{Binding Path=PublishTarget,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Converter={StaticResource equalityConverter},&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ConverterParameter={x:Static local:PublishTarget.LocalFolder},&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Mode=TwoWay}&amp;quot;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; GroupName=&amp;quot;3&amp;quot;/&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;lt;/StackPanel&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Setting each radio button's GroupName to a unique value prevents the bindings from getting clobbered when the user clicks on a radio button.&amp;#160; Here I'm relying on the data source to implement INotifyPropertyChanged, which will tell the other radio buttons to update.&amp;#160; A similar approach should work for radio buttons in an ItemsControl.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9897892" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx">wpfdiscussion</category></item><item><title>WPF discussions 08082009</title><link>http://blogs.msdn.com/jaimer/archive/2009/08/09/wpf-discussions-08082009.aspx</link><pubDate>Mon, 10 Aug 2009 06:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9862566</guid><dc:creator>jaimer</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/9862566.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=9862566</wfw:commentRss><description>&lt;p&gt;Raw/unedited useful WPF advise.. &lt;/p&gt;  &lt;hr /&gt;&lt;strong&gt;Subject: &lt;/strong&gt;Control Verifier   &lt;br /&gt;&lt;strong&gt;From: &lt;/strong&gt;Samantha Durante, our controls PM   &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:       &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;I just wanted to let you know that we’ve just released &lt;strong&gt;Version 0.1 of the&lt;/strong&gt; &lt;a href="http://wpf.codeplex.com/Wiki/View.aspx?title=WPF%20Control%20Verifier"&gt;WPF Control Verifier&lt;/a&gt; tool.&amp;#160; &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;WPF Control Verifier is a tool that verifies the correctness of WPF Controls. This tool is geared towards WPF Control developers with the goal of providing a set of verifications that all controls can run and consume. Version 0.1 includes one category for verification – default style verification. These tests verify that your control can be styled such that its dependency properties are inheriting or template binding correctly. Future versions will include additional categories of verification.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;You can download this tool in the &lt;strong&gt;new&lt;/strong&gt; &lt;a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=30923"&gt;WPF Test Tools&lt;/a&gt;&lt;strong&gt; release&lt;/strong&gt; at the &lt;/font&gt;&lt;a href="http://wpf.codeplex.com/Wiki/View.aspx?title=Home"&gt;&lt;font color="#008000"&gt;WPF Codeplex&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt; site.&amp;#160;&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;&lt;b&gt;Subject:&lt;/b&gt; Application checking .NET 3.0 is installed   &lt;br /&gt;What's the best way to determine if the user's computer has .NET 3.0 installed?   &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Check the Registry.       &lt;br /&gt;The official guide: &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa480198.aspx#netfx30_topic14"&gt;&lt;font color="#008000"&gt;http://msdn.microsoft.com/en-us/library/aa480198.aspx#netfx30_topic14&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;hr /&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: Binding doesn't seem to work: System.Windows.Data Error: 4   &lt;br /&gt;Long discussion on how RelativeSource (binding to Ancestor) is indeterminate with regards to when parent is added to the tree;   &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;In general, RelativeSource looking for an Ancestor type isn't robust against delayed addition to the tree, and not at all against reparenting.&amp;#160; I only learned this earlier this week, debugging a similar issue.&amp;#160; Consider instead making &amp;quot;MyProperty&amp;quot; an inheritable property, and just binding to Self, MyProperty.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;(Jaime’s personal take added now).&amp;#160; I do use RelativeSource within generated items in ItemsControls. Seems usable there and seems like a good place to apply it; if the scenario was different (less items in particular and shallow trees) then inherited property sounds good too. &lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;   &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Knowing if a control is partly occluded&lt;/p&gt;  &lt;p&gt;I’m working on adding tooltips to controls that are partly occluded on mouse hover (like the Outlook folders pane does). What’s the right way to know whether something has been partly occluded?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;///&amp;lt;summary&amp;gt;      &lt;br /&gt;/// This eliminates the part of bounding rectangle if it is at all being overlapped/clipped by any of the visual ancestor up in the parent chain       &lt;br /&gt;///&amp;lt;/summary&amp;gt;       &lt;br /&gt;internal Rect CalculateVisibleBoundingRect()       &lt;br /&gt;{ &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; Rect boundingRect = Rect.Empty; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; boundingRect = new Rect(_owner.RenderSize);      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; // Compute visible portion of the rectangle. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; Visual visual = VisualTreeHelper.GetParent(_owner) as Visual;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; while (visual != null &amp;amp;&amp;amp; boundingRect != Rect.Empty &amp;amp;&amp;amp; boundingRect.Height != 0 &amp;amp;&amp;amp; boundingRect.Width != 0)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Geometry clipGeometry = VisualTreeHelper.GetClip(visual);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (clipGeometry != null)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; GeneralTransform transform = _owner.TransformToAncestor(visual).Inverse;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // Safer version of transform to descendent (doing the inverse ourself and saves us changing the co-ordinate space of the owner's bounding rectangle),       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // we want the rect inside of our space. (Which is always rectangular and much nicer to work with)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; if (transform != null)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Rect clipBounds = clipGeometry.Bounds;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; clipBounds = transform.TransformBounds(clipBounds);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; boundingRect.Intersect(clipBounds);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; else       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // No visibility if non-invertable transform exists.       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; boundingRect = Rect.Empty;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; visual = VisualTreeHelper.GetParent(visual) as Visual;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; } &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; return boundingRect;      &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;   &lt;hr /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: BitmapImage.StreamSource - best practice for closing the stream?     &lt;br /&gt;If I use BitmapImage, then set in the StreamSource, no one seems to ever close the stream.&amp;#160; The net effect is this locks the file in memory – preventing file renames, etc.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;By default images are delay decoded. Set the CacheOption to BitmapCacheOption.OnLoad to force eager decode of the stream.&lt;/font&gt;&amp;#160; &lt;/p&gt;  &lt;hr /&gt;&lt;b&gt;Subject:&lt;/b&gt; CollectionView, Sort Descriptions, Turkish I, and Custom Sorts  &lt;p&gt;Given a CollectionView, and some SortDescriptions, how does one ensure that the sorting is correct for the current culture? Should I use Custom sort? &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;ListCollectionView’s sorting uses the Culture property.&amp;#160;&amp;#160; If you don’t set this, it’s set to agree with the Language of the client element.&amp;#160; For example,&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;ListBox&amp;#160; ItemsSource=”…” Language=”tr-TR”/&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;will sort in Turkish.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;The CustomSort lets you define your own comparison logic.&amp;#160; You can pay attention to whichever columns you like, and choose case-sensitive or insensitive.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; DecodePixelWidth     &lt;br /&gt;I’d like to investigate DecodePixelWidth to reduce memory consumption when viewing large images on the design surface.&amp;#160; &lt;br /&gt;Is there a way without loading the image itself to grab the metadata that would tell me what the size of the image is?&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt;       &lt;br /&gt;Unfortunately no.&lt;/font&gt;    &lt;hr /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Getting HyperLink content    &lt;br /&gt;I'm trying to get the text of a hyperlink via code, and I can't find it.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:       &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;TextRange range = new TextRange(link.ContentStart, link.ContentEnd);      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;string text = range.Text;&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Implement Attribute x:Uid    &lt;br /&gt;Is it possible to implement the localization attribute x:Uid? We would like to implement this attribute without inheriting from UIElement and make it possible to use XAMLReader/XAMLWriter API.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:       &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;If you’re working with 4.0, you can set the UidPropertyAttribute on your type and it’ll set whatever property you need it on.     &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;There is no way in 3.X.&amp;#160; Uid was hard coded in the system to only work with UIElements. Uid is ignored on all other types at runtime.&lt;/font&gt;     &lt;hr /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Invisible Hyperlink can still receive focus&lt;/p&gt;  &lt;p&gt;For following xaml, the hyperlink hyper1 is invisible, but can still receive keyboard focus, I need to set it’s Focusable to false to stop it receiving focus, is this the expected behavior?    &lt;br /&gt;&amp;lt;TextBlock Visibility=&amp;quot;Collapsed&amp;quot;&amp;gt;&amp;lt;Hyperlink x:Name=&amp;quot;hyper1&amp;quot;/&amp;gt;&amp;lt;/TextBlock&amp;gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt;       &lt;br /&gt;This appears to be a bug in TextBlock and is not specific to Hyperlink.&amp;#160; If you replace the Hyperlink with a Button, it loses Tab navigation completely while other panels work as expected.&lt;/font&gt;&amp;#160; &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Mouse wheel in winform interop scenario&lt;/p&gt;  &lt;p&gt;Hi,&lt;/p&gt;  &lt;p&gt;Our project embed a Dunas chart control inside a WindowsFormHost. We want to support mouse wheel on it for zooming. The dunas document specifically call out that mouse wheel does not work unless the control is focused (indeed, when there is no focus, the chart does not receive mouse wheel message, and I guess this is not specific to dunas control but to general winform control too). The&amp;#160; initial thought is to programmatically set focus on the dunas control. However, this is apparently bad that if other elements get focus this stops working. &lt;/p&gt;  &lt;p&gt;Now my goal is to enable mouse wheel without messing with focus. If I am able to intercept mouse wheel message (no matter focused or not) I can work with the control to simulate zooming. The first attempt was to derive from WindowsFormHost and override WndProc to see if I can receive mouse wheel message there without being focused. It did not working (not surprising).&lt;/p&gt;  &lt;p&gt;After looking into MSDN I found ComponentDispatcher class. So I tried the following code:&lt;/p&gt;  &lt;p&gt;ComponentDispatcher.ThreadFilterMessage += delegate(ref MSG msg, ref bool handled)&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;if (msg.message == 0x20A) /*MouseWheel*/&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Diagnostics.Trace.WriteLine(&amp;quot;Receiving mouse wheel message&amp;quot;);&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Diagnostics.Trace.WriteLine(&amp;quot;msg window &amp;quot; + msg.hwnd);&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; System.Diagnostics.Trace.WriteLine(&amp;quot;WindowsFormsHost handle : &amp;quot; + this.wfhost.Handle);&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; };&lt;/p&gt;  &lt;p&gt;Well now I do get mouse wheel message. But I get ALL of them even if the mouse is not on the control. The windows handle in the message is not the same as reported by WindowsFormHost, it is actually the main window (which is logical since this essentially comes from main message pump). &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;Windows will deliver the WM_MOUSEWHEEL to the HWND with focus.&amp;#160; So you will have to start from there.&amp;#160; You can either subclass that window proc, or you can use the ComponentDispatcher to watch the messages come through the message pump.&amp;#160; The HWND in the message will be whatever HWND has focus – such as the main App window.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;You can then look at chart.IsMouseOver to decide whether or not to respond to the message.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Override tab ordering of panel&lt;/p&gt;  &lt;p&gt;We implemented our custom Panel class and want to change the tab navigation behavior.    &lt;br /&gt;Does anyone know where to override the default behavior?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt;       &lt;br /&gt;You can set KeyboardNavigation.TabNavigation property on the custom Panel to the mode you like.       &lt;br /&gt;Then TabIndex property on subelements if you want to change the Tab traverse order.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Question with ReadOnly RichTextBox&lt;/p&gt;  &lt;p&gt;I have a window that contains a RichTextBox control used to display read-only text. As such, I have set the IsReadOnly property to ‘True’ so that the text inside the RichTextBox is not editable. However, setting this property also disables many keyboard navigation commands, such as arrow up/down, page up/down. Some commands, such as text selection (Ctrl+A, Shift+Up/Down/Left/Right) still work. Does the RichTextBox require any additional configuration for the keyboard navigation commands to work when IsReadOnly is set to True?    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;In &amp;lt;=3.5sp1, keyboard navigation is not fully supported when IsReadOnly is set to true. In 4.0, we’ve added a new property to TextBoxBase (IsReadOnlyCaretVisible) which enables both the caret rendering and keyboard navigation in read only mode.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;hr /&gt;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Is it possible to utilize the functionality of DocumentViewer's FindToolBar programatically?    &lt;br /&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Unfortunately the search API used by the document viewers is not publicly exposed and as far as I know there are no plans to expose it in the near future.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;-----------------&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; SplashScreen Bug&lt;/p&gt;  &lt;p&gt;Hello Folks,&lt;/p&gt;  &lt;p&gt;Our client has a bug with the use of the SplashScreen class present in the Framework 3.5 Sp1. The bug are the same that the one describe in these differents threads:&lt;/p&gt;  &lt;p&gt;· &lt;a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=378575"&gt;http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=378575&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;· &lt;a href="http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=362735"&gt;http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=362735&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;It seems that this bug is corrected en the next release of WPF (4.0) But our client needs to release our application &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;You can work around both of those issues using the existing SplashScreen by not using the fade out.&lt;/font&gt;&lt;font color="#008000"&gt;To do that you’ll need to write a main method that looks something like this:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;[STAThread]&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;public static void Main(string[] args)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;{&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;SplashScreen sp = new SplashScreen(&amp;quot;splash.png&amp;quot;);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; sp.Show(false);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() =&amp;gt; sp.Close(TimeSpan.Zero)), DispatcherPriority.Loaded);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; WpfApplication1.App app = new WpfApplication1.App();&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; app.InitializeComponent();&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160; app.Run();&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Question about ListView sorting feature&lt;/p&gt;  &lt;p&gt;When I am developing sorting feature for the ListView, I observed a interesting behavior. Could someone help to identify whether it is by design? I also attached the project. &lt;/p&gt;  &lt;p&gt;Say I have a listview, and the values in column “Test Enabled” are all the same. When I click the column header, the column will be sorted. &lt;/p&gt;  &lt;p&gt;Step 1, see picture 1, no column is sorted.    &lt;br /&gt;Step 2, click column header of column “Test Enabled”, column “Machine” is sorted. (Could anyone tell me why?).     &lt;br /&gt;Step 3, click column header of column “Test Enabled”, no changes.     &lt;br /&gt;Step 4, click column header of column “Test Enabled”, no changes.&lt;/p&gt;  &lt;p&gt;The way I implement the sorting is very simple:&lt;/p&gt;  &lt;p&gt;//sort the machines.&lt;/p&gt;  &lt;p&gt;ICollectionView view = CollectionViewSource.GetDefaultView(this.Machines);&lt;/p&gt;  &lt;p&gt;view.SortDescriptions.Clear();&lt;/p&gt;  &lt;p&gt;view.SortDescriptions.Add(new SortDescription(sortColumn.Tag as string, direction));&lt;/p&gt;  &lt;p&gt;view.Refresh();&lt;/p&gt;  &lt;p&gt;Questions:&lt;/p&gt;  &lt;p&gt;1. In step 1, why column “Machine” is sorted when I try to sort column “Test Enabled”?&lt;/p&gt;  &lt;p&gt;2. In step 3, 4, why wouldn’t the list view change anymore?&lt;/p&gt;  &lt;p&gt;Picture 1:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image001_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image001" border="0" alt="clip_image001" src="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image001_thumb.jpg" width="244" height="140" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Picture 2:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image002_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image002" border="0" alt="clip_image002" src="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image002_thumb.jpg" width="244" height="142" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Picture 3:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image003_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image003" border="0" alt="clip_image003" src="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image003_thumb.jpg" width="244" height="146" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Picture 4:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image004_2.jpg"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="clip_image004" border="0" alt="clip_image004" src="http://blogs.msdn.com/blogfiles/jaimer/WindowsLiveWriter/WPFdiscussions08082009_131DB/clip_image004_thumb.jpg" width="244" height="146" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer&lt;/strong&gt;:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;LCV.CustomSort only specifies the comparer, the actual algorithm is implemented by Array.Sort (it’s a Quicksort). &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;When you click the ‘Test Enabled’ column, we sort by that column only.&amp;#160; Since all the values in that column are equal, &lt;i&gt;any&lt;/i&gt; permutation of the rows is sorted.&amp;#160; The actual result depends on the implementation of the sort algorithm, not on the data at all.&amp;#160; (In other words, it’s not really true that it sorts by ‘Machine’;&amp;#160; all you can say is that the algorithm permutes the rows in some arbitrary way.)&amp;#160; When you click the column again and nothing changes, that only means that Array.Sort produces the same result given the same input – not terribly surprising.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;It’s pretty difficult to implement a sorting algorithm that is both stable (records with equal keys end up in the same relative order as they began) and efficient (O(n log n) with small coefficient).&amp;#160;&amp;#160;&amp;#160; I think you’ll find that the algorithm Marco pointed to (&lt;/font&gt;&lt;a href="http://thomas.baudel.name/Visualisation/VisuTri/inplacestablesort.html) is"&gt;&lt;font color="#008000"&gt;http://thomas.baudel.name/Visualisation/VisuTri/inplacestablesort.html) is&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt; quite a bit slower than Quicksort in practice.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;There’s no way to replace the sorting algorithm used by the collection view.&amp;#160; If you want a more intuitively deterministic result, you can add a second SortDescription that says how to compare records that are equal w.r.t. the first SortDescription.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;BTW, your code actually sorts the array twice.&amp;#160; The collection view automatically refreshes whenever you change the sort descriptions, so you sort once for view.SD.Add() and a second time for view.Refresh().&amp;#160;&amp;#160; If you added a second SortDescription, you’d sort three times.&amp;#160; The right way to do it is:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; using (view.DeferRefresh())&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; view.SortDescriptions.Clear();&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; view.SortDescriptions.Add(….);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; view.SortDescriptions.Add(…);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;This turns off the automatic refresh until you’re done changing things.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9862566" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx">wpfdiscussion</category></item><item><title>WPF discussions 090626</title><link>http://blogs.msdn.com/jaimer/archive/2009/06/29/wpf-discussions-090626.aspx</link><pubDate>Mon, 29 Jun 2009 10:12:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9808255</guid><dc:creator>jaimer</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/9808255.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=9808255</wfw:commentRss><description>&lt;p&gt;Emails from our MS internal discussions. Lots a great tips. &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: &lt;/strong&gt;Advise for running WPF apps over Citrix&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;All versions of WPF since WPF 3.5 SP1 have remoted (both with Remote Desktop and Terminal Server) using Bitmap Remoting.       &lt;br /&gt;      &lt;br /&gt;Bitmap remoting works as follows:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font color="#008000"&gt;The application is rendered on the server using WPF’s software rasterizer&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;As the application runs, the server keeps track of which regions of the application’s window are newly dirty and need to be updated&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;When a region needs to be updated, the server creates a compressed bitmap of just the dirty region and sends that to the client&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Once the client has drawn that bitmap to the appropriate place on its own window, the client window is up-to-date&lt;/font&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Given how this remoting mechanism works, performance can be maximized in several ways:&lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;font color="#008000"&gt;Dirty regions should be kept as small as possible so the least amount of data is sent over the wire&lt;/font&gt; &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Ambient animations should be turned off&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;For instance, setting a window background to an animating gradient would cause the entire window to be invalidated / redrawn every frame&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;The system does not optimize away occluded parts of the application&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;For instance, an animation that is completely hidden behind some other opaque element will &lt;i&gt;still&lt;/i&gt; cause dirty region invalidation / bitmap generation to occur.&amp;#160; Remove these from your application.&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Dirty regions should be created as infrequently as possible&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;Turn off as many animations as possible&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;&lt;font color="#008000"&gt;For those animations that can’t be eliminated completely, lower the animation framerate using the DesiredFramerate property&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Dirty Region Bitmaps should be as simple as possible to maximize their compression&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;Application running over TS should favor solid colors over gradients or other exotic fills (unnecessary images, etc), especially for application pieces that will be redrawn frequently&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;&lt;font color="#008000"&gt;Avoid operations that are especially slow when rendered in software&lt;/font&gt;       &lt;ul&gt;       &lt;li&gt;&lt;font color="#008000"&gt;BitmapEffects / Effects / ShaderEffects, especially blurs and drop shadows with large radii, are quite slow in software&lt;/font&gt; &lt;/li&gt;        &lt;li&gt;&lt;font color="#008000"&gt;3D – the 3D software rasterizer is substantially slower than rendering in hardware&lt;/font&gt; &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: &lt;/strong&gt;Is there any support in WPF for “bottom-up” bitmaps?     &lt;br /&gt;I’m using BitmapSource.Create with an unmanaged memory buffer. The buffer comes from a Win32 DIBSection with a +ve height, which indicates a &lt;a href="http://msdn.microsoft.com/en-us/library/dd407212(VS.85).aspx"&gt;bottom-up DIB&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Wrap it in a TransformedBitmap.&amp;#160; &lt;br /&gt;return new TransformedBitmap(bmp, new ScaleTransform(1,-1));&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;[extra tip]      &lt;br /&gt;Note that I think each call to CopyPixels() on the TransformedBitmap will run the scale transformation again. You can avoid this by caching the result in a CachedBitmap and using the CB instead       &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Getting DependencyProperty value from WinDBG     &lt;br /&gt;I have a dump of a WPF process and am trying to get the value of a DependencyProperty of UIElement.&amp;#160; Does anybody know how this can be done?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;b&gt;Answer:        &lt;br /&gt;&lt;/b&gt;1. Pull out the value of _packedData.       &lt;br /&gt;2. _packedData &amp;amp; 0x0000FFFF will give you the GlobalIndex.       &lt;br /&gt;3. Go to the DependencyObject on which you want to query the property and get access to the _effectiveValues array.       &lt;br /&gt;4. Go through the EffectiveValueEntry objects, looking at the _propertyIndex field until it matches the index you calculated in step 2 (the array should be sorted by property index).       &lt;br /&gt;5. _value is the value of the property on that DependencyObject.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject:&amp;#160; &lt;/strong&gt;Difference between nulll and x:Null for brushes&lt;/p&gt;  &lt;p&gt;I know there is a difference but I can’t remember. I think it had something to do with hit testing (but I can’t remember for sure).&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;No difference.&amp;#160; You're probably thinking of null (No hit test) versus Transparent (Can be hit).&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Disable auto-word selection in FlowDocumentViewer     &lt;br /&gt;How can I make FlowDocumentViewer select character by character when I use the mouse? &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;For FlowDocumentPageViewer, you can use flowDocumentPageViewer.SetValue(TextBoxBase.AutoWordSelectionProperty, false). FlowDocumentScrollViewer doesn’t auto-select words by default. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Internally, the selection code shared by text boxes and FlowDocument viewers relies on TextBoxBase.AutoWordSelectionProperty. We don’t currently expose the property on anything other than TextBoxBase. &lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Blend units.     &lt;br /&gt;Any reason why Blend3 outputs font size in WPF “units” and not the actual pt value. If I change the FontSize on a TextBlock to “11pt”, 14.667 is written out.     &lt;br /&gt;    &lt;br /&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Blend 2 always displayed text units in pixels. This was confusing to most designers who are used to thinking of fonts in terms of points. In Blend 3 we added an option where you can choose whether you want points or pixels as your display in the Property panel. This is under the Units tab in the Options dialog.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;In terms of the XAML output, we had wanted to output the same units as shown in the UI but Silverlight does not support the pt syntax in XAML so we decided (for cost and consistency reasons) to just leave it as pixels in the XAML for V3.&amp;#160; It is something for us to consider improving in the future though.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Disable IME on TextBox     &lt;br /&gt;Is there a setting to disable using IME on a textbox, or some other means of not allowing a user to use it?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;&amp;lt;TextBox InputMethod.IsInputMethodEnabled=”false” /&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; DateTime property in the Properties editor of Blend     &lt;br /&gt;I have a question regarding how Blend handles a control property which is of type System.DateTime.&amp;#160; I am trying to understand how the property editor would interpret a string such as 20/05/2001. Would it take into account the regional settings of the computer or is it tied up with the implementation of the control itself?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Blend will use a text editor to read and display DateTimes, and will parse input based on the locale settings of your machine.&amp;#160; In xaml, it is always stored in an invariant format(year-month-day).&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject:&amp;#160; &lt;/strong&gt;(summarized) issue w/ WPF not matching GDI on how a custom font is rendered&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;There is no expectation that WPF font rasterization will match GDI\GDI+ rasterization. For example if the font does not have italic or bold variants GDI will emulate bold and italic WPF will not.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; DPI interop issues...&lt;/p&gt;  &lt;p&gt;I have a drag/drop gesture that draws a drag/drop feedback in a transparent WPF window. The problem is in tracking the mouse position I had to use interop to Win32.GetCursorPos and that works, when the operating system is in 96 DPI mode.&amp;#160; But when you change the OS DPI to something else, like 120 or 150 DPI then this doesn’t work because positioning the transparent WPF drag/drop feedback window requires WPF device independent coordinates (essentially 96 DPI) so I need to do a conversion&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;     &lt;br /&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;Have you looked at Visual.PointFromScreen?&amp;#160; It can be used to convert screen coordinates from APIs such as GetCursorPos into Device Independent Units &lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: Game loops in WPF?      &lt;br /&gt;&lt;/strong&gt;wondering how easy it would be to write a custom &amp;quot;game loop&amp;quot; within the WPF framework. By game loop, I mean pumping my own events on a custom Dispatcher so I can control the framerate of my app.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;You can write your own message pump. Just don't call Dispatcher.Run. You need to pump messages, and you need to call ComponentDispatcher.RaiseThreadMessage as appropriate. Use reflector to see what Dispatcher.PushFrame does.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Of course, this still may not give you what you want for a &amp;quot;game loop&amp;quot;... &lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;font color="#000000"&gt;&lt;b&gt;Subject:&lt;/b&gt; Is there a way to prevent exception if DataContext is null? &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#000000"&gt;This is just an example.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#000000"&gt;I have a Image which is Databind to some dynamic source (image source) and it works fine and it is all done in xaml. Can we provide some defaule image source incase DataContext becomes null? &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;FallbackValue is your friend: &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.fallbackvalue.aspx"&gt;&lt;font color="#008000"&gt;http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.fallbackvalue.aspx&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;font color="#000000"&gt;&lt;b&gt;Subject:&lt;/b&gt; Listening to selective ETW Events&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#000000"&gt;I’m writing performance tests where we want to listen to the WClientUceNotifyPresent ETW event to calculate frame rates.&amp;#160; However, I haven’t found provider flags to listen to it, along with a limited set of other events.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;With WPF 3.0-3.5 you unfortunately don’t have a lot of options.&amp;#160; You should make sure that you’re using verbosity level 4 (as opposed to 5).&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;If you’re on CLR 4.0 we have much more granular flags so you’ll be able to turn on a flag specifically for Graphics related events which should help .&amp;#160; If you have a recent drop (post Beta1) you should find our event manifest installed in \windows\microsoft.net\framework\v4.0\wpf\wpf-etw.man which lists the available flags.&amp;#160; You will need either flag 1 `General` or flag 0x1000 `Graphics` depending on what drop you have.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;font color="#000000"&gt;&lt;b&gt;Subject:&lt;/b&gt; Way to check if an UIElement is visible in ScrollViewer&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#000000"&gt;Is there any way to check if an UI element is already showing in a scroll viewer?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;[Not right one, but works]      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;Use reflection to invoke ScrollViewer.IsInViewport method?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;[Final]      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;I wouldn’t recommend this for production code.      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;Is there a reason you don’t want to call BringIntoView on elements that are already visible? All handlers of RequestBringIntoView I know of no-op on visible elements.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9808255" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx">wpfdiscussion</category></item><item><title>WPF discussion 090605</title><link>http://blogs.msdn.com/jaimer/archive/2009/06/06/wpf-discussion-090605.aspx</link><pubDate>Sun, 07 Jun 2009 09:46:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9703629</guid><dc:creator>jaimer</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/9703629.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=9703629</wfw:commentRss><description>&lt;p&gt;You know the drill: Raw/unedited WPF discussions from inside the mothership. &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: Accessibility tree, and collapsed elements&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;We have some UI that we’re collapsing (Visibility=Collapsed). However, even after it’s collapsed, it *seems* to be participating in the accessibility tree (shows up in UIspy). Is this the correct behaviour? &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;It seems that this behavior is expected. However UI Elements that are collapsed should have the IsOffScreen property set to true. You could probably filter on that flag.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Blur the focus of a window&lt;/p&gt;  &lt;p&gt;With WPF, how can you blur (lose focus) a window?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer1:&lt;/strong&gt;       &lt;br /&gt;There are essentially 3 types of focus, which type do you want to blur?&amp;#160; There are:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;· Logical focus.&amp;#160; This is essentially a way of marking which IInputElement in a given scope should receive keyboard focus if that scope gains keyboard focus.&amp;#160; Within elements that are marked as a focus scope, there will be 0 or 1 logically-focused child elements.&amp;#160; A focus scope is determined by FocusManager.SetIsFocusScope/FocusManager.GetIsFocusScope, and logical focus can be cleared by using FocusManager.SetFocusedElement on the focus scope to null.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;· Keyboard focus.&amp;#160; This is similar to Win32 focus; only one IInputElement on the thread with Win32 focus can be the Keyboard.FocusedElement.&amp;#160; In 3.0/3.5/3.5 SP1, the only way I know of to clear WPF keyboard focus also involves clearing Win32 focus, by calling ::SetFocus(NULL) from user32.&amp;#160; In WPF 4.0 there is a new method coming along, Keyboard.ClearFocus(), which will clear only the WPF keyboard focus.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;· Standard Win32 focus.&amp;#160; WPF keyboard focus is typically kept in-sync with Win32 focus (in that the focused HWND typically contains the Keyboard.FocusedElement), so doing operations which affect HWND focus will generally affect the Keyboard.FocusedElement.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer2:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Of course, you can always make an element lose focus by focusing another element, too.&amp;#160; Calling Keyboard.Focus on some other element should result in PreviewLostKeyboardFocus/LostKeyboardFocus being raised on the element losing keyboard focus.&amp;#160; Similarly, calling FocusManager.SetFocusedElement to some other element in the focus scope should result in PreviewLostFocus/LostFocus being raised on the element losing logical focus.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Confusingly, perhaps, calling Keyboard.Focus(null) will not clear keyboard focus, but will instead focus the active PresentationSource's root visual.&amp;#160; This can result in Keyboard.Focus(null) actually focusing another element, and not clearing focus.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; How do I change properties on the Navigation Bar in a WPF Frame?&lt;/p&gt;  &lt;p&gt;I'm working on a page based WPF application, and I want to change the size of the navigation bar in the Frame hosting my pages. I set NavigationUIVisibility=&amp;quot;Visible&amp;quot; in order to see the navigation bar, now how do I change properties on the navigation bar like it's size?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;The built-in navigation UI is not directly customizable. You’ll have to replace the entire ControlTemplate of Frame, possibly using the built-in one as a base. This is easy with Blend. Some resources:      &lt;br /&gt;&lt;/font&gt;&lt;a href="http://windowsclient.net/downloads/folders/wpfsamples/entry5121.aspx"&gt;&lt;font color="#008000"&gt;http://windowsclient.net/downloads/folders/wpfsamples/entry5121.aspx&lt;/font&gt;&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c98f9b2a-a910-45cd-acdc-fa5b222b7460/"&gt;&lt;font color="#008000"&gt;http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/c98f9b2a-a910-45cd-acdc-fa5b222b7460/&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Scroll issue with hosting a winform within WPF&lt;/p&gt;  &lt;p&gt;I am having an issue trying to scroll a winform control hosted within WPF. I have a view (WPF UserControl) that has 3 elements. A checkbox, a hosted winform control (gray window below) and a combobox.    &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;font color="#008000"&gt;Here’s an illustration of this technique for another source: &lt;/font&gt;&lt;a href="http://blogs.msdn.com/ryanvog/archive/2009/01/20/clipping-legacy-content-hosted-inside-a-wpf-scrolling-region.aspx"&gt;&lt;font color="#008000"&gt;http://blogs.msdn.com/ryanvog/archive/2009/01/20/clipping-legacy-content-hosted-inside-a-wpf-scrolling-region.aspx&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt;. &lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: Themes\Generic.xaml&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Only resources that are referenced with StaticResource from within the same resource dictionary (i.e. within Generic.xaml) can be strings. For everything else, you must use either a type key ({x:Type Foo}) or a ComponentResourceKey. Styles with no key specified default the key value to the TargetType of the Style.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Asynchronous Commands and Dispatcher&lt;/p&gt;  &lt;p&gt;I have a command which executes a long-running operation using BackgroundWorker.&amp;#160; The command exposes a State property to which the UI can be bound to indicate that the operation is in progress or has finished.&amp;#160; The results of the command are bound to a TreeView.&amp;#160; Whenever an element is added to the results, the command does so by calling Dispatcher.BeginInvoke so that the element will be added to the results collection on the UI which causes the TreeView to be updated.&amp;#160; I call the BeginInvoke method with a priority of Background.&amp;#160; Once the command is finished executing, it updates its state to say it’s finished.&amp;#160; &lt;/p&gt;  &lt;p&gt;The problem is that when there are hundreds of elements that have been added to the collection, the UI thread hasn’t finished processing all of those operations that have been queued on the Dispatcher by the time the command says it’s finished.&amp;#160; So the command says it is finished even though the UI thread is still busy processing all the queued operations.&amp;#160; &lt;/p&gt;  &lt;p&gt;One solution is to have the Command update its State property by having the Dispatcher do it via the BeginInvoke call with the same priority.&amp;#160; That would cause the Dispatcher to update the Command’s state once all the other previously added operations have been processed.&amp;#160; But I’m not sure that’s the right approach; it feels very hacky.&lt;/p&gt;  &lt;p&gt;Is there a better way to do this?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;font color="#008000"&gt;Keep track of the last operation you BeginInvoke over to the UI thread from the worker thread.&amp;#160; When the worker thread is done, before it updates the state property, have it call DispatcherOperation.Wait() to wait for the UI thread to finish.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: Blocking till message loop empty?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Nope.&amp;#160; Dispatcher.Invoke, when called on its &lt;u&gt;own thread&lt;/u&gt;, will implicitly use Dispatcher.PushFrame.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: Bounding rectangle for objects on canvas&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer: &lt;/strong&gt;      &lt;br /&gt;GetDescendantBounds returns the bounds without applying any Visual properties like Clip, Transform, Offset, Effect…       &lt;br /&gt;Canvas.Left/Canvas.Top are mapped to Visual.VisualOffset and Visual.VisualTransform. To take the bounding box from what we call “inner coordinate space” (closest to children) to “outer coordinate space” (closest to parent) you have to apply all the transforms, clips, etc. Note that an effect might change your transformation too…&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;The easiest way to get the outer bounds is to call on the parent GetDescendantBounds as long as the parent does not have any “vector content” (think ink).&amp;#160; For UIElements you provide “vector content” via OnRender, for DrawingVisual you call RenderOpen, etc. If the parent had any content, it would be included in the descendant bounds. The naming is a little unfortunate since it is not purely “descendant”. We originally had the functionality only consider descendants, but lots of people thought it was what it does now…&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Disable script debugging for WebBrowser?&lt;/p&gt;  &lt;p&gt;This option exists in the WinForms web browser, is there a way we can access this option in the WPF web browser also? We are having catastrophic issues with modal script debugger popups that make the browser too annoying to be useful.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Get the native IWebBrowser2 and set the Silent property. See the Community section of the &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.aspx"&gt;&lt;font color="#008000"&gt;WebBrowser class reference&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt; (&lt;a title="http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.aspx" href="http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.aspx&lt;/a&gt;) for how to get IWebBrowser2.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9703629" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx">wpfdiscussion</category></item><item><title>WPF Discussion, 090522</title><link>http://blogs.msdn.com/jaimer/archive/2009/05/23/wpf-discussion-090522.aspx</link><pubDate>Sat, 23 May 2009 11:37:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9636977</guid><dc:creator>jaimer</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/9636977.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=9636977</wfw:commentRss><description>&lt;p&gt;I hope you remember the drill; sorry that I missed last week, we had school &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; ItemsControl and Screen Reader&lt;/p&gt;  &lt;p&gt;I have a WPF 4.0 ItemsControl as follows. The AutomationProperties.Name attached property is set to a string for the item containers. I expected the screen reader to read out the string when the item container get focus, however screen reader (I am using Narrator) actually read nothing. Could anyone give me some insights? Is it a bug of my code or the screen reader or WPF? Thanks a lot!&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Unfortunately ItemsControl does not support UIAutomation – it is primarily intended to be used as a base upon which multi item controls are built.       &lt;br /&gt;You could switch to any of the ItemsControl subclasses that do support UIAutomation (ListBox is probably your best bet)       &lt;br /&gt;Alternatively you can override OnCreateAutomationPeer in your own ItemsControl subclass and return an AutomationPeer implementation of your own. The ListBoxAutomationPeer and ListBoxItemAutomationPeer implementations are really small simple starting points.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Create hidden WPF window ... with an HWND&lt;/p&gt;  &lt;p&gt;I am trying to create a WPF Window that’s initially hidden, do a bunch of initialization, then show the window. In my case the initialization requires access to the HWND that will be hosting the Window. But it appears to me that the HWND is not actually created by WPF until either I call either Window.Show() or Window.Visisibility=Visible. And doing so, of course, makes my app window visible but blank for awhile before my initialization is complete.&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:        &lt;br /&gt;&lt;/strong&gt;Currently, the only good workaround here is to supply an initial window position that’s entirely off-screen, then move it into view once everything’s ready.&amp;#160; That way the blankness/flicker can’t be seen.&amp;#160; For our next release, we’ve added a method to the WindowInteropHelper class called EnsureHandle to cause the HWND to be created before the window is shown.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Rendering delay when first displaying cached images&lt;/p&gt;  &lt;p&gt;I’m tracking down a perf issue with my WPF application. Basically I cache a BitmapImage:&lt;/p&gt;  &lt;p&gt;this.cachedImage = new BitmapImage();&lt;/p&gt;  &lt;p&gt;this.cachedImage.BeginInit();&lt;/p&gt;  &lt;p&gt;this.cachedImage.CacheOption = BitmapCacheOption.OnLoad;&lt;/p&gt;  &lt;p&gt;this.cachedImage.UriSource = new Uri(&amp;quot;IMG_0726.JPG&amp;quot;, UriKind.Relative);&lt;/p&gt;  &lt;p&gt;this.cachedImage.EndInit();&lt;/p&gt;  &lt;p&gt;Then later I go to show it with&lt;/p&gt;  &lt;p&gt;this.imageElement.Source = this.cachedImage;&lt;/p&gt;  &lt;p&gt;But with large images, there is still a significant delay before the image renders, of a second or two. The UI thread does not appear to be blocked during this delay, so I suspect some conversion is happening on the render thread.&lt;/p&gt; &lt;font color="#008000"&gt;Answer: &lt;/font&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer 1      &lt;br /&gt;We take a hit downsampling to display size - if you set DecodePixelWidth/Height on your bitmap to your display size, does that make this issue go away?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Follow-up 1 --&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Though I do see a significant delay when resizing by a large margin, so that could be part of it. I still see a (smaller) delay when displaying an image with DecodePixelWidth set to the display size.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer 2      &lt;br /&gt;Right – we use high-quality resampling down to w/in sqrt(2) of the display dimensions, so you have to double (or halve) the area to cause us to do the “good” resampling.&amp;#160; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;As an alternative, if the image quality is acceptable to you, you can set RenderOptions.SetBitmapScalingMode &lt;i&gt;on the element displaying the Bitmap&lt;/i&gt; to speed this up.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.media.renderoptions.setbitmapscalingmode.aspx"&gt;&lt;font color="#008000"&gt;http://msdn.microsoft.com/en-us/library/system.windows.media.renderoptions.setbitmapscalingmode.aspx&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Follow-up &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Thanks for the tip! Resizing to any size is now basically instant and looks pretty good.      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;   &lt;br /&gt;&lt;strong&gt;Subject:&lt;/strong&gt; TranslateTransform+ScaleTransform wierdness (artifacts)&lt;/p&gt;  &lt;p&gt;I am seeing a weird problem when I applied TranslateTransform+ScaleTransform on a group of elements. When I change the scale factor, there is this random/unexpected gap between elements where they should be near each other. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;While the UI thread uses double precision for layout/hit testing, the rendering thread that actually displays everything converts all values to single precision floating point for speed. I haven’t run the numbers to determine if you’re outside the threshold of precision, but I would suspect that given your symptoms you might be.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: when do property changed event delegates get hooked up?&lt;/p&gt;  &lt;p&gt;&amp;lt;Skipped question&amp;gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;A1      &lt;br /&gt;Correct – setting the Filter property (on a view) will cause that view to refresh.&amp;#160; Setting some other property, such as a property on the data item that the filter might read, does not cause the view to refresh.&amp;#160; Nor does it cause the item to be “re-filtered”.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;The doc says that setting Filter (or Sort or Group) causes a refresh (meaning an immediate refresh).&amp;#160;&amp;#160;&amp;#160; It’s not meant to imply that you never need to call Refresh ever again. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;A2 &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;I would argue the most straight forward reading of that MSDN fragment is that Refresh happens automagically.&amp;#160; I know (from experience) that this isn't true for Filters (and can't be true), but it is true for Sorting and Grouping iirc.&amp;#160; I think making it more explicit (i.e. SETTING Filter will cause a refresh) couldn't hurt.&lt;/font&gt;&lt;/p&gt;  &lt;br /&gt;  &lt;p&gt;&lt;font color="#008000"&gt;A3      &lt;br /&gt;It is &lt;i&gt;not&lt;/i&gt; true for sorting and grouping.&amp;#160; Like filter, it is true that adding/removing a SortDescription or GroupDescription causes an immediate refresh, but changing a property on a data item (such as one that participates in the sorting or grouping) does not cause a refresh, or even a “re-sort” or “re-group”.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Any easy way to save a FlowDocument into a rtf or htm file?     &lt;br /&gt;    &lt;br /&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer: &lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;You can use TextRange.Save() with DataFormats.Rtf. You can get the TextRange with:&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer 2:      &lt;br /&gt;The RTF converter doesn’t know what to do with embedded UIElements, so embedded TextBlocks will be dropped. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Followup2: Need data binding; that is why textblocks. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer 3:      &lt;br /&gt;We’ve made Run.Text a DependencyProperty for v4, so if you can build off of netfx4 databinding is supported directly.&amp;#160; Otherwise, for earlier version of the framework see &lt;/font&gt;&lt;a href="http://fortes.com/2007/03/bindablerun/"&gt;&lt;font color="#008000"&gt;http://fortes.com/2007/03/bindablerun/&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt;.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Follow-up3:      &lt;br /&gt;will TextRange.Save support save to html format in .net 4.0 ?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer 4:      &lt;br /&gt;Unfortunately TextRange.Save does not support html in any version.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; async bindings&lt;/p&gt;  &lt;p&gt;Are async bindings evaluated on a background thread?&amp;#160; &lt;br /&gt;&lt;font color="#008000"&gt;Answer:      &lt;br /&gt;Yes!&lt;/font&gt; &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;font color="#008000"&gt;A Rob Relyea must read ( I will come back to WPF in .NET 4 this weekend ).      &lt;br /&gt;&lt;/font&gt;&lt;a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/05/19/xaml2009-and-system-xaml-dll-preview-in-net-fx-4-beta1.aspx"&gt;&lt;font color="#008000"&gt;http://blogs.windowsclient.net/rob_relyea/archive/2009/05/19/xaml2009-and-system-xaml-dll-preview-in-net-fx-4-beta1.aspx&lt;/font&gt;&lt;/a&gt;     &lt;br /&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; Crash in wpfgfx_v0300&lt;/p&gt;  &lt;p&gt;We have a small application that makes extensive use of DoubleAnimations to constantly move things around the screen. The way the code is currently written the animations are created and destroyed on a regular basis. application sometimes crashes in wpfgfx_v0300.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#008000"&gt;Answer:        &lt;br /&gt;&lt;/font&gt;&lt;/strong&gt;&lt;a href="http://support.microsoft.com/kb/962231"&gt;&lt;font color="#008000"&gt;http://support.microsoft.com/kb/962231&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; creating animated gifs using WPF&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer:      &lt;br /&gt;In Win7, WIC supports GIF metadata and you can do this in WPF natively.&lt;/font&gt; &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;Public Announcement from Eric Fabricant&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;b&gt;Subject:&lt;/b&gt; Update available for the .NET Framework Assistant for Firefox&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Included in the .NET Framework 3.5 SP1 is an extension for Mozilla Firefox that adds ClickOnce support and reports installed versions of the Framework to a web server. This initial release didn’t provide a means of servicing the extension out-of-band without depending on Mozilla and was installed as a machine level component which prevented users from uninstalling the extension.&amp;#160; To remedy these issues the &lt;/font&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=cecc62dc-96a7-4657-af91-6383ba034eab"&gt;&lt;font color="#008000"&gt;Update to .NET Framework 3.5 SP1 for the .NET Framework Assistant 1.0 for Firefox&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt; has been released, updating the extension to version 1.1.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Grab your copy today before Firefox 3.5 introduces changes that will break version 1.0 of the extension and render it disabled.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Note: This issue has already been addressed in Windows 7&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;b&gt;Subject:&lt;/b&gt; RE: Creating image from browser&lt;/p&gt;  &lt;p&gt;Can I use GetDrawing() to obtain a snapshot of the FrameworkElement returned from another AppDomain via the CLR AddIn model.&amp;#160; The HwndHost control looks like an instance of MS.Internal.Controls.AddInHost.&amp;#160; I’ve adapted the code below but I’m still receiving a blank image.&amp;#160; Is there something different about the CLR AddIn model that would prevent this from working?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;strong&gt;Answer:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;What’s blocking your attempt is this in AddInHost:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;/// &amp;lt;summary&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;///&amp;#160;&amp;#160;&amp;#160;&amp;#160; GetDrawing - Returns the drawing content of this Visual.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;/// &amp;lt;/summary&amp;gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;internal override DrawingGroup GetDrawing()&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// HwndHost.GetDrawing returns a bitmap by calling the PrintWindow win32 API.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// This logic fails for the WPF hosting WPF (HwndHost + HwndSource) scenario. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// It currently works this way: PrintWindow redirects to Paint; If it is WPF, &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// it calls back into HwndTarget.DoPaint, which invalidates window region. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// However, mil repaints async. Mil might not start paint before print.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// That is why it prints black(bug 117011).&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;//&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// In 3.5 we decide to override HwndHost behavior and return null for hosting WPF, which will print white. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// So we do not waste toner printing black. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// There are a couple of approaches we will investigate in the future release&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// 1. API that prints other than PrintWindow (This enables all WPF hosting WPF scenario). &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;// 2. The host communicates with the add-in via contract, HwndHost GetDrawing calls HwndSource.RootVisual.GetDrawing. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;//&amp;#160;&amp;#160;&amp;#160; (This is add-in specific). &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;if (_addInHwndSourceWrapper != null)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;return null;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;else&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;return base.GetDrawing();&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#ff0000"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;#160;&amp;#160; }&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;So, you have to get to the add-in’s Visual in its AppDomain, and call GetDrawing() on it directly.&lt;/font&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9636977" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx">wpfdiscussion</category></item><item><title>WPF Discussion,090228</title><link>http://blogs.msdn.com/jaimer/archive/2009/02/28/wpf-discussion-090228.aspx</link><pubDate>Sat, 28 Feb 2009 11:38:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9450527</guid><dc:creator>jaimer</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/jaimer/comments/9450527.aspx</comments><wfw:commentRss>http://blogs.msdn.com/jaimer/commentrss.aspx?PostID=9450527</wfw:commentRss><description>&lt;p&gt;Inside Microsoft, we have our own version of “forums” or “discussion groups” ..&amp;#160; &lt;br /&gt;Lots of great questions and knowledge get fleshed out in these conversations.&amp;#160;&amp;#160; Below is a brief (edited) version of the questions that caught my attention in the last two days. Going forward, I will try to watch these discussions closer and post the juicy ones a couple of times a month (it will always be on friday or saturday, so check for them on mondays). &lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: XAML State of the nation&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Rob Relyea says:&amp;#160;&amp;#160; Just blogged &lt;a href="http://blogs.windowsclient.net/rob_relyea/archive/2009/02/26/xaml-state-of-the-union-feb-2009.aspx" target="_blank"&gt;this update&lt;/a&gt; to the community…&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;    &lt;br /&gt;[It is a very transparent, and relevant update, thanks Rob! ] &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Subject: RE: Is there a way to display first frame of video in MediaElement when loaded?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I used MediaElement to display video. If I set LoadedBehavior as anything other than Play, MediaElement cannot display the first frame of the video but a black screen. If I set it to Play, video will start playing right away. Is there a way to only display the first frame of the video but not playing video when loaded?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer:      &lt;br /&gt;Set Scrubbing to TRUE, Pause and Seek to zero. Note, the first frame IS black for quite a few videos. (Fade from black is pretty common). &lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: Media Element Memory Leak?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I have a very media intensive application developed in WPF. It makes extensive use of MediaElements. What I have been observing is memory leak in my application under very specific conditions. I’m using stream media off of the internet like CNN. When the network is running great all is wonderful. If the network is not available, I don’t get any content but the application still runs with no memory problems. However if the net work is spotty and I’m having issues getting the streams my memory begins to build up until the application runs out of memory. &lt;/p&gt;  &lt;p&gt;I know about this spotty condition as I have other services being called that fail due to network timeouts. I’ve isolated these and they don’t seem to be the issue.&lt;/p&gt;  &lt;p&gt;Any ideas or suggestions?&lt;/p&gt;  &lt;p&gt;BTW: I do destroy and create new media elements during the course of the application… It’s almost like the media element even though its removed is still trying to spool the stream after I’ve removed a reference to it. So its just hanging out taking up memory as it tries to spool that stream…&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;Answer:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;You might be hitting the handle leak described in bug XXXX . A section handle is leaked when you create a single instance of MediaElement and free it up without having another MediaElement anywhere else in the app. “Freeing up” a MediaElement includes calling Close(), so maybe it’s also triggering every time you lose the stream. The workaround is to put a second MediaElement anywhere in the app, so that you never end up destroying the only remaining instance of MediaElement. Try that out and see if it works for you.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Follow-up:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;There are also a few known leaks in WMP which MediaElement uses:    &lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/933245"&gt;http://support.microsoft.com/kb/933245&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/959260"&gt;http://support.microsoft.com/kb/959260&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://support.microsoft.com/kb/892313"&gt;http://support.microsoft.com/kb/892313&lt;/a&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: Overlapped drawings and blending&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Hi,&lt;/p&gt;  &lt;p&gt;I have some rectangles that are being drawn in a call to OnRender.&amp;#160; They are all the same height and are being drawn horizontally.&amp;#160; There are times when rectangles have one or more overlapping regions with other rectangles.&amp;#160; Where the rectangles overlap they sometime appear taller.&amp;#160; I am guessing this is due to some blending that is happening on the top and bottom edges of the rectangles behind the scenes.&amp;#160; I tried turning off Aliasing but I cannot afford the side effects it produced since I use transforms and scaling to move these.&amp;#160; Is there an alternative to drawing these on a bitmap and changing the ScalingMode?    &lt;br /&gt;    &lt;br /&gt;Answer:     &lt;br /&gt;&lt;font color="#008000"&gt;If these were top-level FrameworkElements, you could use SnapsToDevicePixels (&lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.uielement.snapstodevicepixels.aspx"&gt;&lt;font color="#008000"&gt;http://msdn.microsoft.com/en-us/library/system.windows.uielement.snapstodevicepixels.aspx&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt;), which is implemented in terms of DrawingContext.PushGuidelineSet (&lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.media.drawingcontext.pushguidelineset.aspx"&gt;&lt;font color="#008000"&gt;http://msdn.microsoft.com/en-us/library/system.windows.media.drawingcontext.pushguidelineset.aspx&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt;).&amp;#160; Since you're using the DrawingContext directly, I'd encourage you to try this too.&amp;#160; There's more info here as well: &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.media.guidelineset.aspx"&gt;&lt;font color="#008000"&gt;http://msdn.microsoft.com/en-us/library/system.windows.media.guidelineset.aspx&lt;/font&gt;&lt;/a&gt;&lt;font color="#008000"&gt; (with pictures!).&amp;#160; Used correctly, this should address the issue for all axis-aligned objects regardless of DPI/scale/size/sub-pixel position.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Subject: Which measure points to take for GUI response times&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;My customer wants to use WPF’s internal measure points (not sure what those are?) to get timings from their UI responsiveness. They would like to answer some basic questions like “what is the total time a certain window or control takes from a user click to the time when it has rendered completely on the screen”?&lt;/p&gt;  &lt;p&gt;Apparently there are a lot of these measure points, but they fail to find the ones that are relevant. Do we have any guidance on which measurements to take and which questions they can help answer?&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Answer:      &lt;br /&gt;&lt;/font&gt;&lt;a href="http://windowsclient.net/wpf/white-papers/event-tracing-wpf.aspx"&gt;&lt;font color="#008000"&gt;http://windowsclient.net/wpf/white-papers/event-tracing-wpf.aspx&lt;/font&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;Follow-up:      &lt;br /&gt;Thanks, that looks like an interesting list, and from reading into it I assume that the WClientLayout event is the one they would be interested in to know the total rendering time of an element as I mentioned below?&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;&amp;gt;&amp;gt;&amp;gt;      &lt;br /&gt;Well, there are many things to keep&amp;#160; in mind.&amp;#160; WPF has a UI thread and a render thread.&amp;#160; The render thread processes “batches” of updates per frame.&amp;#160; So there are lots of events to consider.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;the event raised when rendering has completed is:&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;i&gt;&lt;font color="#008000"&gt;WClientUceNotifyPresent&lt;/font&gt;&lt;/i&gt;&lt;/p&gt;  &lt;hr /&gt;  &lt;p&gt;&lt;strong&gt;Subject: changing icon for Windows app installed by ClickOnce&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;…is there a way to change an icon for an app deployed by ClickOnce, without having to track down the actual .exe location, creating a shortcut to that, then setting the icon on the Shortcut tab?&amp;#160; MSSolve (CRM app for CSS) was deployed this week and no icon was specified in the package, so I'd like to use something other than the default &amp;quot;white square&amp;quot; icon that it came with. &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#008000"&gt;Answer:      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;It is possible to create a custom icon for your application that is deployed by ClickOnce.&amp;#160; You can set the following in description section in your application manifest. ClickOnce will use your icon instead of the default icon in the Start Menu shortcut.      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;&amp;lt;description iconFile=&amp;quot;sample.ico&amp;quot; /&amp;gt;      &lt;br /&gt;&lt;/font&gt;&lt;font color="#008000"&gt;where sample.ico is your icon file which is also included in the application manifest.&lt;/font&gt;&lt;/p&gt;  &lt;hr /&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9450527" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/jaimer/archive/tags/Windows+Presentation+Foundation/default.aspx">Windows Presentation Foundation</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/clickonce/default.aspx">clickonce</category><category domain="http://blogs.msdn.com/jaimer/archive/tags/wpfdiscussion/default.aspx">wpfdiscussion</category></item></channel></rss>