2 回答
TA贡献1779条经验 获得超6个赞
CompositeCollection正是您所需要的。这是小XAML样本:
<Window ...>
<!-- You should define your ItemsSource in resources-->
<Window.Resources>
<CollectionViewSource x:Key="Names" Source="{Binding Names}" />
</Window.Resources>
<Grid>
<ListBox>
<ListBox.ItemsSource>
<CompositeCollection>
<CollectionContainer Collection="{Binding Source={StaticResource Names}}" />
<ListBoxItem Foreground="Red">Add new...</ListBoxItem>
</CompositeCollection>
</ListBox.ItemsSource>
<!-- Here you can customize everything you want -->
</ListBox>
</Grid>
</Window>
TA贡献1863条经验 获得超2个赞
像这样使用,
var myButton = new Button()
{
Height = 25,
Width = 80
Content = "+",
Background = Brushes.Gray
}
UniformGrid.Children.Add(myButton);
- 2 回答
- 0 关注
- 175 浏览
添加回答
举报