Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responsive UI Tips

Tags:

c#

.net

wpf

I would just like a few tips when i want to create a responsive UI.

I know how to use:

Dispatcher
Task
BackgroundWorker
Threads

I am looking for more advance tips, like binding tips... When i have 50+ controls on my UI that needs to update.

PriorityBinding
Populating ComboBoxes
Populating ListBoxes, ListViews

When processing data in the background... Best practices maybe when it comes to long running proccess.

What else can i do to make my UI 100% responsive.

like image 560
Willem Avatar asked Nov 01 '11 09:11

Willem


2 Answers

  1. FastObservableCollection

  2. Manipulating PresentationSource

  3. Using PLinq or Linq on multiple threads by using AsQueryable() for dynamic filtering of data sources than single threaded and thread agnostic CollectionView.

  4. Readymade Gifs over animation

  5. Vitualization of non-virtualized panels like canvas

  6. Deferred scrolling

  7. Trigger.Exnter \ Exit Actions for animations.

  8. BeginStoryboard.HandoffBehavior="Compose"

  9. Using Hardware over software acceleration.

  10. Avoiding WindowStyle=None, AllowTransparency=true, Background=Transparent, TileMode

  11. Configure RenderOptions.BitmpaScalingMode as LowQuality and enable caching. Enable PresentationFontCache windows service.

  12. Use Staticresources over Dynamicresources

  13. Avoid inheritable dependency properties. Also avoid heavy operations in property changed call backs.

  14. Use Freezable brushes. Avoid x:Name / Namescoping / Binding to their Color propertys them to be freezable all the time.

  15. Set background of the border, if it encapsulates a visual than setting visual's background. Similar is if you have set a Brush as background of a visual then specify Brush.Opacity than Visual.Opacity.

  16. Value converters must have minimulistic code. use Binding.IsAsync and PriorityBinding wherever applicable.

  17. Use Expanders with IsExpanded=False by default.

  18. CompositionTarget.Rendering fires on each rendering cycle so should be used only if required. Detatch it on any opportunity.

  19. WPF DataGrid should avoid heavy use of combobox columns and editable Template columns, as the combobx templates try to load selected value and use the display member path by actually searching it from the items source of each combobox and template columns leak when used with highly observable collections.

  20. Use WPF Extedned Tooklit based Shader effects and New Pixel Shader APIs such as Blur, Shadow.

And Many more...

like image 112
WPF-it Avatar answered Sep 16 '22 16:09

WPF-it


I always found lazy loading very helpful to prevent large data amounts being loaded at once, which is where most of the startup time goes when handling large amounts of data. Bind your records to virtualized item controls, to minimize the memory footprint (obviously WPF is your judge on what's necessary in memory).

But to be honest : Martin is quite right...50+ databound controls,...man, that's freakin' hell ;-)

And your quest for 100% responsiveness, I guess, needs further explanation. To my understanding, applications can be responsive or not (taking user input / producing output vs being stuck doing nothing). Do you aim best performance? Or is it a rowlocking-scenario you're facing (let the user edit other records while performing long tasks on certain records)?

I think some of what AngelWPF has mentioned can be found in this neat article on priority binding.

like image 20
Sebastian Edelmeier Avatar answered Sep 16 '22 16:09

Sebastian Edelmeier