CurrentChangingEventHandler 대리자

정의

ICollectionView 구현의 CurrentChanging 이벤트를 처리할 수 있는 메서드를 나타냅니다.

[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(4085812664, 5023, 19918, 141, 201, 247, 241, 68, 77, 17, 133)]
public delegate void CurrentChangingEventHandler(object sender, CurrentChangingEventArgs e);

매개 변수

sender
Object

이벤트 소스입니다.

e
CurrentChangingEventArgs

이벤트 데이터입니다.

특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

다음 코드 예제에서는 CurrentChanging 이벤트를 처리하는 방법을 보여 줍니다. 이 예제에서 XAML은 CollectionViewSource에 바인딩된 GridView가 있는 페이지의 콘텐츠를 표시합니다. 코드 숨김은 Source를 설정하고 CurrentChanging 이벤트 처리기를 연결하기 위해 해당 뷰를 검색하는 것을 포함하는 CollectionViewSource 초기화를 보여줍니다.

<Page.Resources>
  <CollectionViewSource x:Name="cvs" />
  <DataTemplate x:Key="myDataTemplate">
    <Border Background="#FF939598" Width="200" Height="200">
      <TextBlock Text="{Binding Path=Name}" />
    </Border>
  </DataTemplate>
</Page.Resources>

<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
  <GridView x:Name="PicturesGrid" 
    SelectionMode="Single" CanReorderItems="False" CanDragItems="False"
    ItemsSource="{Binding Source={StaticResource cvs}}"                
    ItemTemplate="{StaticResource myDataTemplate}" >
    <GridView.ItemsPanel>
      <ItemsPanelTemplate>
        <WrapGrid VerticalChildrenAlignment="Top" 
          HorizontalChildrenAlignment="Left" />
      </ItemsPanelTemplate>
    </GridView.ItemsPanel>
  </GridView>
</Grid>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    var library = Windows.Storage.KnownFolders.PicturesLibrary;
    var queryOptions = new Windows.Storage.Search.QueryOptions();
    queryOptions.FolderDepth = Windows.Storage.Search.FolderDepth.Deep;
    queryOptions.IndexerOption = 
        Windows.Storage.Search.IndexerOption.UseIndexerWhenAvailable;

    var fileQuery = library.CreateFileQueryWithOptions(queryOptions);

    var fif = new Windows.Storage.BulkAccess.FileInformationFactory(
        fileQuery, 
        Windows.Storage.FileProperties.ThumbnailMode.PicturesView, 190, 
        Windows.Storage.FileProperties.ThumbnailOptions.UseCurrentScale, 
        false);

    var dataSource = fif.GetVirtualizedFilesVector();
    cvs.Source = dataSource;
    cvs.View.CurrentChanging += View_CurrentChanging;
}

private void View_CurrentChanging(object sender, CurrentChangingEventArgs e)
{
    Debug.WriteLine("Cancel = " + e.Cancel);
    Debug.WriteLine("IsCancelable = " + e.IsCancelable);
    if (e.IsCancelable == true)
    {
        // Cancel the change. The previously selected item remains selected.
        e.Cancel = true;
    }
}

설명

ICollectionView.CurrentChanging 이벤트는 CurrentItem 속성 값이 변경되면 발생합니다. 이벤트 처리기에 전달된 CurrentChangingEventArgs 매개 변수는 변경에 대한 정보를 지정합니다.

IsCancelabletrue이면 이벤트 처리기는 취소를 true로 설정하여 변경 사항을 취소할 수 있습니다. 변경 내용이 취소되면 CurrentItem 이 변경되지 않습니다. IsCancelablefalse이면 Canceltrue로 설정하면 예외가 발생합니다.

적용 대상

제품 버전
WinRT Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100

추가 정보