2014-10-14 1 views

답변

0

가능한 해결책은 다음과 같습니다. 당신이해야합니다 XAML에서

public class Item 
{ 
    public string Info { get; set; } 
    // Menu attached or not 
    public bool OptionsEnabled { get; set; } 
} 

는 apropriate ItemTelplate의 ListView (또는 목록 상자)를 정의하기 :

<ListView Name="myList" Holding="myList_Holding"> 
    <ListView.ItemTemplate> 
     <DataTemplate> 
      <TextBlock Text="{Binding Info}" FontSize="24" Margin="7"> 
        <FlyoutBase.AttachedFlyout> 
        <MenuFlyout> 
         <MenuFlyoutItem Text="First option"/> 
         <MenuFlyoutItem Text="Second option"/> 
        </MenuFlyout>          
        </FlyoutBase.AttachedFlyout> 
      </TextBlock> 
     </DataTemplate> 
    </ListView.ItemTemplate> 
</ListView> 

을 다음 에 팝업에 대한 정보와 함께 항목의 클래스를 정의 개최 이벤트OptionsEnabled 속성을 선택하여 메뉴를 표시 할 수 있습니다. 그렇다면 다음과 같이하십시오.

private void myList_Holding(object sender, HoldingRoutedEventArgs e) 
{ 
    if (e.OriginalSource == null || !(e.OriginalSource is TextBlock)) return; 
    TextBlock listItem = e.OriginalSource as TextBlock; 
    if (listItem.DataContext == null) return; 
    Item itemData = listItem.DataContext as Item; 
    if (itemData.OptionsEnabled) 
     FlyoutBase.ShowAttachedFlyout(listItem); 
} 

download here 일할 수있는 샘플.

관련 문제