ObservableView 3.0.16-pre

This is a prerelease version of ObservableView.
dotnet add package ObservableView --version 3.0.16-pre
                    
NuGet\Install-Package ObservableView -Version 3.0.16-pre
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ObservableView" Version="3.0.16-pre" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ObservableView" Version="3.0.16-pre" />
                    
Directory.Packages.props
<PackageReference Include="ObservableView" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ObservableView --version 3.0.16-pre
                    
#r "nuget: ObservableView, 3.0.16-pre"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ObservableView&version=3.0.16-pre&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=ObservableView&version=3.0.16-pre&prerelease
                    
Install as a Cake Tool

ObservableView

Version Downloads Buy Me a Coffee

ObservableView is a simple wrapper for collections which provides an easy-to-use API for searching, filtering, sorting and grouping of collections. This project enhances the well-known ObservableCollection of the .Net Framework with addition, commonly-used features. The goal is to have a Swiss army knife of a collection utility which provides an easy-to-use but very powerful API while preserving maximum platform compatibility.

Download and Install ObservableView

This library is available on NuGet: https://www.nuget.org/packages/ObservableView/ Use the following command to install ObservableView using NuGet package manager console:

PM> Install-Package ObservableView

You can use this library in any .NET project which is compatible to .NET Standard 2.0 and higher.

API Usage

Basic MVVM data binding with List Views

The usage of ObservableView<T> is not much different from ObservableCollection<T>:

  1. Create a public ObservableView<T> property in your ViewModel.
public ObservableView<Mall> MallList { get; }
  1. Fill the ObservableView<T>.Source with item view models.
public MallListViewModel(IMallService mallService)
{
	var allMalls = mallService.GetAllMalls();
	this.MallList = new ObservableView<Mall>(allMalls);
}
  1. Create a View with a ListView (or any other collection control) and bind the items source to ObservableView<T>.View.
<ListView ItemsSource="{Binding MallList.View}">
	<ListView.View>
		<GridView>
			
			<GridViewColumn Header="Title" Width="Auto">
				<GridViewColumn.CellTemplate>
					<DataTemplate>
						<TextBlock Text="{Binding Title}" />
					</DataTemplate>
				</GridViewColumn.CellTemplate>
			</GridViewColumn>

			
			<GridViewColumn Header="Subtitle" Width="Auto">
				<GridViewColumn.CellTemplate>
					<DataTemplate>
						<TextBlock Text="{Binding Subtitle}" />
					</DataTemplate>
				</GridViewColumn.CellTemplate>
			</GridViewColumn>
		</GridView>
	</ListView.View>
</ListView>

As you can observe in the example above, the XAML view binds to MallList.View. This is important in order to reflect operation (search, filter, group...) performed on the source collection.

Add, remove, update source collection

If you need to add or remove items of the source collection, you can simply do so by manipulating the MallList.Source property. By doing so, it automatically refreshes all dependent properties (e.g. View).

Two steps are necessary in order to enable the search functionality:

  1. Define search specification(s) for properties of your collection item type T:
  • Call SearchSpecification.Add for searchable properties:
this.MallsList.SearchSpecification.Add(x => x.Title, BinaryOperator.Contains);
this.MallsList.SearchSpecification.Add(x => x.Subtitle, BinaryOperator.Contains);
  • Alternative: Annotate searchable properties with [Searchable]
  1. The search operation can be triggered either from within the ViewModel using ObservableView.Search(...) method or by binding ObservableView.SearchText in XAML to an input textbox.
Filtering
  1. Subscribe FilterHandler event:
this.MallsList.FilterHandler += this.MallsList_FilterHandler;
  1. Specify with each collection item if it is filtered or not:
private void MallsList_FilterHandler(object sender, ObservableView.Filtering.FilterEventArgs<Mall> e)
{
	if (e.Item.Title.Contains("Aber"))
	{
		e.IsAllowed = false;
	}
}
Sorting

There are many ways of how collections can be presented with defined sort orders. Method AddOrderSpecification can be used to set-up sort specifications for properties of type T.

this.MallsList.AddOrderSpecification(x => x.Title, OrderDirection.Ascending);
this.MallsList.AddOrderSpecification(x => x.Subtitle, OrderDirection.Descending);

In the XAML, we could either bind the ItemsSource property to MallsList.View or we can use the attached dependency property ObservableViewExtensions.ObservableView to bind MallsList directly to the DataGrid. The latter approach enables you to make use of multi-column sorting using the DataGrid headers.

<DataGrid netfx:ObservableViewExtensions.ObservableView="{Binding MallsList}"
		  AutoGenerateColumns="False">
	<DataGrid.Columns>
		<DataGridTextColumn Binding="{Binding Title}" Header="Title" CanUserSort="True" SortMemberPath="Title"/>
		<DataGridTextColumn Binding="{Binding Subtitle}" Header="Subtitle" CanUserSort="True" SortMemberPath="Subtitle"/>
	</DataGrid.Columns>
</DataGrid>

TODO: Describe how to use IComparer with custom column sort algorithms.

Grouping

ObservableView allows to specify a grouping algorithm as well as the key by which the collection is grouped:

this.MallsList.GroupKeyAlogrithm = new AlphaGroupKeyAlgorithm();
this.MallsList.GroupKey = mall => mall.Title;

Performance considerations

Performance is a critical success factor for ObservableView. ObservableView has been tested with ten thousands of data records with good results. If you run into performance bottlenecks caused by ObservableView, do not hesitate to open a new issue.

Contribution

Contributors welcome! If you find a bug or you want to propose a new feature, feel free to do so by opening a new issue on github.com.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.16-pre 135 6/2/2025
3.0.11-pre 177 3/29/2024
2.2.19286.1-pre 643 10/13/2019
2.2.19284.6 36,368 10/11/2019
2.2.19284.4-pre 510 10/11/2019
2.2.19284.2-pre 518 10/11/2019
2.2.19284.1-pre 510 10/11/2019
2.1.19284.6-pre 486 10/11/2019
2.1.19283.4-pre 473 10/10/2019
2.1.19182.1-pre 775 7/1/2019
2.1.19179.1-pre 516 6/28/2019
2.1.19178.2-pre 507 6/27/2019
2.1.19176.12-pre 528 6/26/2019
2.1.19176.4-pre 527 6/25/2019
2.0.18348.1-pre 631 12/14/2018
1.1.0-pre3 1,143 9/23/2017
1.1.0-pre2 925 9/23/2017
1.1.0-pre1 929 9/23/2017
1.0.3-pre1 691 11/18/2018
1.0.2-pre6 1,884 2/3/2016
1.0.2-pre5 1,023 2/2/2016
1.0.2-pre4 1,303 12/25/2015
1.0.2-pre3 1,110 12/22/2015
1.0.2-pre2 1,072 12/19/2015
1.0.2-pre1 1,081 12/18/2015
1.0.1 1,451 12/13/2015
1.0.0 1,237 12/11/2015
1.0.0-beta3 1,209 12/11/2015
1.0.0-beta2 1,246 12/11/2015
1.0.0-beta1 1,233 12/11/2015
1.0.0-alpha3 1,221 12/11/2015
1.0.0-alpha2 1,013 12/11/2015
1.0.0-alpha1 1,019 12/11/2015

3.0.0
- Drop support for .NET framework
- Drop support for Xamarin

2.0.0
- Support for .Net Standard 2.0

1.1.0-pre1
- Complete overwork of the search API
- Added custom SearchTextDelimiters
- Added SearchTextPreprocessor
- Added configurable SearchTextLogic (AND, OR)

1.0.2
- Bug fix: Sorting in WPF DataGrid headers not reflected correctly
- Bug fix: Sorting not updated on View property refresh

1.0.1
- Initial release