PresentationSource | WordPress developed by the Seattle WordPress community | Content Management System library
kandi X-RAY | PresentationSource Summary
kandi X-RAY | PresentationSource Summary
Plugins for WordPress developed by the Seattle WordPress community
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PresentationSource
PresentationSource Key Features
PresentationSource Examples and Code Snippets
Community Discussions
Trending Discussions on PresentationSource
QUESTION
I'm working on a legacy application that uses WPF and WinForms for its UI. WPF makes up for the vast majority but the application main dialog is still in WinForms.
So far I've been able to have them work together nicely (thanks to System.Windows.Forms.Integration.ElementHost) but I can't get the WPF windows to center on their WinForms parent.
My code looks the following.
WPF Control (hosted in the ElementHost)
...ANSWER
Answered 2020-Nov-28 at 01:58Use Application.Run(new MyForm2());
and then click the button to create a WPF Window
that centers on the main form.
QUESTION
I am attempting to "blurr" a windows 10 user control when an adorner is placed over it.
More exactly, I have a datagrid control in a wpf user window. When a cell in the datagrid is selected, an editing adorner is created over the datagrid control.
...ANSWER
Answered 2020-Mar-26 at 05:17I'm not sure I can give you a whole solution, but I can at least explain why your attempt doesn't work and maybe point you in the right direction.
In WinForms (and C++ I think), each control is sort of its own "mini-window". By which I mean each control is given its own "handle" by the OS, and the OS treats them as individual entities on the screen. WPF is different, the illusion of "separate controls" in a window is one created by the WPF framework. As far as the OS knows, there is only one entity: the Window
and all further logic is handled internally by WPF. This is only mostly true, though, as I'll bring up later.
The reason I bring this up at all is because your line of code PresentationSource.FromVisual(dataGrid)
is going to give you the handle of the Window
in which the DataGrid
is being hosted, not a handle unique to the DataGrid
itself (since the DataGrid
has no handle). And so everything else you do using that handle is actually being targeted to the entire WPF Window
as a whole.
All of the rendering inside a WPF Window
is handled internally by the WPF framework (plus your code), not directly by the OS (as in WinForms and C++), so using a native method that tells the OS how to render something wont work on a specific element inside the Window
.
As I see it there are two routes you can take in trying to create this effect:
You could try to recreate the "glassy" effect inside WPF. This would involve recreating or getting ahold of whatever algorithm is used to visually distort an area to produce that effect, and then somehow implementing that into a control. I wouldn't really know where to start with that other than just Google.
You could try to take advantage of other WPF elements that do have their own handles.
The two main WPF elements I know of that have their own handles are
Window
andPopup
. You might be able to create one of those and position it where you need it, just like you're currently doing with your adorer. This will get tricky though because these elements are actually outside theWindow
that spawned them and aren't really linked to it. So when you move the mainWindow
across the desktop, thePopup
or sub-Window
won't move with it. You might also be able to drag other windows between your WPF window and the popup you create (not sure about that, though).There is maybe one other possibility under this heading, and that is the
WindowsFormsHost
control. This is a WPF control that hosts a WinForms control in a WPF window. The WinForms controls hosted inside presumably are given their own handle by the OS (since that's how WinForms operates). This one might be your best bet, except I've never tried it and I have no idea how theWindowsFormsHost
will interact with other elements that are around or underneath it. So it also might not work at all for what you need.
Good luck.
QUESTION
I have a WindowsFormsHost
nested inside a WPF ScrollViewer, for some reason, after applying clipping it seems that the WIndowsFormsHost
is not filling up all of the available spaces, ie: the control has been overclipped.
Here's how it looks like-- note that there are a lot of white space, which really should be filled with blue color.
Here's my code in totality:
...ANSWER
Answered 2020-Jan-11 at 04:18I found the solution-- the idea is that you need to scale properly for DPI, as per below.
QUESTION
I am trying to make a taskbar app with WPF and I need to be able to react to windows being created and destroyed. In winforms, one way of doing this is to override the WndProc procedure to be able to receive and process Windows messages and I am trying to do the same in WPF.
After searching around and fiddling with the code for a week, I just can't get the thing to work.
I only get some messages when the app first starts up and I may get some messages only when opening a new explorer window although the message itself is never the "window created" message. Apart from that, the WndProc function is never called no matter how many windows I open, switch to or close.
I tried following the answers from Getting Wndproc events to work with WPF?, from How to handle WndProc messages in WPF? , several other websites from search results as well as the "MVVM-Compliant way" described in this blog post which is also referenced in one of the answers on stackoverflow.
By all accounts, this should work but it just doesn't. I tried it on two different computers, both running Windows 10 and the behavior is the same. WndPorc is just not called.
Here is some of the code I tried to use as well as a link to the zipped VS project:
...ANSWER
Answered 2019-Jul-15 at 13:06Here is an example of a WPF window that handles external window being created and destroyed:
QUESTION
Update
Microsoft acknowledged the issue:
Gepost door Microsoft op 13/10/2017 om 11:38
Thank you for reporting this. We are aware of this issue and are fixing it in a future version of .NET. There is also a related issue that is being released in a servicing fix that will drastically reduce the possibility of hitting this problem. This will be serviced relatively soon.
Problem
Our WPF application is being used on tablets using touch (no stylus) and we are experiencing issues after the installation of .NET Framework 4.7. Two scenarios can occur after using the application for a while: either the application freezes completely and has to be restarted or all touch functionality in Popup
or Window
elements is disabled. There is quite a difference between the two but I believe the cause is the same.
Scenario 1: full freeze
- The application becomes fully unresponsive, the application must be closed using the Task Manager
- Touch nor mouse can be used
- Sometimes the following error is thrown before the application hangs:
Index was outside the bounds of the array.
This is the stacktrace:
...ANSWER
Answered 2017-Sep-12 at 22:12Update:
Below workaround for a workaround solution does not work well.
The problem is that all finger taps are interpreted as mouse clicks. The custom touch scroll only works smoothly for content which does not react on mouse clicks. To make it working fine you would need to find a way to "eat" the mouse click events when a scroll action is performed.
I may have found a workaround for the broken touch scroll.
Handle WM_TOUCH and use a custom TouchDevice.
Credit goes to Luca Cornazzani: Enable multitouch on WPF controls
Another source i used (for the TOUCHINPUT definition) : WPF and multi-touch
On app startup call the well-known DisableWPFTabletSupport function.
MainWindow.xaml:
QUESTION
There are dozens of simular Questions to this topic on StackOverflow already and I browsed a lot without finding a suitable answer, that would apply to my problem.
TaskI have a WPF Window in a MVVM pattern, which has quite a lot of buttons that open other windows. I'd like to have most of my windows appear in relation to my buttons (I have a toolbar in the top right corner of my MainWindow and want most of the smaller windows to appear right below my buttons), or at least on the same screen as my MainWindow.
ProblemAt first, I thought this wasn't such a big deal and there were plenty of blogs and questions on google to this topic, yet all of them won't work on my project.
I am using the MVVM pattern, which means:
- I can't use
Mouse.GetPosition(ButtonName)
on my Buttons, as the ViewModel doesn't know their names - I can't use
Mouse.GetPosition(sender)
in a Click-Event, as most Buttons use commands. - I also apparently can't use PointToScreen in my view's code behind, as it will cause an exception (this visual object is not connected to a \"PresentationSource\")
- I could use
Mouse.GetPosition(this)
on a MouseMove-Event in my view's code behind and hand it down to my ViewModel, which will update a Property, that I can use in my Commands when creating the window, but I don't like the idea of having to update a property permanently. Also without PointToScreen I can't set the point in relation to my screen. - I can't use any WinForms references, as this would cause conflicts in my current project
- Additional to Buttons, I also host a UserControl with Hyperlinks in my MainWindow, which open additional windows, that should be in relation to the hyperlinks.
there are quite a few different answers to a question here, but none of them did work for me.
As my ViewModel doesn't know the XAML elements I can't simply access by point notation as suggested here
- My ViewModel doesn't know a WorkingArea, so I couldn't even get my window to appear on the same screen as my MainWindow as demonstrated here
- As most of the other answers, this one seems like it won't work in a ViewModel
I've spent quite some time on a problem, that rather seemed trivial at first, already. Since most questions I've viewed so far seem to target windows without MVVM, what would be the proper approach in a ViewModel to set the location of a window to either my mouse coordinates or the coordinates of a clicked button?
edit: MouseDownEvent as requested in Comments: Xaml:
...ANSWER
Answered 2018-Aug-30 at 12:19Here comes an example of how you can pass a parameter to Command in your Vm:
Window Class:
QUESTION
I am calling HwndSource.AddHook()
to get the messages to be handled in my WPF window. I wonder whether I need to call HwndSource.RemoveHook()
when the window is destroyed - this window is not the MainWindow. If so, what is the right place for calling it (Closing()
)?. It seems the Hooks are removed when the window is destroyed.
ANSWER
Answered 2019-Apr-26 at 12:59If so, what is the right place for calling it (Closing())?
You could override the OnClosed
method.
Is this okay? or should I keep the source object used for
Add()
and use it forRemove()
?
It's "okay" but it's unnecessary to call PresentationSource.FromVisual
and cast the result more than once. This is probably how I would do it:
QUESTION
I'm trying to trace WPF operations by ETW provider embedded into PresentationSource. When I traced real application I was bit by changing already triggered operation Id from Post to Start phase.
At the source code I found that Id is relied on address of the object which might be changed during GC operation: https://referencesource.microsoft.com/#windowsbase/Base/System/Windows/Threading/DispatcherOperation.cs,dff34e59b0cffd1e
Does anybody know how to track by ETW such object relocation?
...ANSWER
Answered 2018-Nov-29 at 10:07Such movement might be tracked by:
ProviderName: "Microsoft-Windows-DotNETRuntime"
EventName: "GC/GCBulkMovedObjectRanges"
Event might be parsed by ClrTraceEventParser.GCBulkMovedObjectRanges
Originally answered there:
UPDATE:
Due to tracing WPF operations I would say that approach with changeable ID is worst ever implementation. It is implemented incorrectly.
Id has fixed address position during gather that Id but whole operation isn't ensure that tracing message contains correct address. It might be already moved when event is raised.
I got next event sequence:
- WClientUIContextPost
- GCBulkMovedObjectRanges
- WClientUIContextPost
Where last one may contains moved or unmoved Id. Only gods know.
The event GCBulkMovedObjectRanges is usable in 95%. But sometimes it is fails.
So it no way to track it reliable. Very sadly that this architectural/implementation mistake turn feature unusable.
QUESTION
I want to know if I have completed an input word on a wpf textbox, but TextChanged
event will fire even if I am typing in IME input. Therefore, I try to distinguish WM_IME_CHAR
from WM_CHAR
message (like I did in c++ windows form). I can get window message for a WPF window using this method, but how can I get the message specifically for a textbox inside WPF window?
ANSWER
Answered 2017-Sep-06 at 09:56After google around, I found an article: imeで変換状態中でもtextbox-textchangedが発生する
Simply, I register three events:
QUESTION
Here is my XAML:
...ANSWER
Answered 2018-Aug-23 at 14:56The XamlWriter.Save
method has some serialization limitations that are mentioned here. One of them being that;
Common references to objects made by various markup extension formats, such as StaticResource or Binding, will be dereferenced by the serialization process. These were already dereferenced at the time that in-memory objects were created by the application runtime, and the Save logic does not revisit the original XAML to restore such references to the serialized output.
So your generated template is missing a TemplateBinding
to the IsOpen
property of the Popup
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PresentationSource
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page