-
Notifications
You must be signed in to change notification settings - Fork 901
Open
Description
I bind PropertyGrid(in ListBox ItemTemplate) PropertyDefinitions to a PropertyDefinitionCollection in my viewmodel, but I find the binding does not work, the PropertyDefinitionCollection of all PropertyGrid is empty, and all PropertyGrid are empty. Here is my code:
<ListBox ItemsSource="{Binding ManufacturerList}">
<ListBox.ItemTemplate>
<DataTemplate>
<xctk:PropertyGrid
SelectedObject="{Binding }"
AutoGenerateProperties="False"
PropertyDefinitions="{Binding DataContext.PropertyDefinitionCollection, ElementName=window}">
</xctk:PropertyGrid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
public class Company
{
public string Task { get; set; }
public string HeadNote { get; set; }
}
public class ViewModel
{
public PropertyDefinitionCollection PropertyDefinitionCollection { get; set; } =
new PropertyDefinitionCollection()
{
new PropertyDefinition()
{
TargetProperties = new[] { "Task" }
},
new PropertyDefinition()
{
TargetProperties = new[] { "HeadNote" }
}
};
public List<Company> ManufacturerList { get; set; }
public ViewModel()
{
List<Company> list = new List<Company>();
list.Add(new Company()
{
Task = "Coding",
HeadNote = "Coding Task",
});
list.Add(new Company()
{
Task = "Communicate",
HeadNote = "Communicate Task",
});
ManufacturerList = list;
}
}
Metadata
Metadata
Assignees
Labels
No labels