XAML/C#을 사용하는 Windows Phone 8 응용 프로그램이 있습니다. 내 앱에는 데이터 템플릿을 사용하는 ItemsControl
이 있습니다. 내 DataTemplate
처럼 보이는 다음Windows Phone 컨텍스트 메뉴 항목 텍스트가 나타나지 않습니다.
DataTemplate
내 XAML의 주요 부분에서 참조
<DataTemplate x:Key="myTemplate">
<Grid Margin="0,0,0,8">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding DisplayName}" TextWrapping="NoWrap" Style="{StaticResource PhoneTextLargeStyle}" TextTrimming="WordEllipsis" >
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu>
<toolkit:MenuItem x:Name="customerMenuItem" Foreground="White" Header="View Customer Profile" Click="customerMenuItem_Click" Tag="{Binding Path=CustomerName}" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</TextBlock>
<TextBlock Text="{Binding Summary}" TextWrapping="NoWrap" Grid.Row="1" Style="{StaticResource PhoneTextSmallStyle}" />
</Grid>
<StackPanel Orientation="Horizontal" Grid.Column="1"><!-- Stuff here --></StackPanel>
</Grid>
</DataTemplate>
:
<Grid x:Name="ContentPanel" Grid.Row="1" Grid.ColumnSpan="2" Margin="12,0,12,0">
<ScrollViewer>
<ItemsControl x:Name="myItemsControl" ItemTemplate="{StaticResource myTemplate}" ItemsSource="{Binding Customers}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
</Grid>
주의 사항은의 "툴킷"네임 스페이스는 CLR-네임 스페이스에서 온다 : Microsoft.Phone.Controls; assembly = Microsoft.Phone.Controls.Toolkit. 손가락 (또는 마우스)을 TextBlock
에 붙이면 상황에 맞는 메뉴가 나타납니다. 그러나 나는 "고객 프로필보기"라는 단어를 보지 못합니다. 컨텍스트 메뉴 자체를 나타내는 블록 상자가 나타납니다. 나는 품목이 거기다는 것을 알고있다. customerMenuItem_Click
이벤트가 성공적으로 실행 되었기 때문에 알았습니다. 거기에 MessageBox
태그 값을 보여줍니다. 그 값은 항상 정확합니다. 어떤 이유로 메뉴 항목 텍스트가 나타나지 않습니다. 내가 도대체 뭘 잘못하고있는 겁니까?