我有一个下一个控件 - 日历。我从 nuget WPControls 得到的。我修改了它,因为我需要一个按钮 - 今天。
这是一个 XAML 代码:
<ControlTemplate x:Key="CalendarControlTemplate1" TargetType="wpControls:Calendar">
<ScrollViewer>
<Grid Height="auto" Background="Black">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{TemplateBinding YearMonthLabel}" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button
Content="<"
Width="100"
Grid.Column="0"
x:Name="PreviousMonthButton"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Visibility="{Binding ShowNavigationButtons, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}"/>
<Button
Content=">"
Width="100"
Grid.Column="2"
x:Name="NextMonthButton"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Visibility="{Binding ShowNavigationButtons, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource TemplatedParent}}"/>
<Button Grid.Row="3" Grid.Column="1" x:Name="TodayButton" Content="{Binding Path=ButtonName}" HorizontalAlignment="Stretch" Height="100" VerticalAlignment="Bottom" Tap="Button_Tap" />
<Grid Height="auto" Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3" x:Name="ItemsGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Text="{TemplateBinding Sunday}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1"/>
<TextBlock Text="{TemplateBinding Monday}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2"/>
<TextBlock Text="{TemplateBinding Tuesday}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="3"/>
<TextBlock Text="{TemplateBinding Wednesday}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="4"/>
<TextBlock Text="{TemplateBinding Thursday}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="5"/>
<TextBlock Text="{TemplateBinding Friday}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="6"/>
<TextBlock Text="{TemplateBinding Saturday}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="7"/>
</Grid>
</Grid>
</ScrollViewer>
</ControlTemplate>
我已经添加了这个东西:
<Button Grid.Row="3" Grid.Column="1" x:Name="TodayButton" Content="{Binding Path=ButtonName}" HorizontalAlignment="Stretch" Height="100" VerticalAlignment="Bottom" Tap="Button_Tap" />
我希望它改变它的内容,例如当我切换语言时的文本,所以我完成了这个绑定:
Content="{Binding Path=ButtonName}"
但它不起作用,为什么?以及如何解决?
这是我的 C# 代码:
string ButtonName;
public CalendarPage()
{
InitializeComponent();
ButtonName = GS.translations["Today"];
}