-
Notifications
You must be signed in to change notification settings - Fork 255
Message
闫驚鏵(Jinhua Yan) edited this page Dec 17, 2024
·
2 revisions
Support Left Top Right Bottom positions around the perimeter
public enum Position
{
Left,
Top,
Right,
Bottom
}
Message.SetPosition(Position.Left);
<StackPanel
Grid.Row="1"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Orientation="Horizontal">
<Button
Click="AddButton_Click"
Content="Info Message"
Style="{StaticResource WD.SuccessPrimaryButton}"
Tag="Info" />
<Button
Click="AddButton_Click"
Content="Error Message"
Style="{StaticResource WD.DangerPrimaryButton}"
Tag="Error" />
<Button
Click="AddButton_Click"
Content="Warning Message"
Style="{StaticResource WD.WarningPrimaryButton}"
Tag="Warning" />
<Button
Click="AddButton_Click"
Content="Question Message"
Style="{StaticResource WD.PrimaryButton}"
Tag="Question" />
<Button
Click="AddButton_Click"
Content="Long Message"
Style="{StaticResource WD.SuccessPrimaryButton}"
Tag="Long" />
</StackPanel>
private void AddButton_Click(object sender, RoutedEventArgs e)
{
var btn = sender as Button;
switch (btn.Tag)
{
case "Info":
Message.Push(App.Current.MainWindow, "This is a info message", MessageBoxImage.Information);
break;
case "Error":
Message.Push("This is a error message", MessageBoxImage.Error, true);
break;
case "Warning":
Message.Push("This is a warning message", MessageBoxImage.Warning, true);
break;
case "Question":
Message.Push("This is a question message", MessageBoxImage.Question);
break;
default:
Message.Push("这是一条很长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长消息", MessageBoxImage.Information);
break;
}
}
<UniformGrid
Height="38"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
wd:PanelHelper.Spacing="2"
Rows="1">
<Button
Click="AddButtonDesktop_Click"
Content="Info Message"
Style="{StaticResource WD.SuccessPrimaryButton}"
Tag="Info" />
<Button
Click="AddButtonDesktop_Click"
Content="Error Message"
Style="{StaticResource WD.DangerPrimaryButton}"
Tag="Error" />
<Button
Click="AddButtonDesktop_Click"
Content="Warning Message"
Style="{StaticResource WD.WarningPrimaryButton}"
Tag="Warning" />
<Button
Click="AddButtonDesktop_Click"
Content="Question Message"
Style="{StaticResource WD.PrimaryButton}"
Tag="Question" />
<Button
Click="AddButtonDesktop_Click"
Content="Long Message"
Style="{StaticResource WD.SuccessPrimaryButton}"
Tag="Long" />
<Button Click="BtnDesktopClear_Click" Content="Clear" />
</UniformGrid>
private void AddButtonDesktop_Click(object sender, RoutedEventArgs e)
{
var btn = sender as Button;
switch (btn.Tag)
{
case "Info":
Message.PushDesktop("This is a info message", MessageBoxImage.Information);
break;
case "Error":
Message.PushDesktop("This is a error message", MessageBoxImage.Error, true);
break;
case "Warning":
Message.PushDesktop("This is a warning message", MessageBoxImage.Warning, true);
break;
case "Question":
Message.PushDesktop("This is a question message", MessageBoxImage.Question);
break;
default:
Message.PushDesktop("这是一条很长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长消息", MessageBoxImage.Information);
break;
}
}