wpf world가 새로 생겼습니다. 메뉴 항목 유형 System.Type
의 MainViewType
이라는 속성을 가지고있는 모듈의 itemssource AppModules
에서프리즘이있는 mvvm : 메뉴 항목에서보기 설정
<ContextMenu>
<MenuItem Header="Login"
Command="{Binding WorkSpaceViewSetter}" CommandParameter="DemoApplication.View.LoginView">
<MenuItem.Icon>
<Image Height="16" Width="16" Stretch="Uniform" Source="/Images/login.png"/>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Modules" ItemsSource="{Binding AppModules}">
<MenuItem.Icon>
<Image Source="/Images/modules.png"/>
</MenuItem.Icon>
<MenuItem.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header" Value="{Binding ModuleName}"/>
<Setter Property="Command" Value="{Binding ElementName=win, Path=DataContext.WorkSpaceViewFromType}"/>
<Setter Property="CommandParameter" Value="{Binding MainViewType}"/>
</Style>
</MenuItem.ItemContainerStyle>
</MenuItem>
</ContextMenu>
각 요소 : 나는 다음과 같이 셸에서 상황에 맞는 메뉴가 있습니다. menuitem이 클릭되었을 때 에서 하나의 ICommad
을 사용하고 MainViewType
을 명령 매개 변수로 사용하여 생각하고있는 지역의보기를 변경하고 싶습니다. 그러나 위 코드는 작동하지 않습니다. Modules
menuitem이 itemssource
에서 예상대로 채워진 이유가 궁금합니다.
속성이 Modules
에 제대로 묶여 있으므로 Login
menuitem의 명령 바인딩이 작동하지 않는 것으로 나타났습니다. 아무도 그것을 작동하게하는 방법을 제안 할 수 있습니까?
ICommand의 실행 모습은 어떻습니까? –
Microsoft.Practices.Prism.Commands의 DelegateCommand을 사용하고 있습니다. –