TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
M M
NA
1
0
ComboBox in DataGrid binding
Dec 2 2011 4:25 PM
Hi, I have datagrid and I bound some data to each row (ObservableCollection<Contact>) Name, Surname, Group, Address are in Contact object as property. For group column I want to add comboBox, where is some Group Collection
namespace BusinessLayer.Structure
{
public class GroupList : ObservableCollection<Group>
{
public GroupList()
{
Manager.PrepareData _groups = new Manager.PrepareData(); // get ObservableCollection<Group>
foreach(Group group in _groups.LoadGroups())
{
this.Add(group);
}
}
}
}
namespace BusinessLayer.Structure
{
public class Group
{
public Guid ID_Group { get; set; }
public string Name_Group { get; set; }
}
}
namespace BusinessLayer.Structure
{
public class Contact
{
public Guid Id { get; set; };
public string Name { get; set; };
public string Surname { get; set; };
public string Group { get; set; };
public string Address { get; set; };
}
}
How can I bind data in DataGrid in XAML? DataGrid is in PresentationLayer namespace.
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox x:Name="group_combobox" SelectedValuePath="Name_Group"
SelectedValue="{Binding Group}"
DisplayMemberPath="Name"
ItemsSource="{Binding Path=DataContext.GroupList,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
IsReadOnly="True" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
I tried a lot of ideas but no solution. Could someone help me, please? Thanks
Reply
Answers (
0
)
Telerik Reporting
Datagrid