Я использую сетку свойств для отображения свойств объекта моего программного обеспечения. Одним из отображаемых свойств является идентификатор элемента в коллекции. В сетке свойств коллекция отображается в виде выпадающего списка с выбранным элементом.
Сетка свойств XAML:
<xctk:PropertyGrid x:Name="_propertyGrid" Margin="0,2,0,0" AutoGenerateProperties="False" Grid.Row="1" Background="LightGray" ShowTitle="False"
PropertyValueChanged="_propertyGrid_PropertyValueChanged" SelectedObjectChanged="_propertyGrid_SelectedObjectChanged"
ShowSummary="False" ShowDescriptionByTooltip="True" Grid.RowSpan="2" IsManipulationEnabled="True" UseLayoutRounding="True"
SelectedPropertyItemChanged="_propertyGrid_SelectedPropertyItemChanged" >
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="Id" />
<xctk:PropertyDefinition TargetProperties="BGColor" Category=" Colors" DisplayName="Background" DisplayOrder="1"/>
<xctk:PropertyDefinition TargetProperties="FGColor" Category=" Colors" DisplayName="Foreground" DisplayOrder="2" />
<xctk:PropertyDefinition TargetProperties="PosX" Category=" Layout" DisplayOrder="0"/>
<xctk:PropertyDefinition TargetProperties="PosY" Category=" Layout" DisplayOrder="1"/>
<xctk:PropertyDefinition TargetProperties="Width" Category=" Layout" DisplayOrder="2"/>
<xctk:PropertyDefinition TargetProperties="Height" Category=" Layout" DisplayOrder="3"/>
<xctk:PropertyDefinition TargetProperties="Type" DisplayOrder="0"/>
<!--<xctk:PropertyDefinition TargetProperties="SourceTable" DisplayOrder="10" DisplayName="Ext Format" />-->
<xctk:PropertyDefinition TargetProperties="StrSourceTable" DisplayOrder="10" DisplayName="Ext Format" />
<xctk:PropertyDefinition TargetProperties="FontSizes" DisplayOrder="4"/>
<!-- Label Specific Properties -->
<xctk:PropertyDefinition TargetProperties="Text" DisplayOrder="4"/>
<!-- Data Properties -->
<xctk:PropertyDefinition TargetProperties="Data" DisplayOrder="3"/>
<xctk:PropertyDefinition TargetProperties="Data2" DisplayOrder="4" DisplayName="Data Y" />
// THE ID SIMPLE TOUCH PROPERTY HERE :
<xctk:PropertyDefinition TargetProperties="IDActionSimpleTouch" DisplayOrder="3" DisplayName="Simple Touch" />
<xctk:PropertyDefinition TargetProperties="IDActionDoubleTouch" DisplayOrder="4" DisplayName="Double Touch" />
<xctk:PropertyDefinition TargetProperties="IDActionLongTouch" DisplayOrder="5" DisplayName="Long Touch" />
Свойство в объекте с привязкой:
[XmlIgnore]
private UInt16 _IDActionSimpleTouch = 0;
[XmlAttribute]
[ItemsSource(typeof(UserEventItemSource))]
[RefreshProperties(RefreshProperties.All)]
public UInt16 IDActionSimpleTouch
{
get { return _IDActionSimpleTouch; }
set
{
_IDActionSimpleTouch = value;
this.PropertyChangedNotify("IDActionSimpleTouch");
}
}
Определение источника элемента:
class UserEventItemSource : IItemsSource
{
public ItemCollection GetValues()
{
ItemCollection ActionsDatas = new ItemCollection();
if (UserEventInfos.ListeUserEvent.Find(x => x == "OFF") == null) UserEventInfos.ListeUserEvent.Insert((UInt16) 0, "OFF");
foreach (string s in UserEventInfos.ListeUserEvent) if(s != null) ActionsDatas.Add((UInt16)UserEventInfos.ListeUserEvent.IndexOf(s), s);
return ActionsDatas;
}
}
Результат в сетке свойств:
![enter image description here](https://i.stack.imgur.com/vP8SK.png)
Проблема заключается в том, когдаЯ добавляю новый элемент в этот список. Он не отображает новый элемент. Я не знаю, как заставить коллекцию источников обновляться при получении уведомления об изменении свойства.
Спасибо за помощь