I have a DataGrid, one of the columns is a DataGridComboBoxColumn:
<DataGrid AutoGenerateColumns="False" CanUserAddRows="True">
<DataGrid.Columns>
<DataGridTextColumn Header="User Name" Width="Auto" Binding="{Binding UName}"/>
<DataGridComboBoxColumn Header="Country" Width="Auto" ????/>
</DataGrid.Columns>
</DataGrid>
I have a Country class:
public class Country{
public string name {get; set;}
public string des {get; set;}
public Country() {}
public Country(string n, string d) {
this.name = n;
this.des = d;
}
}
they have a name and a description, I want the names(of multiple Country objects) to populate the combo-box(and the des the tooltip of each combo-box option), how do I do that?
Note: later I would like to give the user the ability to add a new Country, so I would like the combo-box to change as well(to include the new Country), meaning the solution needs to allow that.
Note2: I am not using the MVVM pattern. edit: meaning it is not a duplicate.
Solution:
1. XAML:
<DataGrid x:Name="DataGrid" AutoGenerateColumns="False" CanUserAddRows="True">
<DataGrid.Columns>
<DataGridTextColumn Header="User UName" Width="Auto" Binding="{Binding UName}"/>
<DataGridComboBoxColumn x:Name="ComboBoxColumn" Header="Country" Width="Auto" DisplayMemberPath="name" SelectedItemBinding="{Binding CountryData}"/>
</DataGrid.Columns>
</DataGrid>
2. Code behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
InitData();
ComboBoxColumn.ItemsSource = CountriesCollection;
DataGrid.ItemsSource = UsersCollection;
}
private void InitData()
{
UsersCollection = new ObservableCollection<UserData>(new List<UserData>
{
new UserData
{
UName = "Greg",
},
new UserData
{
UName = "Joe",
},
new UserData
{
UName = "Iv",
}
});
CountriesCollection = new ObservableCollection<Country>(new List<Country>
{
new Country("Ger", "1500"),
new Country("Fra", "1500"),
new Country("Ru", "1500"),
new Country("Bel", "1500"),
});
}
public ObservableCollection<Country> CountriesCollection { get; set; }
public ObservableCollection<UserData> UsersCollection { get; set; }
}
3. User model:
public class UserData
{
public string UName { get; set; }
public object CountryData { get; set; }
}
4. tool tip support: replace a desired combo box column with next xaml code:
<DataGridComboBoxColumn x:Name="ComboBoxColumn" Header="Country" DisplayMemberPath="CountryName"
ItemsSource="{StaticResource CountriesArray}" Width="Auto"
SelectedItemBinding="{Binding CountryData, UpdateSourceTrigger=PropertyChanged}">
<DataGridComboBoxColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="ToolTip">
<Setter.Value>
<ContentControl Content="{Binding }">
<ContentControl.ContentTemplate>
<DataTemplate DataType="{x:Type soDataGridProjectsHelpAttempt:UserData}">
<DataTemplate.Resources>
<system:String x:Key="NoAnyEntriesKey">
No any entry presented
</system:String>
</DataTemplate.Resources>
<TextBlock Text="{Binding CountryData.Description, FallbackValue={StaticResource NoAnyEntriesKey}}"></TextBlock>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
</Setter.Value>
</Setter>
</Style>
</DataGridComboBoxColumn.CellStyle>
</DataGridComboBoxColumn>
and take in account you nedd to extend Country model with description property.
regards,
Related
I created a small sample-application in WPF to demonstrate my current issue:
In my application I have two DataGrids.
The first DataGrid is bound to an ObservableCollection of my own
Person-Objects and it just shows one property of every Person-Object.
In the second DataGrid I want to show all Person-Details based on the
selected item in my first DataGrid.
Unfortunately my second DataGrid does not upate resp. show anything when I select an item in the first DataGrid and although I googled and read a lot of stuff, I'm not able to solve it myself.
So this is what I got in my DGUpdate-Application:
The MainWindow with both DataGrids, the DataContext etc.:
<Window x:Class="DGUpdate.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DGUpdate"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:MainWindow_ViewModel/>
</Window.DataContext>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<DataGrid
Grid.Column="0"
ItemsSource="{Binding MyObeservableCollectionOfPerson}"
SelectedItem="{Binding Path=SelectedPerson, Mode=TwoWay}"
AutoGenerateColumns="False"
IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Last name" Width="Auto" Binding="{Binding LastName}"/>
</DataGrid.Columns>
</DataGrid>
<DataGrid
Grid.Column="1"
ItemsSource="{Binding SelectedPerson}"
AutoGenerateColumns="False"
IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Last name" Width="Auto" Binding="{Binding SelectedPerson.LastName}"/>
<DataGridTextColumn Header="First name" Width="Auto" Binding="{Binding SelectedPerson.FirstName}"/>
<DataGridTextColumn Header="Age" Width="Auto" Binding="{Binding SelectedPerson.Age}"/>
<DataGridTextColumn Header="Weight" Width="Auto" Binding="{Binding SelectedPerson.Weight}"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
My ViewModel that also implements INotifyPropertyChanged and where I create two demo-Persons in the Constructor:
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.CompilerServices;
namespace DGUpdate
{
public class MainWindow_ViewModel : INotifyPropertyChanged
{
#region Properties
public ObservableCollection<Person_Model> MyObeservableCollectionOfPerson { get; set; }
public Person_Model SelectedPerson { get; set; }
#endregion
#region Constructor
public MainWindow_ViewModel()
{
MyObeservableCollectionOfPerson = new ObservableCollection<Person_Model>();
MyObeservableCollectionOfPerson.Add(
new Person_Model()
{
LastName = "Doe",
FirstName = "John",
Age = 32,
Weight = 90.3
});
MyObeservableCollectionOfPerson.Add(
new Person_Model()
{
LastName = "Miller",
FirstName = "Peter",
Age = 41,
Weight = 75.7
});
}
#endregion
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}
My own Person-Class with the four Properties that I want to be displayed in the second DataGrid based on the Person I selected in my first DataGrid:
namespace DGUpdate
{
public class Person_Model
{
public string LastName { get; set; }
public string FirstName { get; set; }
public int Age { get; set; }
public double Weight { get; set; }
}
}
As you can see, in my ViewModel-Class, I created a Person-Object 'SelectedPerson' that is bound to the SelectedItem of my first DataGrid and that I use as the ItemSource of my second DataGrid.
I also played around a bit with manually calling the NotifyPropertyChanged, but this unfortunately also did not work and thus I removed it from this Sample-Application.
Can someone give me advice on how to solve the above described issue?
You must call NotifyPropertyChanged() in your property like this :
private Person_Model selectedPerson;
public Person_Model SelectedPerson {
get
{
return this.selectedPerson;
}
set
{
if (value != this.selectedPerson)
{
this.selectedPerson = value;
NotifyPropertyChanged();
}
}
}
More details on the doc:
https://learn.microsoft.com/fr-fr/dotnet/framework/winforms/how-to-implement-the-inotifypropertychanged-interface
i want to fill a datagrid with the columns "Datum" (DateTime), "Aktion" (String), "Wer" (string),"BisWann" (DateTime), "Status" (int). The "Status" column should be a dropdown list, which contains four icons and dependent on the int value, there should be the correct image preselected.
how can i archive this? So far, i have the datagrid filled with every value, except the dropdownlist (in the following code just a sample entry w/o database)
Window.xaml:
<DataGrid Name="dgMassnahmen" AutoGenerateColumns="False" Margin="10,10,10,10" Grid.Row="1">
<DataGrid.Columns>
<DataGridTextColumn Header="Datum" Binding="{Binding Datum, StringFormat=\{0:dd.MM.yy\}}"/>
<DataGridTextColumn Header="Aktion" Binding="{Binding Aktion}"/>
<DataGridTextColumn Header="Wer" Binding="{Binding Wer}"/>
<DataGridTemplateColumn Header="BisWann">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<DatePicker SelectedDate="{Binding BisWann}" BorderThickness="0" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridComboBoxColumn Header="Status" SelectedValueBinding="{Binding Status}"/>
</DataGrid.Columns>
</DataGrid>
the Itemclass:
public class Massnahmen
{
public DateTime Datum { get; set; }
public string Aktion { get; set; }
public string Wer { get; set; }
public DateTime BisWann { get; set; }
public int Status { get; set; }
}
in Window.xaml.cs:
private void FillMassnahmen()
{
List<Klassen.Massnahmen> massnahmen = new List<Klassen.Massnahmen>();
massnahmen.Add(new Klassen.Massnahmen() { Datum = DateTime.Now, Aktion = "DoSomething", BisWann = DateTime.Now.AddDays(2), Status = 2, Wer = "OfCourseYOU" });
dgMassnahmen.ItemsSource = massnahmen;
}
You could set the ItemsSource to an array of Image elements and set the Tag property of each element to an int value that you bind to the Status property:
<DataGridComboBoxColumn Header="Status"
SelectedValueBinding="{Binding Status}"
SelectedValuePath="Tag"
xmlns:s="clr-namespace:System;assembly=mscorlib">
<DataGridComboBoxColumn.ItemsSource>
<x:Array Type="{x:Type Image}">
<Image Source="1.png">
<Image.Tag>
<s:Int32>1</s:Int32>
</Image.Tag>
</Image>
<Image Source="2.png">
<Image.Tag>
<s:Int32>2</s:Int32>
</Image.Tag>
</Image>
</x:Array>
</DataGridComboBoxColumn.ItemsSource>
</DataGridComboBoxColumn>
I'm learning XAML with WPF and i'm trying to display some data in a grid, but i can't for the life of me get it to show. the fields appear, but they're empty without text. here's the XAML
<Window x:Class="MoodWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MoodWPF"
mc:Ignorable="d"
Height="810.573"
Width="1026.432"
MinWidth="600">
<Grid x:Name="mainGrid" Background="#333333">
<DataGrid Width="400" Height="400" x:Name="trackList" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#FF404040" BorderBrush="{x:Null}" ColumnHeaderHeight="22" GridLinesVisibility="Vertical" RowBackground="#FF404040" AlternatingRowBackground="#FF333333" RowHeight="20" SelectionMode="Single">
<DataGrid.Columns>
<DataGridTemplateColumn x:Name="Track" Header="Track" Width="100" IsReadOnly="True">
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Artist" Width="100" IsReadOnly="True">
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Album" Width="100" IsReadOnly="True">
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Time" Width="100" IsReadOnly="True">
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
and the C# with which im trying to insert some random data
namespace MoodWPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
// create and add three lines of fake data to be displayed, here
trackList.Items.Add(new DataItem { Track = "a.1", Artist = "a.2", Album = "a.3", Time = "a.4" });
trackList.Items.Add(new DataItem { Track = "a.1", Artist = "a.2", Album = "a.3", Time = "a.4" });
trackList.Items.Add(new DataItem { Track = "a.1", Artist = "a.2", Album = "a.3", Time = "a.4" });
/*
Collection<DataItem> users = new Collection<DataItem>();
users.Add(new DataItem { Track = "firstname-1", Artist = "lastname-1" });
users.Add(new DataItem { Track = "firstname-2", Artist = "lastname-2" });
users.Add(new DataItem { Track = "firstname-3", Artist = "lastname-3" });
users.Add(new DataItem { Track = "firstname-4", Artist = "lastname-4" });
trackList.ItemsSource = users;
}
}
public class DataItem
{
public string Track { get; set; }
public string Artist { get; set; }
public string Album { get; set; }
public string Time { get; set; }
}
}
what am i doing wrong/not doing? keep in mind i'm a beginner with WPF and Xaml
There are few issues,
(i) You need to have a collection to bind to DataGrid, hence add the items to a List or ObservableCollection
Code Behind:
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<DataItem> data = new List<DataItem>();
data.Add(new DataItem { Track = "a.1", Artist = "a.2", Album = "a.3", Time = "a.4" });
data.Add(new DataItem { Track = "a.1", Artist = "a.2", Album = "a.3", Time = "a.4" });
data.Add(new DataItem { Track = "a.1", Artist = "a.2", Album = "a.3", Time = "a.4" });
trackList.ItemsSource = data;
}
}
public class DataItem
{
public string Track { get; set; }
public string Artist { get; set; }
public string Album { get; set; }
public string Time { get; set; }
}
(ii)Set DataGrid AutoGenerateColumns="True"
If you set AutoGenerateColums= false,
XAML:
<DataGrid Width="400" Height="400" x:Name="trackList" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#FF404040" BorderBrush="{x:Null}" ColumnHeaderHeight="22" GridLinesVisibility="Vertical" RowBackground="#FF404040" AlternatingRowBackground="#FF333333" RowHeight="20" SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Track}" x:Name="Track" Header="Track" Width="100" IsReadOnly="True">
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Artist}" Header="Artist" Width="100" IsReadOnly="True">
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Album}" Header="Album" Width="100" IsReadOnly="True">
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding Time}" Header="Time" Width="100" IsReadOnly="True">
</DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
When you need only text try:
<DataGrid.Columns>
<DataGridTextColumn x:Name="Track" Width="100" Binding="{Binding Track}" Header="Track"/>
...
or you need specific template:
<DataGridTemplateColumn Header="Artist" Width="100" IsReadOnly="True">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Artist}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
You must to bind your model (probably a List of specific object) to the DataGrid, and its attributes to its repective columns.
Kind of:
<DataGrid x:Name="TrackList" DataContext="{Binding Source=TrackList}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Track" Binding="{Binding Track}"/>
<DataGridTextColumn Header="Artist" Binding="{Binding Artist}"/>
...........
...........
</DataGrid.Columns>
</DataGrid>
I have a list that will not always have the same number of objects in it, could be 1, 10, 15, etc. Right now I am just guessing and placing that guessed amount of GridviewItems in my XAML. I want to dynamically build the GridviewItems based on the amount of objects in my list. I have have this in a loop of course, I am just unsure of how to do this in c#. I will show you the XAML I have right now that is not dynamically creating the GridviewItems.
<Grid Background="LightGray">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<controls:PageHeader BackButtonVisibility="Collapsed" Content="News" Frame="{x:Bind Frame}">
<Interactivity:Interaction.Behaviors>
<Behaviors:EllipsisBehavior Visibility="Auto" />
</Interactivity:Interaction.Behaviors>
<controls:PageHeader.SecondaryCommands>
<AppBarButton Click="{x:Bind ViewModel.GotoPrivacy}" Label="Privacy" />
<AppBarButton Click="{x:Bind ViewModel.GotoAbout}" Label="About" />
</controls:PageHeader.SecondaryCommands>
</controls:PageHeader>
<GridView Margin="12,60" ItemsSource="{Binding myList}">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Vertical" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemContainerStyle>
<Style TargetType="GridViewItem">
<Style.Setters>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Grid Background="#2A2A2A" Margin="5" Height="200" Width="300">
<ContentPresenter />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</GridView.ItemContainerStyle>
</GridView>
</Grid>
Web Service
[OperationContract]
List<ViewDetails> ViewDetails();
[DataContract]
public class ViewDetails
{
public string TitleView { get; set; }
public string BodyView { get; set; }
public string AuthorView { get; set; }
public ViewDetails() { }
public ViewDetails(string myTitleView, string myBodyView, string myAuthorView)
{
this.TitleView = myTitleView;
this.BodyView = myBodyView;
this.AuthorView = myAuthorView;
}
}
public List<ViewDetails> ViewDetails()
{
List<ViewDetails> details = new List<ViewDetails>();
SqlConnection conn = new SqlConnection(strConnString);
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT TOP 2 [My_Title] AS 'Title', [My_Body] AS 'Body', [My_Author] AS 'Author' FROM [My_table] ORDER BY [Date] DESC", conn);
SqlDataReader rdrDetails = cmd.ExecuteReader();
try
{
while (rdrDetails.Read())
{
details.Add(new ViewDetails(rdrDetails.GetSqlString(rdrDetails.GetOrdinal("Title")).ToString(), rdrDetails.GetSqlString(rdrDetails.GetOrdinal("Body")).ToString(), rdrDetails.GetSqlString(rdrDetails.GetOrdinal("Author")).ToString()));
}
}
catch (Exception e)
{
//exception
}
finally
{
conn.Close();
}
return details;
}
Project where I am calling web service
public async void ViewData()
{
ServiceReference1.Service1Client client = new ServiceReference1.Service1Client();
string title = string.Empty;
string body = string.Empty;
string author = string.Empty;
var res = await client.ViewDetailsAsync();
for (int i = 0; i < res.Count; i++)
{
myList.Add(new GetDetails(res[i].TitleView, res[i].BodyView, res[i].AuthorView));
}
}
public class GetDetails
{
public string TitleView { get; set; }
public string BodyView { get; set; }
public string AuthorView { get; set; }
public GetDetails() { }
public GetDetails(string titleView, string bodyView, string authorView)
{
this.TitleView = titleView;
this.BodyView = bodyView;
this.AuthorView = authorView;
}
}
What I am looking for is some way to programatically build the GridViewItems... Any suggestions?
Just bind ItemsSource
<GridView Margin="12,60" ItemsSource={Binding ItemsList}>
...
</GridView>
EDIT:
1) You can use DataGrid like this
<DataGrid ItemsSource="{Binding TestDataCollection}">
<DataGrid.Columns>
<DataGridTextColumn Header="Title" Binding="{Binding TitleView}"/>
<DataGridTextColumn Header="Body" Binding="{Binding BodyView}"/>
<DataGridTextColumn Header="Author" Binding="{Binding AuthorView}"/>
</DataGrid.Columns>
</DataGrid>
2) Or ListView
<ListView ItemsSource="{Binding TestDataCollection}">
<ListView.View>
<GridView>
<GridViewColumn Header="Author" DisplayMemberBinding="{Binding Path=AuthorView}"/>
<GridViewColumn Header="Title" DisplayMemberBinding="{Binding Path=TitleView}"/>
</GridView>
</ListView.View>
</ListView>
3) Or ListBox
<ListBox ItemsSource="{Binding TestDataCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding AuthorView}"/>
<TextBlock Text="{Binding TitleView}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I have a DataGrid to insert data into Sql Server table. Inside of DataGrid I have ComboBox to pick the data from a codebook (this is the table from the same database) and insert this data into table I bound to DataGrid. This is the XAML:
<DataGrid Name="dgrStavke" AutoGenerateColumns="False" Height="160" Width="600" HorizontalAlignment="Left" Margin="5" Grid.Row="7" Grid.ColumnSpan="4">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Artikl ID">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox Name="cmbArticle" Width="120" ></ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Article Name" Width="150"></DataGridTextColumn>
<DataGridTemplateColumn Header="Usluga ID">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox Name="cmbService" Width="120"></ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn Header="Service Name" Width="150"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
When I choose article id in combobox article, the very next DataGridTextColumn should display name of this article. The same is for service. It's possible to insert few articles and services and that's the reason I use Datagrid.
How can I do this?
Thanks.
I guess the below sample would help you to achieve your goal
In XAML below code used,
<Window.Resources>
<ObjectDataProvider x:Key="RecordValues" ObjectType="{x:Type local:RecordTemp}" MethodName="GetPersonList" >
</ObjectDataProvider>
</Window.Resources>
<Grid>
<Grid>
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding}"
Margin="10,10,73,155" Name="dataGrid1">
<DataGrid.Columns>
<DataGridComboBoxColumn Header="Artikl ID" Width="300"
SelectedValueBinding="{Binding SelectedPart, UpdateSourceTrigger=PropertyChanged}"
DisplayMemberPath="ArticleID"
ItemsSource="{Binding Source={StaticResource RecordValues}}" />
<DataGridTextColumn Header="Order Name" Binding="{Binding SelectedPart.ArticleName}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Grid>
In C# below code used,
public class RecordTemp : INotifyPropertyChanged
{
List<PartsList> _value = new List<PartsList>();
public RecordTemp()
{
_value.Add(new PartsList() { ArticleID = "1", ArticleName = "one - 1", ArticleQuantity = 20 });
_value.Add(new PartsList() { ArticleID = "2", ArticleName = "Two - 2", ArticleQuantity = 10 });
}
public List<PartsList> GetPersonList()
{
return _value;
}
private PartsList _SelectedPart;
public PartsList SelectedPart
{
get { return _SelectedPart; }
set
{
_SelectedPart = value;
OnPropertyChanged("SelectedPart");
}
}
public void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null )
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
public class PartsList
{
public string ArticleID { get; set; }
public double ArticleQuantity { get; set; }
public string ArticleName { get; set; }
}
In the MainWindow the below code could helps to binding the grid.
ObservableCollection<RecordTemp> RecordsTemp = new ObservableCollection<RecordTemp>();
RecordsTemp.Add(new RecordTemp());
RecordsTemp.Add(new RecordTemp());
dataGrid1.DataContext = RecordsTemp;
Please Comment If you have any clarification needed. I'll help you
((ComboBox)GRID.Columns[N].FindControl("cmbArticle")).COMBO-BOX-PROPERTY
Is this correct syntax? I don't know, I think you are looking for something like that.