你可以试试这个...
MainWindow.Xaml.cs->
int Counter = 0;
private static ObservableCollection<string> _MemberList = new ObservableCollection<string>();
// Suppose it is of String type..I took it as of String type to check my case
public static ObservableCollection<string> MemberList
{
get { return MainWindow._MemberList; }
set { MainWindow._MemberList = value; }
}
MainWindow()
{
InitializeComponent();
MemberList.Add("0");
MemberList.Add("1");
MemberList.Add("2");
Label1.DataContext = this;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
try
{
MemberList.RemoveAt(Counter);
Counter++;
}
catch(Exception ex)
{
string strTemp=ex.Message();
}
}
MainWindow.xaml->
<Grid>
<Label Name="Label1" ContentStringFormat="Members: {0}" Margin="0,56,141,38" RenderTransformOrigin="0.158,1.154" HorizontalAlignment="Right" Width="183">
<Label.Content>
<Binding Path="MemberList.Count" Mode="OneWay" UpdateSourceTrigger="Default"/>
</Label.Content>
</Label>
<Button Click="Button_Click" Width="100" Height="20" Content="click" Margin="43,169,360,122" />
</Grid>