Skip to content

Message

闫驚鏵(Jinhua Yan) edited this page Dec 17, 2024 · 2 revisions

Position

Support Left Top Right Bottom positions around the perimeter

public enum Position
{
    Left,
    Top,
    Right,
    Bottom
}
Message.SetPosition(Position.Left);

Window

1)Xaml

<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>

2)CSharp

        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;
            }
        }

Desktop

1)Xaml

<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>

2)CSharp

        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;
    }
}
Clone this wiki locally