wpf | NET Core UI framework for building Windows desktop
kandi X-RAY | wpf Summary
kandi X-RAY | wpf Summary
Windows Presentation Foundation (WPF) is a UI framework for building Windows desktop applications. WPF supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding and documents. WPF uses the Extensible Application Markup Language (XAML) to provide a declarative model for application programming. WPF applications are based on a vector graphics architecture. This enables applications to look great on high DPI monitors, as they can be infinitely scaled. WPF also includes a flexible hosting model, which makes it straightforward to host a video in a button, for example. The visual designer provided in Visual Studio makes it easy to build WPF application, with drag-in-drop and/or direct editing of XAML markup. As of .NET 6.0 WPF supports ARM64. See the WPF Roadmap to learn about project priorities, status and ship dates. WinForms is another UI framework for building Windows desktop applications that is supported on .NET (6.0.x/5.0.x/3.1.x). WPF and WinForms applications only run on Windows. They are part of the Microsoft.NET.Sdk.WindowsDesktop SDK. You are recommended to use the most recent version of Visual Studio to develop WPF and WinForms applications for .NET. To build the WPF repo and contribute features and fixes for .NET 7.0, Visual Studio 2022 Preview is required.
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 wpf
wpf Key Features
wpf Examples and Code Snippets
Community Discussions
Trending Discussions on wpf
QUESTION
I must have fat-fingered something to turn it off, but when I try to run any c# project (.net 6 windows wpf, or even just a commandline application) in debug mode, I no longer see the Diagnostic Tools
window. This is the thing that displays a real-time chart of memory consumption and other things.
I've been trying to re-enable Diagnostic Tools
but so far haven't been able to do it. I can run in debug mode, everything else seems normal, I can add breakpoints etc. What could have gone wrong?
This is so perplexing!
Looking at the docs (Measure Performance While Debugging), it says...
The Diagnostic Tools window appears automatically unless you have turned it off. To bring up the window, click Debug / Windows / Show Diagnostic Tools (or press Ctrl + Alt + F2).
Here's what I tried:
ctrl + alt + f2
Does nothing.In visual studio going to menu bar: Debug/Windows, there's no item for "Show Diagnostic Tools".
- When I search for
Diagnostic Tools
in the Visual studio search bar, it gives me a link to Debugging > General, but there is no checkbox for "Enable Diagnostic Tools while debugging" in the options dialog.
Of course, I also tried closing/re-opening VS. Also, performed an update and did a "repair" from the VS installer. Still the same behavior.
I also tried to "Reset Windows Layout" and "Reset All Settings" following the directions from this msdn forum post. Still stuck.
According to Mohsyn's suggestion, Looked at Tools >> Options >> Debugging. There didn't seem to be anything checked relating to "Managed or Native Compatibility Mode".
- Blue Shell's answer had the solution!!! It was a matter of launching the visual studio installer, clicking Modify for my installation, going to "Individual Components" and checking ".NET profiling tools"
The next step WOULD HAVE BEEN to uninstall VS 2022 and re-install it.
...ANSWER
Answered 2022-Mar-02 at 01:19I'm glad you got it working.
Diagnostic Tools will not be available for
- Windows Store projects that are using JavaScript
- Windows Store projects that are running on a Windows Phone
- Debugging when Managed or Native Compatibility Mode is checked in Tools –> Options –> Debugging
QUESTION
I am trying to embed WebView2 DLL in a C# project. I have added the 3 DLLs :
...ANSWER
Answered 2022-Feb-24 at 08:24Looks like you have resolved the embedding part of your question and are left with just the deletion of the extracted DLLs.
Because the DLL is inuse but your own process, unless you are able to uload the DLL successfully, I dont think you will be able to delete the DLL.
1st Potential Option
One thing you could try and do is schedule the deletion of the file after reboot. This SO post explains how to do that using P/Invoke and MoveFileEx
.
The example they give is as follows:
QUESTION
We have installed .NET desktop runtime 6.0.1 on our machines. Building happens in a docker container with an image built on mcr.microsoft.com/dotnet/sdk:6.0-windowsservercore-ltsc2022
, which was apparently updated to SDK 6.0.102.
Now our app will crash at startup saying
ANSWER
Answered 2022-Feb-10 at 14:14This seems to be a known bug in .net 6.0.2
see: https://github.com/dotnet/core/issues/7172#issuecomment-1034105137
for a workaround you could try this: https://github.com/dotnet/winforms/issues/6663#issuecomment-1034371295
Or just use the sdk:6.0.101-windowsservercore-ltsc2022 image till a fixed version is released
QUESTION
I'm a long-time C# programmer but I'm completely new to WPF and XAML. I can find plenty of tutorials that say "this is how to achieve this specific thing" but not "this is why you do this to achieve this specific thing". I'm seriously struggling to understand the meaning of various syntax in XAML.
In this case, what do curly braces in attributes actually mean? What do they get translated to in terms of code? How do I reason about them? How do they get interpreted? Why does there seem to be multiple syntaxes (Binding="{Binding someProperty}"
vs Binding="{Binding path=someProperty}"
)?
I must be missing something obvious, but I've spent literally days reading tutorials, watching tutorials, even fighting my way through the immensely dry and difficult-to-understand Microsoft documentation and I still can't seem to figure it out.
Let me try to illustrate where I'm getting stuck.
For example, say I was given this:
...ANSWER
Answered 2021-Nov-12 at 07:13This is part of the syntax of a XAML file, you can read all the gory details here
XAML defines a markup extension programming entity that enables an escape from the normal XAML processor handling of string attribute values or object elements, and defers the processing to a backing class. The character that identifies a markup extension to a XAML processor when using attribute syntax is the opening curly brace (
{
), followed by any character other than a closing curly brace (}
). The first string following the opening curly brace must reference the class that provides the particular extension behavior, where the reference may omit the substring "Extension" if that substring is part of the true class name. Thereafter, a single space may appear, and then each succeeding character is used as input by the extension implementation, up until the closing curly brace is encountered.
More information here
Overview of markup extensions for XAML
Also another good link tendered by @Charlieface
A markup extension can be implemented to provide values for properties in an attribute usage, properties in a property element usage, or both.
When used to provide an attribute value, the syntax that distinguishes a markup extension sequence to a XAML processor is the presence of the opening and closing curly braces ({ and }). The type of markup extension is then identified by the string token immediately following the opening curly brace.
When used in property element syntax, a markup extension is visually the same as any other element used to provide a property element value: a XAML element declaration that references the markup extension class as an element, enclosed within angle brackets (<>).
QUESTION
I am trying to update ProgressBar.Value in FsXaml. In C#, I used the below-mentioned code. I haven't tried to implement the C# approach in F# as using a public field (myCaller) does not seem to me as being a functional approach (let alone the fact that I do not know if it is at all possible to use this C# approach in F#).
...ANSWER
Answered 2022-Jan-15 at 19:18This answer explains how, in Elmish.WPF, progress updates to the user interface can be done from an async.
I have created an example on GitHub that demoes this. The example also demoes another way to call async functions and receive results. And it also demoes how to use mkProgram instead of mkSimple. The demo can be used as a starting template for your Elmish.WPF applications.
This snippet from the demo show the essential code involved in updating a user interface from an async.
Both techniques are based on code from the Elmish Book. You will find a lot of code there that is useful also in Elmish.WPF.
I haven't tried to update a progress bar here, only a status text box, but from this you'll very easily figure out what to do to update anything.
QUESTION
So,
In my WPF application, I want my users to be able to open previews of invoices, so that they may either verify or discard them. I am letting them check rows (each row representing a invoice) in a DataGridCheckBoxColumn
in my DataGrid
, then clicking a button (which runs my CreateInvoicePreview()
method, see bottom of post), having all of the invoice previews be opened in new windows (one window for each invoice).
Well.. What happens now, is: User checks InvoiceA and InvoiceB. Two invoices are opened, but they are the same: InvoiceC. The correct amount of invoices are always opened, but not the correct instance. If I open the temp folder specified in my file path, I see that all invoices in the datagrid has been saved: InvoiceA through InvoiceJ.
Let me take you through the code.
This is the method that creates that builds and saves the actual PDF's, which the WebView2
control uses as source, so that it can display them in-app. It is heavily abbreviated.
I have kept the structure with the nested foreach loops
in case that is relevant.
ANSWER
Answered 2022-Jan-19 at 14:26I managed to solve this by doing the following:
I made a property; public static string PreviewedInvoice { get; set; }
in the ViewModel
of the parent window. In my method that opens the child window (where the preview invoices are to be displayed) I bind it to LicenseHolderID
of the rows that have a checked CheckBox
, via foreach loop
, like such:
QUESTION
In Windows Forms and WPF applications we could use the Settings designer file to save user-specific settings. The docs only mention .Net Framework (e.g. 1 - 4), not .Net Core or .Net (e.g. 5+). I've confirmed that the .settings format and designer still works in .Net 6 WPF on Windows with Visual Studio 2022 though.
My questions is, is the .settings
file format and designer still the recommended approach for .Net MAUI applications? Will it work across all platforms (Windows, macOS, mobile)? If not, is the recommended approach to simply write your own custom file for saving your user settings, and if so, where should the file be written to? Environment.SpecialFolder.ApplicationData
/ Environment.SpecialFolder.LocalApplicationData
, or somewhere else?
ANSWER
Answered 2022-Jan-06 at 09:20It all comes down to your requirements really. There is no silver bullet to this.
I must admit I didn't really know the settings (designer) file that you mentioned. I can tell that that's not a thing (as far as I know) in Xamarin or .NET MAUI. Probably also because there is the concept of a sandbox in mobile apps that is less a thing on desktop apps. So the location where things are saved are a bit more important.
In the comments there are already a couple of great suggestions to get you started. If your requirement is to just save simple types (string, bool, int, etc.) then the Essentials Preferences API should work just fine. I think under the hood that just serializes to a json file and stores it somewhere. Essentials is indeed already part of .NET MAUI at this time.
Xamarin.Forms used to have their own Properties, which is I think a more common concept in .NET applications, but I think the Essentials way is better.
If you want to save more complex things you might want to consider using a local database like SQLite or just roll your own and serialize your settings and save that somewhere, preferably with the Essentials FileSystem Helpers.
One thing to note here, and that is where the value of these libraries come in, is where you save the settings. Do you want the settings to be backed up to a cloud service so if survives a reinstall of the app? Or even an install of the same app on a new phone? Or do you then just want to reset the whole state and don't care about it.
If you figure that out, the rest is up to you! Hope this helps.
QUESTION
ANSWER
Answered 2021-Dec-15 at 17:01Try to remove the following line from the project (.csproj
) file and then build again:
QUESTION
In a WPF application I try to set the culture in OnStartup
.
ANSWER
Answered 2021-Dec-02 at 12:56As it correctly pointed in comment it will work without async
, with async
you need to do it on the applicaton's thread. The key is, that CultureInfo.CurrentCulture
set the value for current thread and as it's a thread pool you doesn't see it in async
event handler, or I suppose you can have it occasionally, if you will get the same thread.
QUESTION
Here is the solution to automatically reduce DataGrid columns width during scrolling. I need a slightly modified version where last column fills all row width left after other columns.
The old solution:
...ANSWER
Answered 2021-Nov-28 at 23:53The UpdateLayout
call is totally redundant. Modifying the Width
will automatically trigger a layout pass. Additionally, both iterations should be merged into a single iteration in order to improve the performance.
The complete implementation is very questionable in terms of user experience: in case the user adjusts the column's width, you would override and reset his customizations, which provides a poor experience. Also the grid would potentially resize itself constantly, which looks and feels odd too. You should at least set DataGrid.CanUserResizeColumns
to false
.
I believe that adding a column filter, that allows the user to hide particular columns in order to compact the view, has a higher value.
From the code you have posted, it's not possible to tell exactly what is going on or what could cause the issue. The actual layout configuration of your DataGrid
control and its context is apparently undisclosed.
However, the issue could be related to how the DataGrid
is calculating the width for each column, in case you give the DataGrid
a fixed Width
and this value would cause the content to exceed the available viewport width (the ScrollViewer
would appear in this case):
a) In case of each column width is set to Auto
, the DataGrid
would simply give each column the required minimum width.
b) In case a column's width is set to star *
size, the assigned width is calculated relative to the available remaining space.
In order to calculate a reasonable value, the algorithm would use the effective size of the DataGrid
.
The point is, that when using a ScrollViewer
, the virtual width would be infinite. Now, if the algorithm would set the last column's width to infinite, you would get a very tiny scroll bar. Therefore, infinite is not a reasonable value. In effect, the final width can not be calculated. That's why the algorithm falls back to use the effective width of the DataGrid
, which is the ScrollViewer.ViewportWidth
. The result is that all columns must be sqeezed into the available viewport space, causing columns to clip their headers and cell content.
I can provide two solutions.
The first solution is to use a fixed Width
for the last column like 1000
DIPs.
This solution does scale very bad. The last column would have either a too small width or a too extreme width that does not make much sense (that's why a reasonable width for the last column can't be calculated - what is reasonable in this context?).
The second and better solution would try to detect if the ScrollViewer
can scroll: in this case the last column would be at least partially out of view. This results in a reasonable Width
for the last column of Auto
: the minimal required space.
The other case, when the ScrollViewer
can't scroll, is when all columns are visible in the viewport. This results in a reasonable Width
of *
in order to allow the last column to fill the remaining space:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wpf
.NET Preview SDKs (7.0 daily, 6.0 servicing, and 3.1 servicing)
Getting started instructions
Contributing guide
Migrating .NET Framework WPF Apps to .NET Core
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