我只是想做的是,当用户点击按钮时,它的内容应该根据编码而改变。这是代码。我已经尝试了两种方式,代码隐藏方式和 XAML 绑定方式。但它不工作。
<Button x:Name="Header" Content="{Binding listHeader}" Click="HeaderClick"/>
private string listHeader;
public string ListHeader
{
get { return listHeader; }
set
{
listHeader = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("listHeader"));
}
}
}
public Calendar()
{
this.selectedDate = DateTime.Now;
this.ListHeader = selectedDate.ToString("MMMM");
}
private void HeaderClick(object sender, RoutedEventArgs e)
{
switch (StateOfList)
{
case StatesOfList.ListOfDates:
{
this.listHeader = selectedDate.Year.ToString();
this.StateOfList = StatesOfList.ListOfMonths;
}
break;
case StatesOfList.ListOfMonths:
{
this.FillList(ListDataTypes.Years);
this.StateOfList = StatesOfList.ListOfYears;
}
break;
case StatesOfList.ListOfYears:
{
}
break;
}
}