Posts

Increase Performance of your UI using Virtualization

Image
Recently I found an interesting article written by  Eric Stollnitz on increasing UI performance when Lists and collections are involved in your UI. Worth a read. Please follow this link:  UI Virtualization  

Single Textblock with multiple Font settings

Image
Today, I faced a requirement where I had to show some text and a down-arrow in default Ribbon control. Now, since this ribbon can have only one child, I had to come up with smart solution without much of code-behind. Application Menu After surfing, I got to know about this Inline feature of Textblock. TextBlock.Inlines property states:  An  InlineCollection  containing the  Inline  elements that comprise the contents of the  TextBlock . I added: You can also go with code-behind solution like this:

Binding Previous Item's data in ItemsControl

For a data-bound ItemsControl, each item in the source collection is the DataContext for the generated UI container.  By default, the binding expressions used in the ItemTemplate  are evaluated with respect to this DataContext.  This is useful if all of the information that  the template needs is contained in this context. This is actually the case in the vast  majority of data binding expressions.  However, there might be times when you also want  to take a peek at the previous item to do some work.  For example, say you are plotting a  sales chart and you want to show the percentage change in market share over five years. Here the change can be calculated within the ItemTemplate and shown in red for a decrease and in green for an increase. In this case, it is necessary to have information about the previous item in the data-bound list.  This is where the exact scenario that the  RelativeSource class was designed for with...

Custom DataTemplate Id not visible

Image

Taking Screenshots in WPF

Its Very Easy. Look Below: public static byte[] GetPNGImage(UIElement source, double scale, int quality)         {             double actualHeight = source.RenderSize.Height;             double actualWidth = source.RenderSize.Width;             double renderHeight = actualHeight*scale;             double renderWidth = actualWidth*scale;             var renderTarget = new RenderTargetBitmap((int) renderWidth, (int) renderHeight, 96, 96, PixelFormats.Pbgra32);             VisualBrush sourceBrush = new VisualBrush(source);             DrawingVisual drawingVisual = new DrawingVisual();             DrawingContext drawingContext = drawingVisual.RenderOpen();             using (drawingContext)...