Programmatically creating a toolbar in WPF
Posted
by rwallace
on Stack Overflow
See other posts from Stack Overflow
or by rwallace
Published on 2010-04-18T10:36:43Z
Indexed on
2010/04/18
10:43 UTC
Read the original article
Hit count: 624
wpf
I'm trying to create a simple toolbar in WPF, but the toolbar shows up with no corresponding buttons on it, just a very thin blank white strip. Any idea what I'm doing wrong, or what the recommended procedure is? Relevant code fragments so far:
var tb = new ToolBar();
var b = new Button();
b.Command = comback;
Image myImage = new Image();
myImage.Source = new BitmapImage(new Uri("back.png", UriKind.Relative));
b.Content = myImage;
tb.Items.Add(b);
var p = new DockPanel();
//DockPanel.SetDock(mainmenu, Dock.Top);
DockPanel.SetDock(tb, Dock.Top);
DockPanel.SetDock(sb, Dock.Bottom);
//p.Children.Add(mainmenu);
p.Children.Add(tb);
p.Children.Add(sb);
Content = p;
© Stack Overflow or respective owner