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

In Dreamine, where should I write the code that runs when a button is clicked, and how is it connected to the XAML button?

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

Put the button’s actual behavior in `SampleCrossUi.Shared/ViewModels/ControlsEvent.cs`, in `ControlsEvent.ClickMe()`. In the ViewModel, declare a `[DreamineCommand("Event.ClickMe")]` partial method; bind the XAML button’s `Command` to the generated `ClickMeCommand`.

EVIDENCE COVERAGE

실행 경로 검증

완전 검증

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

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

핵심 코드 근거

직접 근거

ClickMe source declaration

DreamineCommand generation maps ClickMe to ClickMeCommand.

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

ControlsDemoRow.ClickMe source declaration

The ViewModel method is marked with DreamineCommand for ClickMeCommand.

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

ControlsDemoRow.ClickMe source declaration

The DreamineCommand declaration forwards execution to Event.ClickMe.

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

ControlsEvent.ClickMe source declaration

This Event target method contains the actual operation reached by the command.

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

    // ── RadioButton ───────────────────────────────────────
    /// <summary>
    /// \if KO
    /// <para>Selected Radio 값을 가져오거나 설정합니다.</para>
    /// \endif
20_SOURCES/998. DEMO/000. Sample/050. CrossUi/SampleCrossUi.Shared/ViewModels/ControlsEvent.cs:77-88
직접 근거

ControlsPage.ClickMeCommand source declaration

XAML binds the control Command to 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" />

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

The source generator appends Command to the annotated method name.

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

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

MAUI button command binding source declaration

The Click Me button binds its `Command` property to `ClickMeCommand`.

Command="{Binding ClickMeCommand}"
                    <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:21-25

추가 설명

3. XAML connection

Bind the button’s `Command` property to the generated property: ```xml <Button Text="{Binding ClickCount, StringFormat='Click Me ({0})'}" Command="{Binding ClickMeCommand}" /> ``` With the page’s binding context set to `ControlsViewModel`, clicking the button invokes that command.

확인되지 않은 내용

  • The supplied excerpts do not include the generated forwarding body represented by `ControlsDemoRow.ClickMe`; only the complete evidence-chain metadata, ViewModel target declaration, naming rule, XAML binding, and final target implementation are available.
기술 세부정보

정규화된 질문: In Dreamine, where should I write the code that runs when a button is clicked, and how is it connected to the XAML button?

Source · ControlsEvent.ClickMe implementation source-1 · 직접 근거 · confidence 1.00
Source · ControlsViewModel command declaration source-2 · 직접 근거 · confidence 1.00
Source · Dreamine command naming rule source-3 · 직접 근거 · confidence 1.00
Source · MAUI button command binding source-4 · 직접 근거 · 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:47:56
이 답변이 유용했나요?