I see CacheMode in Pivot control (and other controls) like this:
<phone:PivotItem CacheMode="{x:Null}" Margin="0,-5,0,0">
I knew that Windows Phone just has BitmapCache value for it. anyway, what is RenderAtScale property of it for?
I have an app which will has lots of values in memory and I fear that a memory leak will occur. Should I use this cache? and what is the best value for RenderAtScale for my scenario?
A question with a link to the answer in it? Sorry but have to poke fun at that. RenderAtScale would be for example if you have a UIElement that you're applying a ScaleTransform or Zooming in/out to make it larger than it is naturally, than you would also want to apply your RenderAtScale property. See this example for more info.
As for the best value for your scenario, well you're not messing with any Scale so I don't think you'll use it.
Careful with how you use CacheMode since it can kill performance if not used correctly. If I remember right, a lot of the WP stuff implements it automatically for elements animating things where caching helps for like Translates/Opacity/Rotates, etc etc. Also keep in mind, all the children will inherit that declaration if you set it, so you could end up with a lot of stuff cached you may not even need to.
Hope this helps.
Related
Title of my question probably is descriptive enough, yet here is the rest:
I need to plot histograms and area charts for some numeric values. I already managed to do it partially using a CategoryXAxis, the only option which ColumnSeries Supports.
Unfortunately labels don't show good enough (Position, Spacing, ...) and also Tick Markers are meant to be for category data and show between Columns.
As the task looks really trivial, and i need to do this many times with different options, i was thinking maybe there is a way to do this using a NumericXAxis which is pretty simple and meant to be used for numeric data.
Unfortunately i don't see a way to convert use NumericXAxis for ColumnSeries? So I hope someone could help me on this.
Requirements: I use .Net Framework 4.0, C#, WPF
Note: I'm more interested in Code-Behind rather than XAML.
An explanation relative to this format would be nice, I've been looking for a simple explanation; however, nothing really explains in a simplistic way without making me have to read pages of things.
Your object will have a position (Left, right...).
The margin is the space between your object and another object.
The padding is the space between the internal objects inside your parent container-object...
and the blue zone is the place where are your children object.
Some Background
I am writing an application that moves a multitude of windows on the screen which demands a real-time constraint. I normally set the window positions using the following format:
this.Left = position.x;
this.Top = position.y;
The Question
What I would like to know is if this is the fastest, or most efficient way to do this. Does setting the Left automatically fire off an event to refresh, or does it wait for an OnRender event?
Secondly, why isn't there a function to simply set the position altogether? Or is this even necessary? I am aware that the Windows API has SetWindowPos, but I would prefer to stay away from unmanaged code. Would using this function be faster?
I'm not sure if it's the most efficient but calling it multiple times may have performance issues. The reason for this is because the Left and Top dependency properties have a PropertyChangedCallback instance set to the OnPositioningChanged method. This method calls InvalidateArrange. From the link:
Frequent calls to InvalidateArrange or in particular to UpdateLayout
have significant performance consequences.
I know it's an obvious answer but the best way would be to benchmark both methods and see which one works for you. Regardless of whether you go the unmanaged route or stick with your current method, I imagine the same rendering calls will have to be made at some point (happy to be corrected on that).
I'm trying to implement IScrollInfo for WPFExtensions' ZoomControl in order to be able to use this control in combination with ScrollViewer. However I'm having difficulty understanding how to correctly calculate HorizontalOffset and VerticalOffset properties and where I need to update them .At first I suspected it was TranslateX and TranslateY but that only gives you the offset relative to the position of the content from the last time the Zoom property changed and not the global offset of the viewport.
This seems like a very common need for users of ZoomControl. Has this effort been done before?
WPFExtensions seems to be very poorly documented and not very
self-explanatory, is there a good source of information to better
understand how ZoomControl works?
EDIT: I've been using this control as a reference in my efforts as it implements IScrollInfo. However the 2 controls have different approaches to invalidate the view and update data so it didn't get me very far. I prefer using WPFExtension's control since it is simpler to use, has better animation and seems to be more widely accepted.
Currently I'm using a System.Windows.Media.DrawingGroup to store some tiled images (ImageDrawing) inside the Children-DrawingCollection property.
Well the problem is now, this method gets really slow if you display the entire DrawingGroup in an Image control, because my DrawingGroup can contain hundreds or even thousands of small images it can really mess up the performance.
So my first thought was to somehow render a single image from all the small ones inside the DrawingGroup and then only display that image, that would be much faster. But as you might have figured out I haven't found any solution so simply combine several images with WPF Imaging.
It would really be great if someone could help with this problem or tell me how i can improve the performance with the DrawingGroup or even use another approach.
One last thing, currently I'm using a RenderTargetBitmap to generate a single BitmapSource from the DrawingGroup, this approach isn't really faster, but it makes the scrolling and working on the Image control at least a little smoother.
I'm not sure this applies to your problem, but I'll post it here anyway since it might help someone:
If not all of the images in the drawing group is going to be visible at the same time, you could set the ClipGeometry property to whatever you want it to draw. This effectively tells WPF that the parts outside of the geometry is not needed and will be skipped during rendering.
A few other things you could experiment with are:
Freeze the drawinggroup before applying it to your image source. At least it couldn't hurt (unless you really need to modify the instance, but remember you could always just create a new one instead of modifying the old)
Try different ways to display your drawinggroup. For instance as a DrawingVisual (which is considered light weight) or as a DrawingBrush to paint e.g. a rectangle.
Combine the small images into smaller groups which you then combine to your bigger group. No idea if this improves or hurts performance, but it could be worth trying.
I'm working on a problem having to do with tiled images, with the added complication of having to display some images overlaid on others.
I haven't run into any performance issues (and likely won't since my images are rather small and relatively small in number, around 100 max.), but I did come across the Freeze method in a code sample for the DrawingImage class. The comment for it was "Freeze the DrawingImage for performance benefits."
The Freeze method also applies to the DrawingGroup class. Maybe give it a try?