Windows Phone 8 global application bar localization - windows-phone-7

I am trying to create a localized windows phone 8 app , and I am creating a global application bar . However I am unable to set the text of the items inside the bar using the resource , anyone have an idea how to do that ? I am also unable to get it in code .

you can reuse the commented code in the template's MainPage.xaml.cs:
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));
//Search in AppResources.Search is a key of a string in the resource files (.resx)
appBarButton.Text = AppResources.Search;
ApplicationBar.Buttons.Add(appBarButton);
// Create a new menu item with the localized string from AppResources.
//Search in AppResources.Search is a key of a string in the resource files (.resx)
ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.Search);
ApplicationBar.MenuItems.Add(appBarMenuItem);
}
unfortunately the app bar is not a traditional Silverlight control so you have to create programmatically in every page if you want it localized.

Related

How to add icon to Action Sheet Popup on Xamarin forms?

I'm using Action Sheet Popup of the library Rg.Plugins.Popup on Xamarin Forms.
I want to display the image as below:
How to add an icon to Action Sheet Popup on Xamarin forms?
This is my code:
public Task<string> ShowActionSheetDialogAsync(string title, string cancelString = null, string destructive = null, CancellationToken? token = null, string[] arrayButtons = null)
{
return UserDialogs.Instance.ActionSheetAsync(title, cancelString,destructive, cancelToken: token,buttons:arrayButtons);
}
Or you can suggest another idea which might also show.
Please help me!
Use aritchie/userdialogs instead, it provides icon option for the item in list , check API .
Usage
IUserDialogs d = UserDialogs.Instance;
ActionSheetConfig config = new ActionSheetConfig();
List<ActionSheetOption> Options = new List<ActionSheetOption>();
Options.Add(new ActionSheetOption("1" , null , "info.png"));
Options.Add(new ActionSheetOption("2", null, "info.png"));
ActionSheetOption cancel = new ActionSheetOption("Cancel",null,null);
config.Options = Options;
config.Cancel = cancel;
d.ActionSheet(config);
Screen shot
This is platform-specific, so wrap it in DependencyService for example.
This is how you add image to an ActionSheet action:
UIImage img; //the image
var action = new UIAlertAction();
action.SetValueForKey("image", img);
Then add this UIAlertAction to a UIActionSheet. (You should also set Title and Action, of course)

programmatically created NSMenu is only showing the first item

I am writing a Mac app with minimal IB usage -- see programatically create initial window of cocoa app (OS X).
Here is my code (via Xamarin/C#):
public override void DidFinishLaunching(NSNotification notification) {
// create and show a window, then . . .
NSMenu fileMenu = new NSMenu();
NSMenu appMenu = new NSMenu();
// add some items to both menus, then . . .
NSMenuItem file = new NSMenuItem("file");
file.Submenu = fileMenu;
NSMenuItem app = new NSMenuItem("app");
app.Submenu = appMenu;
NSMenu topLevelMenu = new NSMenu();
topLevelMenu.AddItem(app); // these two lines in
topLevelMenu.AddItem(file); // either order
NSApplication.SharedApplication.Menu = topLevelMenu; // incidentally, setting the MainMenu doesn't appear to do anything
}
}
The weird thing is that only the first menu item I add shows up, and its title is changed to the name of my app. So for the above code, I would see the app menu, only, with a title of MyAppName, but the correct items. If I were to instead add the file NSMenuItem first, I would see that menu, again with its name changed to my app name, and the view menu would not show up at all.
I don't mind the changed title; I suppose Apple wants to always show the name of the active app. But it bugs me that I can't get the additional menus to appear.
How can I get all of my menus to show up across the top of the screen?
I just needed to add titles to my menus:
fileMenu.Title = "file";
appMenu.Title = "whatever";
The title of the first one is still changed to the name of the app.

add web page in xamarin form

I'm very very new to using Xamarin forms. So new in fact I have just watched the "microsoft xamarin forms for absolute beginners".
I'm trying to include a webpage into the Xamarin form but the only info I can find is
var browser = new WebView {
Source = "http://xamarin.com"
};
This might sound silly but has anyone got a full tutorial on how to include one?
thanks
just create a WebView and assign it to a ContentPage. Then you can either make this page the main page of your app (in the App class) or you can navigate to it from another page.
ContentPage page = new ContentPage {
Content = new WebView { Source = "http://xamarin.com" }
};
To display a website from the internet, set the WebView's Source property to a string URL:
var browser = new WebView
{
Source = "http://xamarin.com"
};
see this:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/webview?tabs=windows#performance

how to add/show a UserControl (e.g. popup) in a WP7 app page?

hi i have created a user control.
now i want to add this control to a page e.g. when the user clicks a button (important is, that i dont want to add it direcly in xaml, i want to add id in the c# code section)
how to so this?
In your button's Click event, you could do something like:
MyControl control = new MyControl();
// Set whatever properties you need in your control here
LayoutRoot.Children.Add(control);
if (listBox1.Items.Count == 0)
{
Popup popup = new Popup();
WPCpopup po = new WPCpopup(popup);
popup.Width = System.Windows.Application.Current.Host.Content.ActualWidth;
popup.Child = po;
popup.VerticalOffset = 300;
popup.IsOpen = true;
}
WPCpopup is usercontrol

Relative or absolute path mess

I'm developing a Windows Phone 7.1 application.
I have the following folders structure:
- Images (**folder**)
|
- appbar.questionmark.rest.png
- Views(**folder**)
|
- About.xaml
- MainPage.xaml
...
I'm trying to create an app bar programmatically with:
private void SetUpAppBar()
{
// 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 helpButton = new ApplicationBarIconButton(new Uri("..//Images//appbar.questionmark.rest.png", UriKind.Relative));
helpButton.Text = AppResources.Help;
helpButton.Click += new EventHandler(helpButton_Click);
ApplicationBar.Buttons.Add(helpButton);
// Create a new menu item with the localized string from AppResources.
ApplicationBarMenuItem appBarHelpMenuItem = new ApplicationBarMenuItem(AppResources.Help);
appBarHelpMenuItem.Click += new EventHandler(helpButton_Click);
ApplicationBar.MenuItems.Add(appBarHelpMenuItem);
}
But I can't see the icon on app bar. What am I doing wrong?
I have test with this:
ApplicationBarIconButton helpButton = new ApplicationBarIconButton(new Uri("..//Images//appbar.questionmark.rest.png", UriKind.Relative))
But I get an invalid path exception. I've also changed UriKind to Relative, Absolute and with AbsoluteOrRelative.
appbar.questionmark.rest.png is marked as Resource, and copy to directory is set to "don't copy".
The pictures Build Action should be Content.
ApplicationBarIconButton helpButton = new ApplicationBarIconButton(new Uri("/Images/appbar.questionmark.rest.png", UriKind.Relative));
Try this i hope this will work.:)
This is how MSDN describes how to add a button to the AppBar
ApplicationBarIconButton button1 = new ApplicationBarIconButton();
button1.IconUri = new Uri("/Images/YourImage.png", UriKind.Relative);
button1.Text = "button 1";
ApplicationBar.Buttons.Add(button1);
I think your problem is that your picture is set as a Resource and not as Content.

Resources