Click here to Skip to main content
15,885,216 members
Everything / Desktop Programming / WPF

WPF

WPF

Great Reads

by Dr. WPF
.NET 3.5 SP1 is here! It's time to break out your DirectX skills. This article provides the information necessary to get started using a new DirectX interop feature in WPF called D3DImage.
by Daniel Vaughan
Calcium provides much of what one needs to rapidly build a multifaceted and sophisticated modular application. Includes a host of modules and services, and an infrastructure that is ready to use in your next application.
by Fredrik Bornander
WPF Implementation of the spinning panel frequently used on the iPhone
by Sacha Barber
It would probably be like Cinch, an MVVM framework for WPF.

Latest Articles

by Macabies Gilles
An easy-to-use filterable, multilingual custom DataGrid control for managing and filtering data for your WPF applications
by gabriel4sonic
Shows how to use OpenGL in a .NET WPF application by directly incorporating an OpenGL window as a child of the main WPF window, making it behave more like a control
by Jo_vb.net
Part 2 of my article about 'Schafkopf' introduces Automated Bidding
by Peter Sun (247)
Implement ChatGPT API in C# WPF with GPT3.5-turbo

All Articles

Sort by Updated

WPF 

N 24 Apr 2024 by Graeme_Grant
I did a quick Google Search wpf datagrid multiselect dragging with scroll[^] and found this working solution: DataGrid auto scrolling when doing selection - solved[^]
N 24 Apr 2024 by Member 16239100
I want a WPF datagrid which can select the rows same as we can do in Win explorer. For the i have implemented some code and need some help in that. Here the autoscroll for up direction is working fine but for downside autoscroll its not working....
N 23 Apr 2024 by Member 14770314
This only addresses code behind code. There is no solution for event handler or command handler that lives in a databound ViewModel. No solution for that. It forces code behind and not View Model implementation, or at least a partial mvvm solution.
N 23 Apr 2024 by M-Badger
I've not tested this but it would appear that the MS interop library version that you are using doesn't know how to convert images into MathML or LaTeX format. So either you need to convert them to MathML or LaTeX in the document before saving...
N 22 Apr 2024 by Member 7920931
Get element clicked in a canvas. myCanvas.MouseLeftButtonDown += OnMouseLeftButtonDown; private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { var layer = (Canvas)sender; var element =...
U 22 Apr 2024 by Conduct dotnet
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the...
N 22 Apr 2024 by Jo_vb.net
I have a strongly typed DataSet (DataSet.xsd) with table "Credits". This is easy to use for read/write table "Credits" to *.xml file. Binding to DataGrid and view data is no problem. But for filtering and grouping a CollectionViewSource seems...
U 21 Apr 2024 by Graeme_Grant
Here is a working example: string link = "https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/introduction"; Process? process = Process.Start(new ProcessStartInfo(link) { UseShellExecute = true }); process!.WaitForExit(); You...
N 21 Apr 2024 by Pete O'Hanlon
Try setting UseShellExecute to true. This will use the default application to start the process....
U 21 Apr 2024 by Jo_vb.net
After converting WPF MS framework 4.8 project to net 8 the process.start(url) no longer works. private void DG_Hyperlink_Click(object sender, RoutedEventArgs e) { Hyperlink link = (Hyperlink)e.OriginalSource;...
U 15 Apr 2024 by Jo_vb.net
A workaround (not a solution) for improving two of the remaining issues: For private void SelectItemsInRectangle(Rect selectionRect, DataGrid dataGrid, object sender, MouseEventArgs e) you should use the version which was posted here as...
N 11 Apr 2024 by Andre Oosthuizen
From what I could make out of your code is that your 'SelectItemsInRectangle' method is only considering the visible rows in your DataGrid at the time that you make the selection. When you scroll, new rows become visible, and your selection...
U 10 Apr 2024 by Jo_vb.net
I think you have to calculate the rectangle position every time when it should move. Perhaps it is simpler to delete the rectangle which is on wrong position and create a new one on calculated position if needed. ...
U 10 Apr 2024 by Member 16239100
I am attempting to replicate the selection behavior of Windows File Explorer within a WPF DataGrid. Specifically, I aim to implement a selection rectangle that mimics the functionality of File Explorer's selection mechanism. Currently, I have...
3 Apr 2024 by OriginalGriff
To add to what Pete has said, x86 projects build for a 32 bit OS, while AMD64 are built for a 64 bit environment - you can't combine the two in a single executable as the CPU can't be switched between them at run time. So if you want to use a 64...
3 Apr 2024 by Pete O'Hanlon
First thing - try to run the project using Any CPU. See if that fixes it for you. If it doesn't, you will need to create an AMD64 specific configuration. From the menu, select Build > Configuration Manager. Select the Active Solution Platform...
3 Apr 2024 by Member 16235801
I'm encountering the error ".dll targeting 'AMD64' is not compatible with the project's target platform 'x86'" while building my project in visual studio 2019. What I have tried: Switched project target platform to x64 (if applicable). Cleaned...
31 Mar 2024 by Graeme_Grant
AlternationIndex and IsSelected are both properties of a ListViewItem, so a standard Style.Trigger will not work. You need to use a MultiTrigger Class (System.Windows) | Microsoft Learn[^]. Examples are provided with that link, however here is...
31 Mar 2024 by Mike Hankey
I have a ListView control and I'm trying to create a style to; color alternating rows, which works, color the rows when hovering and selecting. The hovering and selecting is the problem, the default behavior does not allow me to change the...
19 Mar 2024 by Graeme_Grant
I am not sure what you are trying to do however I'll show you how to handle each item in the ObservableCollection. The Item class needs to implement the INotifyPropertyChanged Interface (System.ComponentModel)[^]. Microsoft provide a sample: How...
17 Mar 2024 by Pete O'Hanlon
You cannot tell if an object has been changed using an ObservableCollection. The way to do this is to use INotifyPropertyChanged and raise the PropertyChanged event whenever you change the value in a property.
17 Mar 2024 by Sh.H.
Hi folks. I have an Observation Collection. I used event CollectionChanged. But this event only raises when new item added, or an item deleted. So how can I detect if an item edited? (And ofcourse, it would better also to detect which item got...
14 Mar 2024 by Member 11634771
I'm so late, but how about my suggestion? var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri("pen.png", UriKind.RelativeOrAbsolute); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; ...
12 Mar 2024 by hardover
With guidance from others, I have solved the problem. The key was to use the PropertyChangedCallBack to manage when the SelectTags List was bound. In summary, the solution involves capturing the point at which the actual List binding takes...
9 Mar 2024 by Andre Oosthuizen
Another solution will be to use the 'DispatcherTimer' control to sync your titles - C# DispatcherTimer properties[^] Your code will look like the following, adjust the 'SubtitleRecord' class and initialization parts based on your actual data in...
8 Mar 2024 by OriginalGriff
That's complicated, because the user can pause, fast forward, or rewind at any time, and you need to keep the subtitles in sync with the video or it will just get very confusing. Probably your best bet is to use the industry standard .SRT file -...
8 Mar 2024 by Sh.H.
Hi guys Here is a list with 3 fields: StartTime , EndTime , SubtitleText There is almost 1000 numbers in the list. So I have a VideoElement which plays the video, and I made a TextBlock on it to show this list as its subtitle. Could you please...
6 Mar 2024 by Graeme_Grant
List is not a bindable collection. You need to use the ObservableCollection Class (System.Collections.ObjectModel) | Microsoft Learn[^]. Here is a working solution for a similar question. Create a new project and add this code: 1. Classes: ...
6 Mar 2024 by hardover
Binding not working when Custom Control is used in a DataGridTemplateColumn My charge is to provide a control that can be used to select multiple items from a list of items. The items are classification tags. The object is a Tag. It has three...
5 Mar 2024 by Macabies Gilles
An easy-to-use filterable, multilingual custom DataGrid control for managing and filtering data for your WPF applications
5 Mar 2024 by Pete O'Hanlon
Guidance to the correct solutions have been provided by Gerry Schmitz[^] and Richard Deeming[^]. Please don't vote for this answer; I am merely pointing out that the solutions are in the comments on the question. If anything, you should go and...
1 Mar 2024 by gabriel4sonic
Shows how to use OpenGL in a .NET WPF application by directly incorporating an OpenGL window as a child of the main WPF window, making it behave more like a control
25 Feb 2024 by mojtabahakimian
I am developing a C# WPF application using .NET 6 in Visual Studio 2022, with a SQL Server 2008 R2 database. My database contains a table GRADE_CUST_GRP with a column GCPS of type image, where files of various types are stored without any file...
24 Feb 2024 by Member 12692000
Hi I'm trying to generate a pdf with some data (header, paragraph, table, footer etc.) using PDFSharp+Migradoc where the table data is taken from a WPF datagrid. But whenever there are many rows in the table the footer text is overlapping with...
21 Feb 2024 by Jo_vb.net
Part 2 of my article about 'Schafkopf' introduces Automated Bidding
20 Feb 2024 by Member 16206966
The desired RowDetailsTemplate content is available just then the row is expanded. Till this event (see LoadingRowDetails) the content is null and Try to find it with DataGridDetailsPresenter.ContentTemplate leads to an exception:...
19 Feb 2024 by Member 4137856
Bit late, but problem might be the missing comma after the 'DT' in:
18 Feb 2024 by OriginalGriff
There is another way here, but I've not tried it myself: https://stackoverflow.com/questions/5843562/how-can-i-specify-letter-spacing-or-kerning-in-a-wpf-textbox[^]
18 Feb 2024 by clwprogrammer
I am wanting to increase the character spacing of a TextBlock or Label in WPF. This is NOT UWP. What I have tried: I have seen example code stating to use Glyphs. I dont like this method because you have to onow the actual font path, which is...
17 Feb 2024 by Knight school
Hi, I have storyboard with multiple double animations (Not all show in code to make it easier on the eye). I'm setting the duration in the double animation & have read you should also set the storyboard duration to same value to not cut short...
16 Feb 2024 by Peter Sun (247)
Implement ChatGPT API in C# WPF with GPT3.5-turbo
16 Feb 2024 by Jo_vb.net
This article and the demo are about getting started using my Schafkopf_OOP VB.NET project.
16 Feb 2024 by Andre Oosthuizen
Gerry gave the solution, to elaborate on taht - The TextBlock is a read-only control, and that's why you can't edit the content when you double-click on it - MS Learn | TextBlock Class[^] To use editing, you should use an editable control such...
16 Feb 2024 by 4711a
I have a DataGrid with a DataGridTemplateColumn. I'm not able to edit the Comment field. When I double click on a Comment field, the background changes a expected to LightSalmon and the content of the bound property Comment is shown but I cannot...
15 Feb 2024 by vickyqu115
This exploration into the WPF Slider control aims to provide a deep understanding of how WPF designs its controls and their internal mechanisms. While it's nearly impossible to delve into every WPF control's internals due to the vast source code, there's no urgent need to worry or complain.
4 Feb 2024 by Dave Kreskowiak
WCF was deprecated with the release of .NET 5. You'll have to migrate the code to more modern technologies, like CoreWCF[^].
4 Feb 2024 by OmatrixTech
Are there any options available for hosting WCF services in .NET 8.0? I'm migrating my existing application from .NET Framework 4.5.2 to .NET 8.0. Previously, I utilized WCF in the 4.5.2 framework, but I'm currently facing challenges in finding a...
3 Feb 2024 by mojtabahakimian
Project: I had Accounting project made in MS Access ADP 2003 project that connects to SQL Server database , Because it is not possible to create a beautiful and modern user interface with animation in Access, I decided to rewrite my program, I...
3 Feb 2024 by Knight school
Hi, I want replicate the drag & drop from file explorer but from my application which will be lislview item. i.e. Drag listview item (File path) to other application the same as explorer would work. There seems to be a lot of example dragging...
2 Feb 2024 by OriginalGriff
When you drag'n'drop from explorer into an app, the receiver neds to do a couple of things: 1) Handle the DragEnter Event Set the e.Effect to DragDropEffect.Copy, or DragDropEffects.Move 2) Handle the DragDrop Event and fetch the list of files by...
2 Feb 2024 by sahil ajmeri 2022
i want to show the center part of the icVideo box by cropping and show it to bottom part of the icVideo. here middle part of the icVideo will be the diamond's girdle part(the three lines between diamond) as here is example of the project image...
31 Jan 2024 by Levie Rufenacht, Thomas Althammer
Instead of rewriting: Modernize WinForms & WPF solutions with Wisej.NET
17 Jan 2024 by Knight school
Hi, This is difficult one to explain but here goes. I have a list of numbers which are to be set over a set number of column (Pre-determined by another calulation). The task it to move the number around till the shortest column height (Numbers...
16 Jan 2024 by Graeme_Grant
Because it expects a boolean value? Use an IValueConverter for binding conversions. Here is more information: Value conversion with IValueConverter - The complete WPF tutorial[^]
16 Jan 2024 by Sh.H.
Hi guys. I have a String variable which works like a Boolean. The data will be "Male" or "Female". So I Bind RadioButton to it in two way mode. But I don't know it doesn't work! Any Help please? UPDATE: I changed the IsChecked to Visibility. And...
15 Jan 2024 by Graeme_Grant
Further to Jo's answer, yes, the article link he has pointed you to does not give you the exact answer that you want however it does show you how to animate. The same principle applies. You need to take that and write the code or use the answer...
15 Jan 2024 by Sh.H.
I found the answer. I should bind the Text to parent, then bind to the Class.
15 Jan 2024 by Sh.H.
Hi I have a DataGrid. I used TextBox in its cells. I made a ControlTemplate for it. So My problem is when I use controlTemplate, the Binding of TextBox won't work. But if I directly set everything in the DataTemplate, the Binding works perfect....
14 Jan 2024 by Graeme_Grant
Best place to understand a WPF control is to look at the Default Template. For the DataGrid it can be found here: DataGrid Styles and Templates - WPF .NET Framework | Microsoft Learn[^]. What you are pointing to is the Select All button in the...
14 Jan 2024 by Sh.H.
Hi guys Please kindly see the picture Intersection — Freeimage.host[^] As you see there is a white space between RowHeaders and ColumnHeaders in DataGrid. So I need to know how may I change its color? Thanks. What I have tried: I tried to...
14 Jan 2024 by Jo_vb.net
I searched CodeProject articles... Animation using Storyboards in WPF[^] This may help you to write the code for your own needs.
14 Jan 2024 by Sh.H.
Hi people. Follow my previous post in How do I add new row in datagrid in WPF?[^] I need to know how may I use animation when a row adds or inserts into this DataGrid? I mean when I add or insert new row, it opens like curtain... or accordion....
14 Jan 2024 by Sh.H.
Hi. I found a solution. Below code works perfect. However, I think there is better way for this scenario. For example I think there could be a way to use CallBack and Filtering. But I do not have any idea. So please kindly help me to make a...
12 Jan 2024 by Andre Oosthuizen
There is not much information to go on, I will however implement something like my code below. This is in no way a full solution, only a pointer for you in the right direction, you need to modify the code to work for you - Imports...
11 Jan 2024 by Sh.H.
Good evening. I have a DataGrid in WPF. I want, when moue cursor moves to bottom of each row, a plus sign appears at the bottom of that row. So then the user can click on it, and a new row inserted there. Anybody has idea that what is approach...
10 Jan 2024 by vickyqu115
Control featuring design and animations specialized for mobile, but can be elegantly and structurally implemented using ListBox and Animation technologies available in WPF.
8 Jan 2024 by Lawyer Sonia
To build a NuGet with visible user control in the toolbox of the consumer app, make sure your UI project is configured to build a NuGet on the build. In your UI project, include the assembly references and package metadata, as well as the user...
8 Jan 2024 by Pete O'Hanlon
Just spitballing, but something like this should be possible.private HttpClient httpClient; public async Task DownloadImageAndSaveAsync(string sourceFile, string outputFolder, string outputFileName) { try { using Stream fileStream = await...
8 Jan 2024 by OriginalGriff
Here's how I do it: WebClient wc = new WebClient(); outPath = Path.Combine(KnownFolders.Downloads.Path, $"{imageFileName}.{imageFileExtension}"); wc.DownloadFile(imageUrl,...
8 Jan 2024 by Member 10146711
I have created a NuGet package containing a WPF user control in VS 2022 and I just can't figure out how to get the control to appear in the toolbox of the consumer application. I used the Pack command from the drop down menu of the user control...
8 Jan 2024 by Leonard Salamacha 2023
I have been trying to get the image from a url then writing the image to disk with no success. Can anyone help with this? Example URL is: https://static.tvmaze.com/uploads/images/medium_portrait/244/610854.jpg Current code is: try {...
6 Jan 2024 by Jo_vb.net
You can search @GitHub... This project GitHub - Alphabet85/WPFVideoPlayer: A video player created in WPF using MVVM techniques.[^] uses MVVM concept and it uses properties in VideoPlayerViewModel.cs and ICommands like private ICommand...
6 Jan 2024 by Mike-MadBadger
There is no built-in property for determining whether a MediaElement is playing or not. There are events triggered when a MediaElement is opened or ended. You can use the MediaEnded event to check when the media has finished playing. You can...
5 Jan 2024 by Graeme_Grant
You do not need to set the size of the Rectangle if you want to fill the Grid area. Now, if you remove the Width and Height of the Grid, the Grid will fill the parent...
5 Jan 2024 by Graeme_Grant
A quick Google search: WPF MediaElement is playing? - Google Search [^] found this: How to: Control a MediaElement (Play, Pause, Stop, Volume, and Speed) - WPF .NET Framework | Microsoft Learn[^] If you read the sample code you will see this:...
5 Jan 2024 by Graeme_Grant
If it is not working, then you need to point to the property using Path:
5 Jan 2024 by Graeme_Grant
You do not need a Rectangle to set the background color of a cell, you just need to set the Cell Style. Here is a working example:
5 Jan 2024 by Graeme_Grant
Yes, it is possible, but not recommended. Here are some examples: Bind to a method in WPF? - Stack Overflow[^]
4 Jan 2024 by Pete O'Hanlon
There is no in-built way that you can directly bind your ItemsSource to the result of a method. Anything you do is going to involve C# at some point. Theoretically, it might be possible to accomplish something of what you want by writing a custom...
4 Jan 2024 by Sh.H.
I need to make the size of Rectangle automatically takes the needed size of the Grid. Any idea please? What I have tried:
4 Jan 2024 by Sh.H.
Hi guys. I need to know how can I determine my video is now playing, or in Pause state, or in Stop state. In WPF. Any help please? What I have tried: I couldn't find any try! Just I used MediaElement from Toolbox.
2 Jan 2024 by Gerry Schmitz
Your Rectangle has nothing to use for a "size request" ... at a minimum, give the Rectangle a .MinHeight and a .MinWidth in this case (e.g. 24x24 or 32x32). If the Rectangle was "contained", and "stretched", you wouldn't need to specify...
2 Jan 2024 by Gerry Schmitz
Your approach to coloring the rectangle appears to be wrong in the first place (HTML vs XAML). Use a static resource as illustrated here since you need the same color in more than one place anyway. (Otherwise you'd use a Rectangle.Fill "object"...
1 Jan 2024 by Sh.H.
Hello I need to change the color of text in TextBlock equal to color of Rectangle in another part of the Grid. With respect, any kindly Help please? What I have tried:
1 Jan 2024 by Nick Polyak
Describes the new powerful features of UniDock, the new multiplatform UI docking framework.
1 Jan 2024 by Richard MacCutchan
Try it the way shown in this example: DataGridTemplateColumn Class (System.Windows.Controls) | Microsoft Learn[^].
31 Dec 2023 by Sh.H.
I just want to to set background of a cell to Red. I added a rectangle in the cell and change the background to pink. But I don't why my code does not work. Any help please? P.S: Accidentally I changed the Height of rectangle to 10, and I saw...
31 Dec 2023 by George Swan
My WPF is a bit rusty, but I would suggest that you set the window's DataContext to a view model instance and set the DataGrid Items source to a CustomerList property defined in the view model. So the Xaml would look like this:
31 Dec 2023 by Sh.H.
Hi everybody. I copy/paste this example code from DataGrid.ItemsSource Property (System.Windows.Controls) | Microsoft Learn[^]
30 Dec 2023 by Gerry Schmitz
(After looking at your picture ...) Use a "DataGridTemplateColumn" to define a "stack" for the first cell. See the "Publish Date" in the example. DataGridTemplateColumn.CellTemplate Property (System.Windows.Controls) | Microsoft Learn[^]
30 Dec 2023 by Richard MacCutchan
Take a look at WPF: A Beginner's Guide - Part 1 of n[^] by the excellent Sacha Barber.
30 Dec 2023 by Sh.H.
Hi folks. I need a data grid in wpf with 10 cells. But the first 3 columns be in first cell in vertical order. And ofcourse the font size will be less. So what you will see in monitor is a row with 7 columns but the first column have 3 cells...
29 Dec 2023 by Gerry Schmitz
I think what you have is a "multiple" knapsacks problem. (Find a link that works for you if not this one). Solving a Multiple Knapsacks Problem �|� OR-Tools �|� Google for Developers[^]
29 Dec 2023 by M Imran Ansari
Regarding your question about merging cells in a WPF grid, check out the below links, which offers a solution aligned with your requirements. How to merge datacells in WPF DataGridView[^] Wpf – Datagrid, Merge/Combine rows, cells and columns –...
26 Dec 2023 by Christopher Rath
I've been struggling with this problem, off and on, for several months. Today, I decided to ask Bing Chat how to do this. I gave Bing the following direction: write c# code to extend the .net RichTextBox control in a WPF application so that...
25 Dec 2023 by Peter Huber SG
Do you need a 10 minute break or want to do some mental warmup before programming? This free game is for you.