Icons do not appear in ApplicationBar.
MainPage.xaml.cs
// Конструктор
public MainPage()
{
InitializeComponent();
// Локализация ApplicationBar
BuildLocalizedApplicationBar();
}
// ApplicationBar
private void BuildLocalizedApplicationBar()
{
// Установка нового экземпляра ApplicationBar.
ApplicationBar = new ApplicationBar();
// Задаем опции
ApplicationBar.Mode = ApplicationBarMode.Default;
ApplicationBar.Opacity = 1.0;
ApplicationBar.IsVisible = true;
ApplicationBar.IsMenuEnabled = true;
// Кнопка "Add"
ApplicationBarIconButton Add = new ApplicationBarIconButton(new Uri("/Assets/AppBar/Add.png", UriKind.Relative));
Add.Text = AppResources.AppBarAdd;
ApplicationBar.Buttons.Add(Add);
Add.Click += new EventHandler(Button_Add_Click);
// Кнопка "Edit"
ApplicationBarIconButton Edit = new ApplicationBarIconButton(new Uri("/Assets/AppBar/Edit.png", UriKind.Relative));
Edit.Text = AppResources.AppBarEdit;
ApplicationBar.Buttons.Add(Edit);
Edit.Click += new EventHandler(Button_Edit_Click);
// Кнопка "Delete"
ApplicationBarIconButton Delete = new ApplicationBarIconButton(new Uri("/Assets/AppBar/Delete.png", UriKind.Relative));
Delete.Text = AppResources.AppBarDelete;
ApplicationBar.Buttons.Add(Delete);
Delete.Click += new EventHandler(Button_Delete_Click);
// Кнопка "Connect"
ApplicationBarIconButton Connect = new ApplicationBarIconButton(new Uri("/Assets/AppBar/Connect.png", UriKind.Relative));
Connect.Text = AppResources.AppBarConnect;
ApplicationBar.Buttons.Add(Connect);
Connect.Click += new EventHandler(Button_Connect_Click);
}
Icons in the folder / Assets / AppBar / is, standard icons, pulled out of most SDK, size 76x76, for Dark theme.
The problem on the emulator and on the phone.
Related
Ho to make Secondary Commands in C# in windows phone 8.1 (winprt) app?
//WINRT:
CommandBar CommandBarObject = new CommandBar();
AppBarButton FirstBtn = new AppBarButton() { Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Assets/first.png") } };
FirstBtn.Label = "First";
FirstBtn.Click += FirstBtn_Click;
FirstBtn.IsEnabled = true;
CommandBarObject.PrimaryCommands.Add(FirstBtn);
CommandBarObject.SecondaryCommands.Add(secondaryCommand);
How to make this secondaryCommand now?
Just put there AppBarButton:
CommandBar CommandBarObject = new CommandBar();
AppBarButton FirstBtn = new AppBarButton() { Icon = new BitmapIcon() { UriSource = new Uri("ms-appx:///Assets/first.png") } };
FirstBtn.Label = "First";
FirstBtn.Click += FirstBtn_Click;
FirstBtn.IsEnabled = true;
AppBarButton secondaryCommand = new AppBarButton() { Label = "Second", IsEnabled = true } };
secondaryCommand.Click += FirstBtn_Click;
CommandBarObject.PrimaryCommands.Add(FirstBtn);
CommandBarObject.SecondaryCommands.Add(secondaryCommand);
I need to add a grid to a popup in Silverlight project. I have added this code in the mainpage.xaml.cs file I have created a popup.
but I need to add a grid showing a table from the database.
private void Button_Click_1(object sender, RoutedEventArgs e)
{
popup p = new Popup();Border border = new Border();
border.BorderBrush = new SolidColorBrush(Colors.Black);
border.BorderThickness = new Thickness(5.0);
StackPanel panel1 = new StackPanel();
panel1.Background = new SolidColorBrush(Colors.LightGray);
Button button1 = new Button();
button1.Content = "Close";
button1.Margin = new Thickness(2.0);
button1.Click += new RoutedEventHandler(button1_Click);
TextBlock textblock1 = new TextBlock();
textblock1.Text = "The popup control";
textblock1.Margin = new Thickness(5.0);
panel1.Children.Add(textblock1);
panel1.Children.Add(button1);
border.Child = panel1;
Grid grid1 = new Grid();
// i need to bind this grid to data from the sql database and attach this grid to the popup
// Set the Child property of Popup to the border
// which contains a stackpanel, textblock and button.
p.Child = border;
p.DataContext =
// Set where the popup will show up on the screen.
p.VerticalOffset = 200;
p.HorizontalOffset = 300;
// Open the popup.
p.IsOpen = true;
}
The Grid is a layout control, and not for displaying tables. For tabular data, you'll need a DataGrid control.
List<Customer> customerList = new List<Customer>();
var dataGrid = new DataGrid();
dataGrid.ItemsSource = customerList;
Popup popup = new Popup();
popup.Child = dataGrid;
popup.IsOpen = true;
I've tried several things and eventualy just put the image directly inside C:\Users\Gebruiker\Documents\Visual Studio 2012\Projects\FolderMonitor\FolderMonitor\bin\Debug. This works for now, but idealy I'd like to set the notifyIcon.Icon = new Icon("folder.ico") to an image inside a images folder in the solution. But I can't figure out how this works..
public FolderMonitorApplicationContext()
{
this.monitor = new Monitor();
notifyIcon = new NotifyIcon();
notifyIcon.Icon = new Icon("folder.ico");
notifyIcon.Text = "Folder Monitor";
notifyIcon.Visible = true;
contextMenu = new ContextMenuStrip();
openMonitor = new ToolStripMenuItem();
exitApplication = new ToolStripMenuItem();
notifyIcon.ContextMenuStrip = contextMenu;
notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
openMonitor.Text = "Open";
openMonitor.Click += new EventHandler(OpenMonitor_Click);
contextMenu.Items.Add(openMonitor);
exitApplication.Text = "Exit..";
exitApplication.Click += new EventHandler(ExitApplication_Click);
contextMenu.Items.Add(exitApplication);
}
So it's currently working, but not how it i'd like it to work. Hope you can help me out here, thanks in advance.
After adding the picture file to your project, bring up the item properties by clicking on it, and pressing F4. Under Build Action, change it to "Embedded Resource".
You can access embedded resources in Stream form like this:
public FolderMonitorApplicationContext()
{
this.monitor = new Monitor();
notifyIcon = new NotifyIcon();
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
"<project namespace>.<folder path>" + "filename.ico"))
{
notifyIcon.Icon = new Icon(stream);
}
notifyIcon.Text = "Folder Monitor";
notifyIcon.Visible = true;
contextMenu = new ContextMenuStrip();
openMonitor = new ToolStripMenuItem();
exitApplication = new ToolStripMenuItem();
notifyIcon.ContextMenuStrip = contextMenu;
notifyIcon.DoubleClick += NotifyIcon_DoubleClick;
openMonitor.Text = "Open";
openMonitor.Click += new EventHandler(OpenMonitor_Click);
contextMenu.Items.Add(openMonitor);
exitApplication.Text = "Exit..";
exitApplication.Click += new EventHandler(ExitApplication_Click);
contextMenu.Items.Add(exitApplication);
}
Use the same method to insert the icon on the form.
To find the same code in your application to copy in your systemtray please:
check if, in the file .resx, there is the icon called with $ symbol(example:"$this.icon")
find your code to include the icon on the [name of form].desiner.cs.
example of code in my application:
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(systemtray));
trayIcon.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
public MainPage()
{
InitializeComponent();
ApplicationBar = new ApplicationBar();
ApplicationBar.Opacity = 1.0;
ApplicationBar.IsVisible = true;
ApplicationBar.IsMenuEnabled = true;
ApplicationBar.BackgroundColor = System.Windows.Media.Colors.Transparent;
ApplicationBarIconButton add = new ApplicationBarIconButton();
add.IconUri = new Uri("Icons/appbar.add.rest.png", UriKind.Relative);
add.Text = "add a friend";
ApplicationBar.Buttons.Add(add);
add.Click += new EventHandler(add_Click); //ERROR
ApplicationBarIconButton list = new ApplicationBarIconButton();
list.IconUri = new Uri("icons/appbar.folder.rest.png",UriKind.Relative);
list.Text = "List";
ApplicationBar.Buttons.Add(list);
ApplicationBarIconButton about = new ApplicationBarIconButton();
about.IconUri = new Uri("icons/appbar.questionmark.rest.png",UriKind.Relative);
about.Text = "about";
ApplicationBar.Buttons.Add(about);
}
Have you defined a method called add_Click anywhere in the class? It needs to have the following signature:
void add_Click(object sender, EventArgs e)
{
// Put code to handle the click event in here
}
You need to wire your add_Click event with the actual add_Click method.
I think you are missing add_Click implementation in your code.
In WM6.5 a have a simple form with a webbrowser control. I open a local file and fill this page data to the document.text
1.
On some phones you see the page but no scrollbar?
2.
On my phone and in the simulators I have a scrollbar. If you put your finger on the screen and move vertically you only highlight the text. What I would like is the page to scroll down/up with this touch.
Is there a trick for this? Below is my init and the filling of the html.
public partial class FormLicense : Form
{
bool _CanClose = false;
private const string _html =
"<html><body><br><div style='top:20px;left:50px;border:solid 1px red'><a href='http://www.cnn.com'>CNN</a></div><br><font size='14'>xx</font><a href='http://stackoverflow.com'>stackoverflow</a></body></html>";
public FormLicense()
{
InitializeComponent();
this.Load += new System.EventHandler(this.FormLicense_Load);
this.Closed += new System.EventHandler(this.FormLicense_Closed);
this.Closing += new System.ComponentModel.CancelEventHandler(this.FormLicense_Closing);
this.SuspendLayout();
this.menu1L.Text = "I Accept";
this.menu1R.Text = "Don't Accept";
this.Text = "License";
using (StreamReader sr = new StreamReader(GlobalLicense.FileName, System.Text.Encoding.Default))
{
webBrowser1.DocumentText = sr.ReadToEnd();
}
.....
....
...
..
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menu1L = new System.Windows.Forms.MenuItem();
this.menu1R = new System.Windows.Forms.MenuItem();
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.Add(this.menu1L);
this.mainMenu1.MenuItems.Add(this.menu1R);
//
// menu1L
//
this.menu1L.Text = "1L";
this.menu1L.Click += new System.EventHandler(this.menu1L_Click);
//
// menu1R
//
this.menu1R.Text = "1R";
this.menu1R.Click += new System.EventHandler(this.menu1R_Click);
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.ScriptErrorsSuppressed = true;
this.webBrowser1.Size = new System.Drawing.Size(240, 268);
//
// FormLicense
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScroll = true;
this.AutoScrollMargin = new System.Drawing.Size(10, 10);
this.ClientSize = new System.Drawing.Size(240, 268);
this.Controls.Add(this.webBrowser1);
this.Menu = this.mainMenu1;
this.Name = "FormLicense";
this.Text = "FormLicense";
this.ResumeLayout(false);
The scrollbar problem is a bug:
Link