0

다음 목록 상자가있는 Windows Phone 7 응용 프로그램이 있으며 모든 항목에 2 개의 텍스트 블록과 하이퍼 링크 버튼이 있습니다. 나는 다음과 같은 코드를 가지고있는 ViewModel 생성자에서 Windows Phone 및 Silverlight ListBox.ItemTemplate

<ListBox.ItemTemplate><DataTemplate><StackPanel Orientation="Vertical"> 
          <TextBlock/> 
          <TextBlock/> 
          <HyperlinkButton Content="[More...]" FontSize="12"HorizontalAlignment="Right" Height="30" Click="ClickEvent"> 
           <i:Interaction.Triggers> 
            <i:EventTrigger EventName="Click"<GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding GetCommand, Mode=OneWay}"/> 
            </i:EventTrigger> 
           </i:Interaction.Triggers> 
          </HyperlinkButton> 
         </StackPanel> 
       </DataTemplate> 
      </ListBox.ItemTemplate> 

:

GetCommand = new RelayCommand(() =>{some code}); where GetCommand is a property : 

public RelayCommand GetCommand { get; private set; } 

내 문제는 내가 버튼을 누를 때 GetCommand = new RelayCommand(() =>{some code});가 실행되지 않는 것입니다.

HyperlinkButton을 itemTemplate에 포함시키지 않으면 모든 것이 잘 동작한다고 말해야합니다. Galasoft mvvm light tookit을 사용합니다. - http://www.galasoft.ch/mvvm/getstarted/ 도움이되었습니다. 나는 당신이 당신의 XAML에 오타가 추측하고

+1

그런 빠른 질문에서 비슷한 질문을하지 마십시오. 추가 세부 사항으로 원래 질문을 편집하십시오. 같은 주제로 다른 질문 삭제하기 – AnthonyWJones

답변

0

, 읽어야합니다 -

<i:Interaction.Triggers> 
    <i:EventTrigger EventName="Click"> 
     <GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding GetCommand, Mode=OneWay}"/> 
    </i:EventTrigger> 
</i:Interaction.Triggers> 

바인딩 표현에서 Mode=OneWay을 제거한 후 코드를 사용해보십시오.

HTH, indyfromoz

관련 문제