2012-05-21 4 views
0

라이브러리 컨트롤이 포함 된 분산 뷰를 사용하고있는 경우. 사용자는 요소를 라이브러리 컨테이너에서 스 캐터 뷰로 끌 수 있습니다. 그 후 사용자는 이미지를 제거 할 수 있습니다.분산 제거보기 항목

뷰 템플릿 내의 표면 버튼과 이미지가 드래그 템플릿으로 포함 된 스타일을 만들었습니다.

표면 버튼의 클릭 기능에 문제가 있습니까? 이미지를 지우려면 어떻게해야합니까?

답변

0

전체 ScatterViewItem 또는 이미지 만 제거하고 단추를 유지 하시겠습니까?

/// <summary> 
    /// Attempts to get an ancestor of the passed-in element with the given type. 
    /// </summary> 
    /// <typeparam name="T">Type of ancestor to search for.</typeparam> 
    /// <param name="descendent">Element whose ancestor to find.</param> 
    /// <param name="ancestor">Returned ancestor or null if none found.</param> 
    /// <returns>True if found, false otherwise.</returns> 
    public static T GetVisualAncestor<T>(DependencyObject descendent) where T : class 
    { 
     T ancestor = null; 
     DependencyObject scan = descendent; 
     ancestor = null; 

     while (scan != null && ((ancestor = scan as T) == null)) 
     { 
      scan = VisualTreeHelper.GetParent(scan); 
     } 

     return ancestor; 
    } 

은 다음 항목 수집에서 SVI를 제거 할 수 있습니다 :이 방법은 Visual 조상을 찾아 ScatterViewItems을 제거 일반적으로 ancestor.items.remove (하위);