Skip to main content

52m
comment Standard MVVM Pattern Implementation
And view code behind (as distinct from subclassed Controls which are totally different) should be avoided whenever possible. See stackoverflow.com/questions/13753228/… (ignore the votes - we all know who they're from - and instead just read the articles and answers I cite).
56m
comment Standard MVVM Pattern Implementation
@GerrySchmitz even if you're a one man shop, if the time ever comes to port your app to a modern framework, or the web (Blazor) you'll be very glad you avoided those bad things. Take it from me who was once a one man shop but because I avoided the bad things we could scale it to other platforms and a bigger team and now bring in millions per year. You never know what your one man app will become!
15h
comment WPF MVVM - Setting the CaretPosition from ViewModel
@dotNET is right. Use a Behavior or an attached command. Please do not handle events in code-behind when avoidable. See stackoverflow.com/questions/13753228/…. Ignore the vote count and read the articles and Q&As I cite.
1d
comment WPF application memory different on different system
@SeanTan you're right, WinUI is definitely not without problems. However I have spent a good amount of time in it and have yet to find anything I can do with WPF that I can't accomplish with it. It does require a lot of hacking and working around but it is possible. As for interop, both WinUI3 and Avalonia use the standard .NET Core stack so there is no issue using P/Invoke in either platform. In fact if you use WinUI you will find yourself doing a LOT of P/Invoke of Windows APIs to get around WinUI's inherent limitations. So WinUI C# with P/Invoke is a fine choice, as is Avalonia.
1d
comment WPF application memory different on different system
@clemens you should not be so cavalier and dismissive of WPF's obsolescence. I am not talking about WPF itself. I'm talking about hardware support for DirectX 9. The possibility of DX9 becoming unsupported and unusable at some future date is very real and if that happens WPF is dead. Have you ever tried running a WPF app on a PC without graphics acceleration? It's near impossible. Anyone beginning a new project would be very wise to look for alternatives.
2d
comment WPF application memory different on different system
This is almost entirely OS/driver determined. Obviously it's not your app causing it. You rarely have to worry about this though. The system should be smart enough to adapt memory usage depending on how much your app really needs and how much else is going on on the PC. I will say that WPF uses DirectX9 which is obsolete, and it's possible gfx drivers are getting to the point of no longer supporting DX9 efficiently. I suspect in the next 5 years (maybe much sooner) WPF will be unusable on modern PCs. If you're new to this I would stay away from WPF and look to WinUI or Avalonia.
Jul
16
awarded Famous Question
Jul
15
comment WPF subscribe to WM_QUERYENDSESSION before Window is created
Maybe dumb question by why are you using a WPF Application object, etc., at all if there's no window? You can still use a lot of WPF APIs from a console or even server app,.
Jul
12
comment How to pass information from the view model to a validation rule
Agree with Marcin's answer. I think you're overcomplicating things. See if this helps - stackoverflow.com/questions/56606441/…?
Jul
11
comment How exactly is a WPF element along with its other visual objects rendered?
This is a bit like asking how gravity works. There are a dozen possible answers depending on how deep you want to get. Fundamentally, WPF always uses DirectX9 to draw pixels to the window. There's a very dense C++ library that you can study if you really want. Everything else is a layer above that, layer upon layer upon layer. How deep do you actually want to go? Too deep and you may never return. :) If you focus more on what you want to achieve rather than just "how does it work" there are many people here who can help I'm sure. But this is a hard question to answer abstractly.
Jul
10
comment How can I apply non-affine transformations to 2D framework elements in WPF?
For what it's worth, WinUI 3 appears to support this. learn.microsoft.com/en-us/windows/apps/design/layout/…. You might be able to use XAML Islands to get this into your WPF app, though I've never tried that particular flavor of Frankenstein's monster so I can't vouch for it.
Jul
10
comment How can I apply non-affine transformations to 2D framework elements in WPF?
The problem is that UIElement.RenderTransform requires a Transform which always boils down to an affine matrix. So you couldn't use anything else, including Skia, to put transformed objects in the visual tree and have them still behave like controls. The only thing you could do is use RenderTargetBitmap to create an image of a visual tree fragment, then use Skia to make a new transformed image, and display the image. But any child elements would be "flattened" into the bitmap and no longer active. So this would work only for simple elements.
Jul
10
answered MVVM: How to handle a List of Models in the ViewModel?
Jul
9
revised Changing default line height in avalon edit
edited tags
Jul
9
revised How to run WPF/Windows Form on a Web browser?
edited tags
Jul
8
comment List of Supported MIME Types for Clipboard "write"
Well that's fracking stupid.
Jul
8
comment How can I prevent webpage reloading when a user clicks on the address bar enter using JQuery or JS
The answer is correct but the defense of the policy ignores that there are legitimate reasons to want to intercept this - most notably in an SPA where the user wants to manually navigate to a different route within the same SPA route structure, e.g., a link in an email or doc. It's a bad user experience for the whole SPA to have to reload and reinitialize its state. Obviously changing to a totally different origin is a different matter, but IMO browsers should give the SPA an opportunity to handle an address bar change when nothing left of the base declared in the html file has changed.
Jul
8
comment How to render AVFrames more efficiently?
A couple VLC source files to start looking at - d3d11_fmt.c - AllocateTextures creates the initial pool of textures. modules/codec/avcodec/video.c shows how to use get_buffer2 to feed textures to the codec. d3d11_surface.c shows how to use CopySubresourceRegion to copy the decoded tex to the output surface. Look this is an extremely difficult thing to do and the vlc code is very confusing because it's multi-platform plain C. It could take you weeks to wrap your head around it all. But it really is the model for how to do this.
Jul
8
comment How to render AVFrames more efficiently?
30 threads?? Good god man!! Whatever gave you that idea? These are the threads you should have: (1) read from disk; (2) decoder/feeder; (3) video presentation loop; 3 threads at most (plus one for audio if using). Read thread just pulls from disk. Decoder thread feeds AVPacket's to the decoder and decodes. Presentation thread handles frame timing and when it's presentation time, pulls a decoded frame/D3D texture from the decoded queue, copies to the "screen" using CopySubresourceRegion, and returns the texture to the "available" queue. Don't use D3D locks, that's what's killing your perf.
Jul
8
comment How to render AVFrames more efficiently?
Look you really need to pull the VLC player source code and understand it thoroughly. There's just no way to explain the entire process in a Stack Overflow post. videolan.org/vlc/download-sources.html. This is literally the best reference you will ever find for how to make a player with libav and Direct3D.
1 2 3 4 5