gpt4 book ai didi

c# - ApplicationBar 绑定(bind) Windows Phone

转载 作者:太空宇宙 更新时间:2023-11-03 19:13:01 27 4
gpt4 key购买 nike

无法绑定(bind) ApplicationBar,我试过了:

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton
x:Name="btnTest"
IconUri="/Assets/AppBar/appbar.add.rest.png"
Text="{Binding MyBtnText}" />
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
btnTest.Text = AppResources.Reset;
}

最佳答案

private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
ApplicationBarIconButton btn= ApplicationBar.Buttons[0] as ApplicationBarIconButton;
if (btn!= null)
{
btn.Text = AppResources.Test;
}

}

来源:http://www.diaryofaninja.com/blog/2011/07/05/solved-why-donrsquot-applicationbar-bindings-work-ndash-windows-phone-7-sdk

或从 C# 后面的代码构建 ApplicationBar

// Build a localized ApplicationBar
private void BuildLocalizedApplicationBar()
{
// Set the page's ApplicationBar to a new instance of ApplicationBar.
ApplicationBar = new ApplicationBar();

// Create a new button and set the text value to the localized string from AppResources.
ApplicationBarIconButton appBarButton =
new ApplicationBarIconButton(new
Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
appBarButton.Text = AppResources.Reset;
ApplicationBar.Buttons.Add(appBarButton);

// Create a new menu item with the localized string from AppResources.
ApplicationBarMenuItem appBarMenuItem =
new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
ApplicationBar.MenuItems.Add(appBarMenuItem);
}

来源:

How to build a localized app for Windows Phone

Tips for Localizing Windows Phone 8 XAML Apps - Part1

关于c# - ApplicationBar 绑定(bind) Windows Phone,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19203066/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com