I have question how i can bind datagrid column to collection?
dataGrid1.Columns.Add(new DataGridTemplateColumn { Header="d", Binding = "RoomNumber"});
binding does not exsists what can i use to bind?
it work perfectly but i need to bind it with code behind
<DataGridTextColumn Header="Room Number" Binding="{Binding RoomNumber}"/>
C# is a programming language. WPF is a technology used to develop rich GUI applications using C# (or any other . NET language).
What's New in WPF Version 4.5 | Microsoft Learn. This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
However, some industries still rely on WPF concepts and tools like XAML & MVVM to develop futuristic web, mobile, and desktop applications. None of Microsoft's GUI frameworks ever really die. WPF has top-notch performance, with a high level of customization, and if you aim for Windows, both WPF is critical.
WPF is used to build Windows client applications that run on Windows operating system. WPF uses XAML as its frontend language and C# as its backend languages. WPF was introduced as a part of . NET Framework 3.0 as the Windows library to build Windows client apps and the next generation of Windows Forms.
As far as i understand you want to add data grid column from code behind and that column should work with binding..?
here is sample snippet to add datagrid column from code behind
var col = new DataGridTextColumn();
col.Header = "d";
col.Binding = new Binding("RoomNumber");
dataGrid1.Columns.Add(col);
With this approach you can add as many columns as you want and you can give data binding at run time for each column and you can specify itemssource at once....
make sure to mark AutoGenerateColumns="False" in your data grid so that you can avoid unwanted columns get added from itemssource..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With