在我的C#windows phone手機應用程序中,我創建了一個綁定來將一個字符串列表綁定到ItemsControl
。如何在綁定後向ItemsControl添加更多項目
// MyCollections is a List<string>
<ItemsControl x:Name="ContentRoot" ItemsSource="{Binding MyCollections}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding }" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
它的工作原理。但是我的問題是如何在綁定後添加自己的物品(例如'點擊以添加更多')到ItemsControl
?
添加到MyCollections後面的代碼。 – RadioSpace 2014-10-02 17:48:25
也代替'List'使用'System.Collections.ObjectModel.ObservableCollection ''。它會自動更新控件。 –
RadioSpace
2014-10-02 17:53:59