iconDreamine
← 지식 Q&A 목록
Dreamine 입문 · Published

Dreamine으로 만든 화면에서 버튼을 눌렀을 때 실행할 코드는 어디에 작성해야 하나요?

요청 판정 Supported 개정 1 / 1 조회 729초 동안 분석2026-07-20 23:17
직접 답변

버튼 클릭 시 실행할 실제 코드는 XAML 코드 비하인드가 아니라 `SampleCrossUi.Shared/ViewModels/ControlsEvent.cs`의 `ControlsEvent.ClickMe()`에 작성합니다. ViewModel에는 `[DreamineCommand("Event.ClickMe")] private partial void ClickMe();`만 선언하고, XAML은 생성되는 `ClickMeCommand`에 바인딩합니다.

EVIDENCE COVERAGE

실행 경로 검증

완전 검증

ClickMeCommand → ControlsDemoRow.ClickMe → Event.ClickMe → ControlsEvent.ClickMe

  1. XAML Command 바인딩
  2. 생성된 Command
  3. ViewModel DreamineCommand 메서드
  4. forwardsTo 대상
  5. Event 실제 메서드

핵심 코드 근거

직접 근거

ClickMe 코드 선언

stable URI로 확인한 실제 선언 일부입니다.

[DreamineCommand] ClickMe()
    [DreamineCommand("Event.ClickMe")]
    private partial void ClickMe();
20_SOURCES/998. DEMO/000. Sample/050. CrossUi/SampleCrossUi.Shared/ViewModels/ControlsViewModel.cs:56-57
직접 근거

ControlsDemoRow.ClickMe 코드 선언

stable URI로 확인한 실제 선언 일부입니다.

[DreamineCommand] ClickMe()
    [DreamineCommand("Event.ClickMe")]
    private partial void ClickMe();
20_SOURCES/998. DEMO/000. Sample/050. CrossUi/SampleCrossUi.Shared/ViewModels/ControlsViewModel.cs:56-57
직접 근거

ControlsDemoRow.ClickMe 코드 선언

stable URI로 확인한 실제 선언 일부입니다.

[DreamineCommand("Event.ClickMe")]
    [DreamineCommand("Event.ClickMe")]
    private partial void ClickMe();
20_SOURCES/998. DEMO/000. Sample/050. CrossUi/SampleCrossUi.Shared/ViewModels/ControlsViewModel.cs:56-57
직접 근거

ControlsEvent.ClickMe 코드 선언

stable URI로 확인한 실제 선언 일부입니다.

ControlsEvent.ClickMe()
    public void ClickMe()
    {
        ClickCount++;
        ActivityLog.Add($"[{DateTime.Now:HH:mm:ss}] Clicked ({ClickCount})");
        Raise($"Button clicked {ClickCount} time(s)");
    }

    // ── RadioButton ───────────────────────────────────────
    public string SelectedRadio { get; private set; } = "Option A";

    public void SelectRadio(string? option)
    {
20_SOURCES/998. DEMO/000. Sample/050. CrossUi/SampleCrossUi.Shared/ViewModels/ControlsEvent.cs:26-37
직접 근거

ControlsPage.ClickMeCommand 코드 선언

stable URI로 확인한 실제 선언 일부입니다.

Command="{Binding ClickMeCommand}"

                <!-- ① Button -->
                <VerticalStackLayout x:Name="TabButton" Spacing="12">
                    <Label Text="Button" FontAttributes="Bold" FontSize="16" />
                    <Button Text="{Binding ClickCount, StringFormat='Click Me ({0})'}"
                            Command="{Binding ClickMeCommand}"
                            BackgroundColor="#0d6efd" TextColor="White" />

                    <Label Text="Color Variants" FontAttributes="Bold" />
                    <HorizontalStackLayout Spacing="8">
                        <Button Text="Primary" BackgroundColor="#0d6efd" TextColor="White" WidthRequest="90" Clicked="OnVariantButtonClicked" />
                        <Button Text="Success" BackgroundColor="#198754" TextColor="White" WidthRequest="90" Clicked="OnVariantButtonClicked" />
                        <Button Text="Warning" BackgroundColor="#ffc107" TextColor="Black" WidthRequest="90" Clicked="OnVariantButtonClicked" />
20_SOURCES/998. DEMO/000. Sample/050. CrossUi/SampleCrossUi.Maui/Views/ControlsPage.xaml:18-30
직접 근거

DreamineCommand generated property naming rule 코드 선언

stable URI로 확인한 실제 선언 일부입니다.

return methodName + "Command";
            {
                return commandNameOverride!;
            }

            return methodName + "Command";
        }
20_SOURCES/100. Library/Generators/DreamineCommandSourceGenerator.cs:300-305
직접 근거

ControlsPage 버튼 바인딩 코드 선언

MAUI 버튼이 ClickMeCommand에 바인딩됩니다.

Command="{Binding ClickMeCommand}"

                <!-- ① Button -->
                <VerticalStackLayout x:Name="TabButton" Spacing="12">
                    <Label Text="Button" FontAttributes="Bold" FontSize="16" />
                    <Button Text="{Binding ClickCount, StringFormat='Click Me ({0})'}"
                            Command="{Binding ClickMeCommand}"
                            BackgroundColor="#0d6efd" TextColor="White" />
20_SOURCES/998. DEMO/000. Sample/050. CrossUi/SampleCrossUi.Maui/Views/ControlsPage.xaml:18-25
기술 세부정보

정규화된 질문: Dreamine으로 만든 화면에서 버튼을 눌렀을 때 실행할 코드는 어디에 작성해야 하나요?

Source · ControlsEvent.ClickMe 실제 구현 source-1 · 직접 근거 · confidence 1.00
Source · ControlsViewModel의 DreamineCommand 선언 source-2 · 직접 근거 · confidence 1.00
Source · 생성 커맨드 이름 규칙 source-3 · 직접 근거 · confidence 1.00
Source · ControlsPage 버튼 바인딩 source-4 · 직접 근거 · confidence 1.00
Source · Event 계층의 역할 설명 source-5 · 직접 근거 · confidence 1.00
Source · bindsCommand ControlsPage.ClickMeCommand trace-xaml-binding · 직접 근거 · confidence 1.00
Source · generatesCommand DreamineCommand generated property naming rule trace-generator-rule · 직접 근거 · confidence 1.00
Source · declaresCommandMethod ControlsDemoRow.ClickMe trace-viewmodel-command · 직접 근거 · confidence 1.00
Source · generatesCommand ClickMe → generatesCommand → ClickMeCommand trace-generated-command · 직접 근거 · confidence 1.00
Source · forwardsTo ControlsDemoRow.ClickMe → forwardsTo → Event.ClickMe trace-forwards-to · 직접 근거 · confidence 1.00
Source · targetMethod ControlsEvent.ClickMe trace-event-target · 직접 근거 · confidence 1.00
검색 원본
서버 저장소 소스 코드
생성 모델
codex-cli:default
생성 정책
dreamine-repository-search-v4
마지막 검증
2026-07-20 23:17:17
이 답변이 유용했나요?