CurrentChangingEventArgs CurrentChangingEventArgs CurrentChangingEventArgs CurrentChangingEventArgs Class

Definition

Provides data for the CurrentChanging event.

public : class CurrentChangingEventArgs : ICurrentChangingEventArgspublic class CurrentChangingEventArgs : ICurrentChangingEventArgsPublic Class CurrentChangingEventArgs Implements ICurrentChangingEventArgs// This API is not available in Javascript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following code example demonstrates how to handle the CurrentChanging event. In this example, the XAML shows the content of a page with a GridView bound to a CollectionViewSource. The code-behind shows the CollectionViewSource initialization, which includes setting its Source and retrieving its View in order to attach the CurrentChanging event handler.

<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;
    }
}

Remarks

The CurrentChanging event occurs when the CurrentItem property value changes in an ICollectionView implementation. The ICollectionView implementation uses the CurrentChangingEventArgs constructor to specify whether you can cancel the CurrentItem change in a CurrentChanging event handler. If the IsCancelable property value is true, you can cancel the CurrentItem change by setting the Cancel property to true. Otherwise, you cannot cancel the CurrentItem change.

Constructors

CurrentChangingEventArgs() CurrentChangingEventArgs() CurrentChangingEventArgs() CurrentChangingEventArgs()

Initializes a new instance of the CurrentChangingEventArgs class.

public : CurrentChangingEventArgs()public CurrentChangingEventArgs()Public Sub New()// This API is not available in Javascript.
See Also

CurrentChangingEventArgs(Boolean) CurrentChangingEventArgs(Boolean) CurrentChangingEventArgs(Boolean) CurrentChangingEventArgs(Boolean)

Initializes a new instance of the CurrentChangingEventArgs class.

public : CurrentChangingEventArgs(bool isCancelable)public CurrentChangingEventArgs(Boolean isCancelable)Public Sub New(isCancelable As Boolean)// This API is not available in Javascript.
Parameters
isCancelable
bool Boolean Boolean Boolean

true to disable the ability to cancel a CurrentItem change; false to enable cancellation.

Properties

Cancel Cancel Cancel Cancel

Gets or sets a value that indicates whether the CurrentItem change should be canceled.

public : PlatForm::Boolean Cancel { get; set; }public bool Cancel { get; set; }Public ReadWrite Property Cancel As bool// This API is not available in Javascript.
Value
PlatForm::Boolean bool bool bool

true if the event should be canceled; otherwise, false. The default is false.

Remarks

If the IsCancelable property value is false, setting the Cancel property to true will throw an InvalidOperationException.

IsCancelable IsCancelable IsCancelable IsCancelable

Gets a value that indicates whether the CurrentItem change can be canceled.

public : PlatForm::Boolean IsCancelable { get; }public bool IsCancelable { get; }Public ReadOnly Property IsCancelable As bool// This API is not available in Javascript.
Value
PlatForm::Boolean bool bool bool

true if the event can be canceled; false if the event cannot be canceled.

Remarks

If the IsCancelable property value is false, setting the Cancel property to true will throw an InvalidOperationException.

See Also