Notification.Wpf
Notification.Wpf copied to clipboard
Round corner?
How can I make the corner of the notifications round?
what do you mean?
Border.CornerRadius
Right now a notification window/popup/message is a rectangle but I want round corners.
you can use this like a sample
var grid = new Grid();
var text_block = new TextBlock { Text = "Some Text", Margin = new Thickness(0, 10, 0, 0), HorizontalAlignment = HorizontalAlignment.Center };
var panelBTN = new StackPanel { Height = 100, Margin = new Thickness(0, 40, 0, 0) };
var btn1 = new Button { Width = 200, Height = 40, Content = "Cancel" };
var text = new TextBlock {Foreground = Brushes.White, Text = "Hello, world", Margin = new Thickness(0, 10, 0, 0), HorizontalAlignment = HorizontalAlignment.Center};
panelBTN.VerticalAlignment = VerticalAlignment.Bottom;
panelBTN.Children.Add(btn1);
var row1 = new RowDefinition();
var row2 = new RowDefinition();
var row3 = new RowDefinition();
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.HorizontalAlignment = HorizontalAlignment.Center;
grid.Children.Add(text_block);
grid.Children.Add(text);
grid.Children.Add(panelBTN);
Grid.SetRow(panelBTN, 1);
Grid.SetRow(text_block, 0);
Grid.SetRow(text, 2);
object content = grid;
notificationManager.Show(content,null,TimeSpan.MaxValue);
This method allows you to create any element yourself and then show it. Create your message template and display it
No offense but you did not understand me. With your suggestion:
private void Show_Any_content()
{
var border = new Border
{
CornerRadius = new CornerRadius(50),
Background = new SolidColorBrush(Colors.Red),
BorderBrush = new SolidColorBrush(Colors.Yellow),
BorderThickness = new Thickness(5)
};
var grid = new Grid();
var text_block = new TextBlock { Text = "Some Text", Margin = new Thickness(0, 10, 0, 0), HorizontalAlignment = HorizontalAlignment.Center };
var panelBTN = new StackPanel { Height = 100, Margin = new Thickness(0, 40, 0, 0) };
var btn1 = new Button { Width = 200, Height = 40, Content = "Cancel" };
var text = new TextBlock
{ Foreground = Brushes.White, Text = "Hello, world", Margin = new Thickness(0, 10, 0, 0), HorizontalAlignment = HorizontalAlignment.Center };
panelBTN.VerticalAlignment = VerticalAlignment.Bottom;
panelBTN.Children.Add(btn1);
//var row1 = new RowDefinition();
//var row2 = new RowDefinition();
//var row3 = new RowDefinition();
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.HorizontalAlignment = HorizontalAlignment.Center;
grid.Children.Add(text_block);
grid.Children.Add(text);
grid.Children.Add(panelBTN);
Grid.SetRow(panelBTN, 1);
Grid.SetRow(text_block, 0);
Grid.SetRow(text, 2);
border.Child = grid;
object content = border;
_notificationManager.Show(content,
areaName: GetArea(), TimeSpan.MaxValue);
}
Result:
You can see the black / dark gray rectangle. You need to update your theme file and expose CornerRadius.
I believe its this one, if not doesnt matter as the solution is the same: https://github.com/Platonenkov/Notification.Wpf/blob/42a12042ec8387a3d3b3e3a77e531652bb0fbe27/Notification.Wpf/Themes/Generic.xaml#L385-L388
Change it to
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{Binding RelativeSource={RelativeSource AncestorType=controls:Notification}, Path=CornerRadius}"
BorderThickness="{TemplateBinding BorderThickness}"
Margin="8,8,0,0">
And add a public property CornerRadius to Notification control