By Adam Nagy
I set the DialogLauncher property of my RibbonPanelSource, but the icon does not appear on it:
static RibbonPanel AddOnePanel()
{
RibbonButton rb;
RibbonPanelSource rps = new RibbonPanelSource();
rps.Title = "Test One";
RibbonPanel rp = new RibbonPanel();
rp.Source = rps;
rb = new RibbonButton();
rb.Name = "Test Button";
rb.ShowText = true;
rb.Text = "Test Button";
// Add the Button to the Tab
rps.Items.Add(rb);
// Create a Command Item that the Dialog Launcher can use,
// for this test it is just a place holder.
RibbonCommandItem rci = new RibbonCommandItem();
rci.Name = "TestCommand";
// Assign the Command Item to the DialogLauncher which auto-enables
// the little button at the lower right of a Panel, but where's
// the arrow you see in the stock Ribbons?
rps.DialogLauncher = rci;
return rp;
}
If I tried to set the image myself, that did not work either:
BitmapImage myBitMapImage = new BitmapImage();
// BitmapImage.UriSource must be in a BeginInit/EndInit block.
myBitMapImage.BeginInit();
// Change this string to a bmp file on your system
myBitMapImage.UriSource = new Uri("C:/temp.png",
UriKind.RelativeOrAbsolute);
myBitMapImage.EndInit();
rci.Image = myBitMapImage;
rci.LargeImage = myBitMapImage;
Solution
You need to use a RibbonButton and assign that to the DialogLauncher:
RibbonButton dialogLauncherButton = new RibbonButton();
dialogLauncherButton.Name = "TestCommand";
rps.DialogLauncher = dialogLauncherButton;