我有一个带有 GridView 列的组合框:
...
<GridView AllowsColumnReorder="True" ColumnHeaderToolTip="Info test">
<GridViewColumn Header="Number" Width="120">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Path=extensions}" Width="105" IsEditable="True" HorizontalAlignment="Center" Margin="0,0,0,0" BorderThickness="0">
<ComboBox.Resources>
<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">15</sys:Double>
</ComboBox.Resources>
</ComboBox>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
...
在后面的代码中,“扩展”是ObserverableCollection<string>
100% 被初始化和填充的(这是在类构造函数中):
public partial class MyForm : Window
{
...
public ObservableCollection<string> extensions;
...
public MyForm()
{
...
Initialize();
}
private Initialize()
{
extensions = new ObservableCollection<string>();
extensions.Add("x100");
extensions.Add("x101");
}
}
但是当应用程序在组合框出现时运行时,绑定永远不会发生。需要哪些额外步骤才能完成/正确?