Coffeehouse Thread

62 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

OK WPF is just really different from WinForms, and is the Bestest in the World. But also really Slow.

Back to Forum: Coffeehouse
  • User profile image
    BitFlipper

    OK I know many people will swear by WPF/XAML but being much more familiar with WinForms I find it frustratingly difficult to get anything working properly.

    To explain a bit further... I've been trying to port a WinForms based TreeListView over to WPF while using this project as a guide for how WPF does things. In some cases I have virtually identical code but just can't get things to work right. The issue I have is that when things work fine, great, but when things don't work as they should... well good luck figuring out *why*. Some issues I ran into:

    • I spend the whole day trying to get content to show up in my TreeListView. Everything compiles without error, yet the ListViewItem objects just didn't show up. Just through luck I found out that my ListView derived class can't use generics. I used generics so that you can specify what type of object the node will contain. However XAML doesn't like generics and after removing it from my TreeListView, some things started working.
    • I can't get the tree column nodes to behave like tree nodes as per the linked to project. The relevant code is practically identical, other than for changed type names where appropriate. No luck. Once again compiles fine but it just refuses to use the supplied CellTemplate. I have no idea how to debug it since I can't step through the XAML code.

    Is there some sort of trick to debug these kinds of issues? Any suggestions would be welcome.

  • User profile image
    JoshRoss

    With the implosion of Silverlight, I went from WinForms to HTML5. There were so many significant changes, that I never thought it stable enough to develop front line business apps on it. Not that HTML5 is stable, but I have the full code for all the libraries I use.

    -Josh

  • User profile image
    BitFlipper

    My biggest issues with it are that it is severely over engineered and almost always suffers from performance issues. Well that and the whole good-luck-figuring-out-why-it-doesn't-work issue...

    Whoever implemented the WPF TreeView should be sent to a Performance 101 class. It's a poster child for how NOT to implement a TreeView.

    I get that it is extremely flexible compared to WinForms but I think MS went too far which resulted in it becoming over engineered such as it is.

    BTW I wonder if the periodic freezes we see in Visual Studio is a result of its UI being switched over to WPF. I don't remember seeing this in earlier versions.

  • User profile image
    PeterF

    A comment that WPF is a step back from Winforms is understandable if you haven't used MVVM/Databinding. Maybe the treeview is not needed anymore after a redesign?

  • User profile image
    DeathBy​VisualStudio

    WPF is great but unfinished. It's like the early versions of .NET and Visual Studio. Unfortunately Microsoft chose to deprecate it instead of finishing it and hasn't produced a replacement for it for LOB app developers to-date IMO.

    I'd agree with JoshRoss: web-based clients are the way to go now (and not the bastardized HTML5 Windows Store App mess). The world is moving forward without Microsoft and no one is going to wait for them to get their devices, APIs, and overall ecosystem straight. Best they can hope for IMO is a huge adoption of Azure and great sell through of Office on a growing list of supported platforms.

    If we all believed in unicorns and fairies the world would be a better place.
    Last modified
  • User profile image
    BitFlipper

    @PeterF:

    Yes I'm using MVVM/Databinding in my design and I agree it is very powerful. Part of what I mean with "a step back" is that if all you want is a simple TreeView that works more or less like the WinForms one you are out of luck. Instead now you will spend a whole lot of time re-inventing the wheel since the stock WPF TreeView is unusable for all but the most simple cases due to its performance issues.

    The one I'm working on now is based on the WPF ListView which has fewer performance issues. However I can't figure out why I can't make the tree column cells act like a tree, similar to the linked to project. I've duplicated almost every last bit of code with no luck.

    At this point I'm wondering if I should not just port my original from-scratch WinForms based TreeListView to WPF starting from a simple Canvas or Grid. I really don't need databinding.

  • User profile image
    BitFlipper

    HTML5 really isn't an option for my purpose. I'm working on a Visual Studio plugin. And I need less abstraction, not more.

  • User profile image
    RealBboy360

    Some things have to be in WPF, if you're doing scanning, printing, displaying documents, or you just need to take a load off the server like making reports.  There are some things you can do in HTML (or without a custom plug in).  WPF/Silverlight is much easier/better than web programming, but that's not what should be driving your development.

    WPF seems to be slower than winforms, but certain things like binding and templates make it faster for development and might be better for performance, I don't know.  The web installation and updates from a server is probably the main reason to use WPF (I don't know if winforms has it).

    If you're doing major development with WPF, I'd use a 3rd party for your treeview like Telerik or infragistics or something.  Telerik works decent with WPF.

  • User profile image
    magicalclick

    I love WPF and XAML. Winform sux. XAML is so much faster to developer and the code is so much easier to read. And for pixel nerd like me, XAML is way better than Winfrom. The content flows much better on WPF than WinForm. And I can prototype so much faster with fancy graphic on WPF.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified
  • User profile image
    BitFlipper

    WPF fast? I don't think so. There's an old thread on C9 where I complain about my computer that can run Crysis without issues but was brought to it's knees with a simple WPF application that had about 20 controls with drop shadows.

    And this really doesn't have anything to do with web development, on any level.

  • User profile image
    PerfectPhase

    , RealBboy360 wrote

    If you're doing major development with WPF, I'd use a 3rd party for your treeview like Telerik or infragistics or something.  Telerik works decent with WPF.

    Was about to say the same thing, get yourself a Telerik subscription, makes life so much easier.

  • User profile image
    PerfectPhase

    @BitFlipper: Having VS take a dependency on WPF was the best thing to ever happen to WPF, for example http://lukhezo.com/2011/09/24/itemscontrol-performance-improvements-in-net-4-5/ 

  • User profile image
    TexasToast

    @BitFlipper: I agree with you.   Winforms can put together a powerful application in a matter of days.   I am not talking about HTML and server based apps.   I have done a lot of WPF apps also and I like some of the things about them, but as far as standard controls they are just not as simple to put together.   They are slower also.   Drawing your own graphics in a WPF is fast ( so if your app is about drawing lines , bitmaps , zooming I would go with WPF.   If you are just doing a general purpose tree control with some list views,  tabbed views stick with winforms.  

    Like DBVS said,  WPF never really was finished to the point of being easily used like winforms.   Killing Silverlight was a huge mistake because this was going to put the final touches on WPF also.

  • User profile image
    RealBboy360

    If you have a lot of items in your listboxs/treeviews... make sure you use a template and virtualizaltion!!  You're going to get terrible performance if you have 1000 items and don't do this.

    Also, someone mentioned drop shadows above, don't use those.  That kills performance and a known issue.  Put a jpg or gif of a shadow under your control.

  • User profile image
    BitFlipper

    @RealBboy360: Yes I'm turning on virtualization. I also implemented a hierarchical collection derived from ObservableCollection.

    Maybe if I explain what I'm doing it would be easier to recommend what approach to take...

    So I'm writing a VS plugin. Think of the Quick Watch window where you can drop variables and then expand them to inspect their member values etc. There is one big problem with the Quick Watch window though - your application isn't running.

    My plugin adds a Live Watch window. What you do is break into your application, then drop one or more variables onto the Live Watch window (similar appearance to the Quick Watch window). Press F5 and you can now browse those objects in real time while your application is running at full speed.

    Right now this all works well. I'm not going to go into detail about how this works, but the data I get back to display is essentially just the part of the tree that is visible at that time. So even if you have multiple nodes expanded with thousands of objects (think of large arrays), at most only a few dozen items would need to be refreshed at any point in time. Right now one refresh operation takes less than 3 ms. Because of this I can easily do 10 scans a second without any noticeable impact on the debugee.

    So the bottom line is that I need to continuously refresh the visible nodes in the tree. I'm worried that data binding etc is going to slow things down. For the above 3 ms operation, refreshing my current custom WinForms TreeListView itself takes less than 0.5 ms, even with thousands of nodes.

    Should I just port my current TreeListView to WPF using Canvas or Grid as a basis, or would the current WPF ListView control that I'm trying to turn into a TreeListView end up being workable for this use case? Any suggestions?

  • User profile image
    DeathBy​VisualStudio

    @RealBboy360: and add to that the issue with UIAutomation. I can't remember what the customer had loaded (it wasn't a Wacom digitizer or anything obvious, maybe a screen capture program like "snag it").

    If you're unfamiliar with the performance issue that UIAutomation creates here's a few threads to get you started:

    Now I'm not suggesting that you hobble the app and prevent tools that the disable use from working with it but you might consider a setting that enables or disables that functionality. When we disabled it performance was much improved.

     

    If we all believed in unicorns and fairies the world would be a better place.
    Last modified
  • User profile image
    Bass

    Never felt the need to learn WPF because WinForms was never really broken for my purposes. So I'm more like it's not like WPF is crap, but WinForms is good enough.

  • User profile image
    RealBboy360

    Well you can use winforms in WPF with <WindowsFormsHost , many times there's a 3 party tool for scanning or documents, you can use in there.

    The UI looks better though and the data binding kicks *.  I have pop-ups that I share with WPF and silverlight (not a big deal anymore).   I'm guessing it's easier to integrate web services and I can update the WPF file from link on a server (maybe you can do that with winforms, I dunno).  The main thing is that MS is going to support it better, at least for the... well crap I don't know, I just try to put all my logic in WCF services.  Well WPF has a better chance of having newer features in the future.

    Most people can't really write metro apps LOB cus most businesses are not going to upgrade to windows 8.

     

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.