Windows Phone 72010.06.15 15:47

일단 처음에 해야할것은

역시 HugeFlow dll 레퍼런스에 로드 하고 ViewModel에 을 상속받아서 쓴다.

일단 코드를 보자~

#region StartButtonCommand
       /// <summary>
       /// StartButton InstantCommand for ViewModel
       /// </summary>
       private ICommand _StartButtonCommand;
       public ICommand StartButtonCommand
       {
           get
           {
               return _StartButtonCommand;
           }
           set
           {
               _StartButtonCommand = value;
               OnPropertyChanged("StartButtonCommand");
           }
       }
 
       public void StartButton(object param)
       {
             // code here
       }
       #endregion StartButtonCommand
 
 


code snipper를 이용하면 ic 를 입력하면 instantCommand를 이용할수 있다.



그리고 생성자에



 
public RandomNumberViewModel()
       {
           StartButtonCommand = new InstantCommand<object>(StartButton);
           //StartRandomCommand = new InstantCommand<string>(StartRandom);
       }
 
 


이렇게 넣어주면 땡~



xaml에서는



 
<phoneNavigation:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone.Shell"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"    
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:HugeFlow_CommandPattern_Interactivity="clr-namespace:HugeFlow.CommandPattern.Interactivity;assembly=HugeFlow.MVVM" 
    x:Class="RanDomNumber.MainPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"    
    x:Name="phoneApplicationPage" 
    DataContext="{Binding RandomNumberViewModel, Source={StaticResource ServiceLocator}}"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}">
    <i:Interaction.Behaviors>
        <HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior x:Name="StartButtonCommand" Command="{Binding StartButtonCommand}">
            <i:Interaction.Triggers>
                <i:EventTrigger SourceName="TestButton" EventName="Click">
                    <i:InvokeCommandAction CommandName="CommandTriggers"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior>
    </i:Interaction.Behaviors>
 
 


보면 알겟지만



xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:HugeFlow_CommandPattern_Interactivity="clr-namespace:HugeFlow.CommandPattern.Interactivity;assembly=HugeFlow.MVVM"



를 추가하고



블랜드를 이용하여



<i:Interaction.Behaviors>

        <HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior x:Name="StartButtonCommand" Command="{Binding StartButtonCommand}">


            <i:Interaction.Triggers>


                <i:EventTrigger SourceName="TestButton" EventName="Click">


                    <i:InvokeCommandAction CommandName="CommandTriggers"/>


                </i:EventTrigger>


            </i:Interaction.Triggers>


        </HugeFlow_CommandPattern_Interactivity:ExecuteInstantCommandBehavior>


    </i:Interaction.Behaviors>



이 구문을 만들었다 블랜드를 이용해서 만드는 방법을 알아보자~



silverlight 4 rc 버전을 이용했다(정식버전은 아직 지원안됨 이것떄문에 지웠다 다시깜 ㅠㅠ)



""



 



그냥 간단하게 보자



위에서부터 Asset-ExucteInstantCommand-그리고 커맨드가 생기면 커맨드 클릭한후 event trriger 등록 하고 숨겨진창을



클릭하여 SourceName을 선택한후  마우스로 컨트롤을 선택하고 Command에 가서 icommand 가 있는 메소드를 선택하면 된다.



마지막으로 x:name 즉 이름 넣는곳에 알기 쉽게 아까 만든거와 같은 커맨드 네이밍을 입력하자



여기서는 StartButtonCommand~

Posted by 동동(이재동)
TAG