I am new in wpf.
I have a datagrid
, on application startup it have blank row where the user will enter data.
In my datagrid
there is Product_Name
column. I want when the user type any product name in this column an auto complete list open under this column and match string from Database Product
Table. How can I do that ?
If it is not possible in DataGridTextColumn
then how can i fill my DataGridComboBoxColumn
with this Database Column in Product Table and this datagrid Combobox can search string. User can type in datagrid combobox the name of Product and if string match under this datagrid Combobox then matching string(Product Name) should bring up in combobox list.
I am searching since two days but no luck kindly guide me in detail not have command new in wpf and c#. Thanks.
xaml:
<DataGrid x:Name="dg_List_Of_PurchasedItem" Margin="5" AutoGenerateColumns="False" ItemsSource="{Binding Purch_Order}" AlternatingRowBackground="LightGray" >
<DataGrid.Columns>
<DataGridTextColumn Header="Sr#" Width="35" Binding="{Binding Sr}"></DataGridTextColumn>
<DataGridCheckBoxColumn Header="Select" Width="45" Binding="{Binding Select}"></DataGridCheckBoxColumn>
<DataGridComboBoxColumn Header="Product" x:Name="cb_ProdName" Width="150" SelectedValueBinding="{Binding Product_Name}"></DataGridComboBoxColumn>
<DataGridTextColumn Header="Description" Width="170" Binding="{Binding Description}" ></DataGridTextColumn>
<DataGridTextColumn Header="Type" Width="80" Binding="{Binding Type}" ></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
Code-behind:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class add_Purchase_Order_Win : Window
{
public add_Purchase_Order_Win()
{
InitializeComponent();
DataContext = new PO_ViewModel();
}
}
public class PO_ViewModel
{
private ObservableCollection<Purch_Order> _Purch_Order = new ObservableCollection<Purch_Order>();
public ObservableCollection<Purch_Order> Purch_Order
{
get { return _Purch_Order; }
set { _Purch_Order = value; }
}
}
public class Purch_Order
{
public Purch_Order() { }
public int Sr { get; set; }
public bool Select { get; set; }
public string Product_Name { get; set; }
public string Description { get; set; }
public string Type { get; set; }
}
}