1
Vote

CommandButton with image in code

description

Hi.

I have a problem when creating command buttons in code. I do it like this:
var cmd = new Elysium.Controls.CommandButton();
                    cmd.Click += (sender, args) =>
                        {
                            var dlg = new DisplayConfigPage(plugin.Value.ConfigPage);
                            dlg.Owner = this;
                            if (dlg.ShowDialog() ?? false)
                                ;
                        };
                    cmd.Header = "Configure " + header;
                    var bi = new BitmapImage();
                    bi.BeginInit();
                    bi.UriSource = new Uri("pack://application:,,,/DatenAquisition;component/iconZ/Settings.png");
                    bi.DecodePixelWidth = 30;
                    bi.DecodePixelHeight = 30;
                    bi.EndInit();
                    cmd.Content = new Image { Source = bi, Stretch = Stretch.Fill, SnapsToDevicePixels = true };

                    var xy = appbar.Items.Add(cmd);
Now the buttons are seeable, but the icons aren't as they are displayed like boxes. The image width/height is 48, and the background is transparent.

Please help.

comments