Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Creating Wpf Dialogs

БесплатноБез исполняемых скриптовНе проверен

Creates WPF dialog windows including modal dialogs, MessageBox, and common dialogs. Use when implementing confirmation prompts, settings windows, or…

christian289от christian289★ 42 звезды на GitHub

Об этом скилле

WPF Dialog Patterns

MVVM Framework Rule: .claude/rules/dotnet/wpf/mvvm-framework.md 설정에 따라 코드 스타일이 결정됩니다. Prism 9 사용 시 → PRISM.md 참조

Creating and managing dialog windows for user interaction.

Advanced Patterns: See ADVANCED.md for MVVM dialog service, modeless dialogs, and input dialogs.

1. Dialog Types Overview

Dialog Types
├── Modal Dialogs (ShowDialog)
│   ├── Custom Window dialogs
│   └── MessageBox
├── Modeless Dialogs (Show)
│   └── Tool windows, floating panels
└── Common Dialogs
    ├── OpenFileDialog
    ├── SaveFileDialog
    └── FolderBrowserDialog

2. MessageBox

2.1 Basic Usage

// Simple message
MessageBox.Show("Operation completed successfully.");

// With title
MessageBox.Show("File saved.", "Success");

// With buttons
var result = MessageBox.Show(
    "Do you want to save changes?",
    "Confirm",
    MessageBoxButton.YesNoCancel);

// With icon
MessageBox.Show(
    "An error occurred.",
    "Error",
    MessageBoxButton.OK,
    MessageBoxImage.Error);

2.2 MessageBox Options

Buttons:

Value Buttons
OK OK
OKCancel OK, Cancel
YesNo Yes, No
YesNoCancel Yes, No, Cancel

Icons:

Value Icon
None No icon
Information Info circle
Warning Warning triangle
Error Red X

2.3 Processing Results

var result = MessageBox.Show(
    "Are you sure you want to delete this item?",
    "Confirm Delete",
    MessageBoxButton.YesNo,
    MessageBoxImage.Warning,
    MessageBoxResult.No);  // Default button

switch (result)
{
    case MessageBoxResult.Yes:
        DeleteItem();
        break;
    case MessageBoxResult.No:
        // Cancelled
        break;
}

3. Custom Modal Dialog

3.1 Dialog Window XAML

<Window x:Class="MyApp.Dialogs.SettingsDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Settings"
        Width="400" Height="300"
        WindowStartupLocation="CenterOwner"
        ResizeMode="NoResize"
        ShowInTaskbar="False">
    <Grid Margin="20">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- Content -->
        <StackPanel Grid.Row="0">
            <Label Content="User Name:"/>
            <TextBox x:Name="UserNameTextBox" Margin="0,5,0,15"/>
            <CheckBox x:Name="EnableNotificationsCheckBox"
                      Content="Enable notifications"/>
        </StackPanel>

        <!-- Dialog buttons -->
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="OK" Width="80" Margin="0,0,10,0"
                    Click="OkButton_Click" IsDefault="True"/>
            <Button Content="Cancel" Width="80"
                    Click="CancelButton_Click" IsCancel="True"/>
        </StackPanel>
    </Grid>
</Window>

3.2 Dialog Code-Behind

namespace MyApp.Dialogs;

using System.Windows;

public partial class SettingsDialog : Window
{
    public string UserName { get; private set; } = string.Empty;
    public bool EnableNotifications { get; private set; }

    public SettingsDialog()
    {
        InitializeComponent();
    }

    private void OkButton_Click(object sender, RoutedEventArgs e)
    {
        // Validate input
        if (string.IsNullOrWhiteSpace(UserNameTextBox.Text))
        {
            MessageBox.Show("Please enter a user name.", "Validation Error",
                MessageBoxButton.OK, MessageBoxImage.Warning);
            UserNameTextBox.Focus();
            return;
        }

        // Set results
        UserName = UserNameTextBox.Text;
        EnableNotifications = EnableNotificationsCheckBox.IsChecked ?? false;

        // Close with success
        DialogResult = true;
    }

    private void CancelButton_Click(object sender, RoutedEventArgs e)
    {
        DialogResult = false;
    }
}

3.3 Using the Dialog

private void OpenSettings_Click(object sender, RoutedEventArgs e)
{
    var dialog = new SettingsDialog
    {
        Owner = this  // Set owner for centering
    };

    if (dialog.ShowDialog() == true)
    {
        // User clicked OK
        _currentUserName = dialog.UserName;
        _enableNotifications = dialog.EnableNotifications;
        ApplySettings();
    }
}

4. Common Dialogs

4.1 OpenFileDialog

using Microsoft.Win32;

private void OpenFile_Click(object sender, RoutedEventArgs e)
{
    var dialog = new OpenFileDialog
    {
        Title = "Open File",
        Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*",
        FilterIndex = 1,
        InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
        Multiselect = false,
        CheckFileExists = true
    };
Полный SKILL.md на GitHub

Установить Creating Wpf Dialogs в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

ADVANCED.mdPRISM.md

FAQ

Что делает скилл Creating Wpf Dialogs?

Creates WPF dialog windows including modal dialogs, MessageBox, and common dialogs. Use when implementing confirmation prompts, settings windows, or file/folder pickers.

Как установить скилл Creating Wpf Dialogs?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Creating Wpf Dialogs запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Creating Wpf Dialogs с