CurrentChangingEventArgs class

Applies to Windows and Windows Phone

Provides data for the CurrentChanging event.

Inheritance

Object
  CurrentChangingEventArgs

Syntax


public class CurrentChangingEventArgs

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The CurrentChangingEventArgs class has these types of members:

Constructors

The CurrentChangingEventArgs class has these constructors.

ConstructorDescription
CurrentChangingEventArgs() Initializes a new instance of the CurrentChangingEventArgs class.
CurrentChangingEventArgs(Boolean) Initializes a new instance of the CurrentChangingEventArgs class.

 

Methods

The CurrentChangingEventArgs class inherits methods from the Object class.

Properties

The CurrentChangingEventArgs class has these properties.

PropertyAccess typeDescription

Cancel

Read/writeGets or sets a value that indicates whether the CurrentItem change should be canceled.

IsCancelable

Read-onlyGets a value that indicates whether the CurrentItem change can be canceled.

 

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.

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


Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Data
Windows::UI::Xaml::Data [C++]

Metadata

Windows.winmd

See also

XAML data binding sample
Data binding overview

 

 

Show:
© 2014 Microsoft