Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi guys,
I searched many pages and tried them. But I have some troubles with display image for a new ribbon button.
- I dont know where I can put my image to it work.
- I wonder After build, if others PC load this .dll file then this image will be showed ?
Anyone can help!
I have some following codes:
BitmapImage getBitmap(string fileName)
{
BitmapImage bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(string.Format("pack://application:,,,/{0};component/{1}",
Assembly.GetExecutingAssembly().GetName().Name, fileName));
bmp.EndInit();
return bmp;
}private void addPanel2(RibbonTab ribTab)
{
//create the panel source
var ribPanelSource = new RibbonPanelSource();
ribPanelSource.Title = "My Tool";
//create the panel
var ribPanel = new RibbonPanel();
ribPanel.Source = ribPanelSource;
ribTab.Panels.Add(ribPanel);
//create button1
var button1 = new RibbonButton();
button1.Text = "Button1";
button1.ShowText = true;
button1.ShowImage = true;
button1.Image = getBitmap("button1.png");
//pay attention to the SPACE after the command name
button1.CommandParameter = "PlineChecked ";
button1.CommandHandler = new BtCommandHandler();
ribPanelSource.Items.Add(button1);
/*************/
//Add separate between 2 button
RibbonSeparator rbseparator = new RibbonSeparator();
rbseparator.SeparatorStyle = RibbonSeparatorStyle.Line;
ribPanelSource.Items.Add(rbseparator);
/*************/
//create button2
var button2 = new RibbonButton();
button2.Text = "Button2";
button2.ShowText = true;
//pay attention to the SPACE after the command name
button2.CommandParameter = "LineChecked ";
button2.CommandHandler = new BtCommandHandler();
ribPanelSource.Items.Add(button2);
}
Solved! Go to Solution.