且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WPF DataGridComboBoxColumn

更新时间:2022-02-15 08:35:52

im可以肯定这是因为当你不处于编辑模式您的列没有项目源,并且ComboBox不能有没有项目源的选定项目。一旦你去编辑模式你的列获得其项目源,一切都很酷。你可以通过指定一个项目来源来解决这个问题: -

im pretty sure that this is because when you are not in edit mode your Column does not have an items source and a ComboBox cant have a selected item without an items source. as soon as you go to edit mode your column gets its items source and everything is cool. you can fix this by specifying an items source like so :-

<tk:DataGridComboBoxColumn.ElementStyle>
    <Style TargetType="ComboBox">
        <Setter Property="ItemsSource" Value="{Binding Path=GroupLevel.Group.GroupLevels}" />
    </Style>
</tk:DataGridComboBoxColumn.ElementStyle>

那么你的编辑元素和你的(非编辑)元素都有相同的ItemsSource

then both your editing element and your (non-editing)element has the same ItemsSource