Want to add multiple Buttons/Commands without changing whole style.
Like: https://docs.telerik.com/devtools/winforms/controls/desktopalert/button-items
Hello Marco,
Thank you for sharing your solution with our community. I do hope you find it suitable while we implement this feature.
Regards,
Dilyan Traykov
Progress Telerik
Thank you for your efforts.
FYI
I also found this example and build my workaround for this with the help of Stack overflow ( How do I build a DataTemplate in c# code? ). I need it for a behavior with code behind:
var style = new Style(typeof(RadDesktopAlert));
DataTemplate alertDataTemplate = new DataTemplate {DataType = typeof(RadDesktopAlert)};
//set up the stack panel
FrameworkElementFactory spFactory = new FrameworkElementFactory(typeof(StackPanel));
spFactory.SetValue(StackPanel.OrientationProperty, Orientation.Vertical);
//set up the card holder textblock
FrameworkElementFactory cardHolder = new FrameworkElementFactory(typeof(TextBlock));
cardHolder.SetBinding(TextBlock.TextProperty, new Binding("")); // empty Binding = Content
spFactory.AppendChild(cardHolder);
//set up the stack panel
FrameworkElementFactory buttonSpFactory = new FrameworkElementFactory(typeof(StackPanel));
buttonSpFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
spFactory.AppendChild(buttonSpFactory);
//set up the notes textblock
FrameworkElementFactory buttonIsin = new FrameworkElementFactory(typeof(RadButton));
buttonIsin.SetValue(RadButton.CommandProperty, _adoptAllCommand);
buttonIsin.SetValue(RadButton.ContentProperty, "All");
buttonSpFactory.AppendChild(buttonIsin);
FrameworkElementFactory buttonAll = new FrameworkElementFactory(typeof(RadButton));
buttonAll.SetValue(RadButton.CommandProperty, _adoptIsinCommand);
buttonAll.SetValue(RadButton.ContentProperty, "Same ISIN");
buttonSpFactory.AppendChild(buttonAll);
//set the visual tree of the data template
alertDataTemplate.VisualTree = spFactory;
//set the item template to be our shiny new data template
style.Setters.Add(new Setter(RadDesktopAlert.ContentTemplateProperty, alertDataTemplate));
var alert = new DesktopAlertParameters
{
Header = "Take over values",
Content = "Change " + (e.Cell.Column.Header is string ? e.Cell.Column.Header : e.Cell.Column.UniqueName) + " to " + newVal + "?",
DesktopAlertStyle = style,
};
Hi Marco,
Thank you for your feedback.
If this feature request accumulates enough votes, we will consider introducing additional properties to add custom content to the RadDesktopAlerts.
For the time being, you can only achieve the desired result by modifying the control template of the RadDesktopAlert control.
For your convenience, I've prepared a small sample project to demonstrate how to achieve a layout similar to the one in the article you referenced.
Could you please have a look and let me know whether such an approach would be applicable for you for the time being?
Regards,
Dilyan Traykov
Progress Telerik