Responsive UI Tips

后端 未结 3 732
既然无缘
既然无缘 2020-12-23 23:44

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

相关标签:
3条回答
  • 2020-12-24 00:12

    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.

    0 讨论(0)
  • 2020-12-24 00:31

    50+ controls on a single UI sounds like it was designed by a coder and optimising the code will probably just offset the real problem for a while. Best thing to speed that up is to seperate your functionality out onto different screens or hide the less used information behind menus.

    0 讨论(0)
  • 2020-12-24 00:35
    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...

    0 讨论(0)
提交回复
热议问题