【发布时间】:2011-11-10 17:42:37
【问题描述】:
我正在尝试将项目添加到具有行为的应用程序栏中。
在 xaml 中它们看起来像:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True"
IsMenuEnabled="True">
<shell:ApplicationBarIconButton x:Name="Save"
IconUri="/resources/icons/appbar.check.rest.png"
Text="Save" />
<shell:ApplicationBarIconButton x:Name="Cancel"
IconUri="/resources/icons/appbar.cancel.rest.png"
Text="Cancel" />
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
<i:Interaction.Behaviors>
<Behaviors:ApplicationBarIconButtonCommand TextKey="Save"
CommandBinding="{Binding SaveEventSetupCommand}" />
<Behaviors:ApplicationBarIconButtonCommand TextKey="Cancel"
CommandBinding="{Binding CancelEventSetupCommand}" />
</i:Interaction.Behaviors>
对于多语言支持,我需要添加如下内容:
Text="{Binding Path=Localizedresources.lblCourse, Source={StaticResource LocalizedStrings}}"
到每个按钮。看来这不能在 xaml 中完成,因此使用代码。
在这段代码中添加了按钮:
ApplicationBarIconButton appBarSaveButton = new ApplicationBarIconButton(
new Uri("/resources/icons/appbar.check.rest.png", UriKind.Relative))
{ Text = "Test" };
ApplicationBar.Buttons.Add(appBarSaveButton);
我只是不知道如何添加行为。这是我的起点:
WP7Contrib.View.Controls.Behaviors.ApplicationBarIconButtonCommand
ibc = new WP7Contrib.View.Controls.Behaviors.ApplicationBarIconButtonCommand
{ TextKey = "Test" };
如果有人愿意的话,基本上我正在寻找一个工作样本。
谢谢
【问题讨论】:
-
什么样的行为?我担心它无法完成,因为 ApplicationBar 不是 Silverlight 控件。
标签: windows-phone-7 behavior application-bar