CurrentChangingEventHandler 대리자

정의

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

[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.Guid(1026201821, 38323, 24533, 147, 180, 161, 162, 89, 159, 34, 92)]
public delegate void CurrentChangingEventHandler(object sender, CurrentChangingEventArgs e);
Public Delegate Sub CurrentChangingEventHandler(sender As Object, e As CurrentChangingEventArgs)

매개 변수

sender
Object

이벤트 소스입니다.

e
CurrentChangingEventArgs

이벤트 데이터입니다.

특성

예제

다음 코드 예제에서는 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로 설정하면 예외가 발생합니다.

적용 대상

추가 정보