Inside Microsoft, we have our own version of “forums” or “discussion groups” ..
Lots of great questions and knowledge get fleshed out in these conversations. 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).
Subject: XAML State of the nation
Rob Relyea says: Just blogged this update to the community…
[It is a very transparent, and relevant update, thanks Rob! ]
Subject: RE: Is there a way to display first frame of video in MediaElement when loaded?
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?
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).
Subject: Media Element Memory Leak?
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.
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.
Any ideas or suggestions?
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…
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.
Subject: Overlapped drawings and blending
I have some rectangles that are being drawn in a call to OnRender. They are all the same height and are being drawn horizontally. There are times when rectangles have one or more overlapping regions with other rectangles. Where the rectangles overlap they sometime appear taller. I am guessing this is due to some blending that is happening on the top and bottom edges of the rectangles behind the scenes. I tried turning off Aliasing but I cannot afford the side effects it produced since I use transforms and scaling to move these. Is there an alternative to drawing these on a bitmap and changing the ScalingMode?
If these were top-level FrameworkElements, you could use SnapsToDevicePixels (http://msdn.microsoft.com/en-us/library/system.windows.uielement.snapstodevicepixels.aspx), which is implemented in terms of DrawingContext.PushGuidelineSet (http://msdn.microsoft.com/en-us/library/system.windows.media.drawingcontext.pushguidelineset.aspx). Since you're using the DrawingContext directly, I'd encourage you to try this too. There's more info here as well: http://msdn.microsoft.com/en-us/library/system.windows.media.guidelineset.aspx (with pictures!). Used correctly, this should address the issue for all axis-aligned objects regardless of DPI/scale/size/sub-pixel position.
Subject: Which measure points to take for GUI response times
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”?
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?
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?
Well, there are many things to keep in mind. WPF has a UI thread and a render thread. The render thread processes “batches” of updates per frame. So there are lots of events to consider.
the event raised when rendering has completed is:
Subject: changing icon for Windows app installed by ClickOnce
…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? 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 "white square" icon that it came with.
It is possible to create a custom icon for your application that is deployed by ClickOnce. 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.
<description iconFile="sample.ico" />
where sample.ico is your icon file which is also included in the application manifest.