Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
7f40b71
Improved performance when selecting multiple items
Jul 21, 2014
4bc2adb
Add ListView to Demo and extract the functional part out to a separat…
Nov 14, 2014
6720bcb
Inline code tidy and deimplicitise
Nov 14, 2014
14d5987
StyleCop corrections.
Nov 14, 2014
d975c8d
Update README.md, add icon and update nuspec to point to it.
9swampy Nov 15, 2014
7531c58
Add a little starting point thread safety and test coverage for Multi…
9swampy Nov 16, 2014
f48d154
Switch from internal to public FluentAssertions
9swampy Nov 16, 2014
ecf6920
Whitespace
9swampy Nov 16, 2014
16fb6bf
Whitespace
9swampy Nov 16, 2014
e769d4e
Add NextVersion.txt attempting to set up GitVersion
9swampy Nov 16, 2014
8361a06
Add a fixed version of GitVersion as a lib entry.
9swampy Nov 16, 2014
963e634
Update .nuspec
9swampy Nov 16, 2014
4c6b8a8
Add try/catch throw blocks to TwoListSynchronizer - only aiding debug…
9swampy Nov 17, 2014
395018e
Adds working example/prototype OneWayToSource Calendar synchronizer.
9swampy Nov 18, 2014
7760eda
Update Nuspec to improve description and license linkage, add example…
9swampy Nov 30, 2014
6945497
Added .NET45 library
Nimgoble Sep 25, 2015
52a355f
Merge pull request #1 from Nimgoble/SelectedItemsSynchronizer
9swampy Sep 26, 2015
50bacfd
Tidy, add links to common Net45 code instead of copying, fix referenc…
9swampy Sep 26, 2015
40b3a03
Merge branch 'SelectedItemsSynchronizer'
9swampy Sep 26, 2015
61a16e2
Add CI and NuGet badges
9swampy Oct 25, 2015
2fb0dd2
Merge pull request #2 from 9swampy/hotfix/AddBadges
9swampy Oct 25, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions IListItemConverter.cs

This file was deleted.

24 changes: 0 additions & 24 deletions LICENSE

This file was deleted.

9 changes: 9 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) SelectedItemsSynchronizer contributors. (SelectedItemsSynchronizer@prims.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
134 changes: 0 additions & 134 deletions MultiSelectorBehaviours.cs

This file was deleted.

1 change: 1 addition & 0 deletions NextVersion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.0
Binary file added Psync.xcf
Binary file not shown.
Binary file added Psync128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Psync256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,101 @@
[![][build-img]][build]
[![][nuget-img]][nuget]

[build]: https://ci.appveyor.com/project/9swampy/selecteditemsbindingdemo
[build-img]: https://ci.appveyor.com/api/projects/status/aa8mw3opmlyxc68u?svg=true

[nuget]: https://badge.fury.io/nu/SelectedItemsSynchronizer
[nuget-img]: https://badge.fury.io/nu/SelectedItemsSynchronizer.svg

SelectedItemsBindingDemo
========================

An example of how to bind the SelectedItems property of an ItemsControl in WPF to a ViewModel

The origin of all this and a good explanation of how it all works can be found at
http://blog.functionalfun.net/2009/02/how-to-databind-to-selecteditems.html

The original example demo is still included in the code base, but the code has been reorganised a bit so that it can be published as a utility library in a NuGet package. I'm hoping you'll find it as useful as I have done, and making it available as a NuGet package should ease integration with your production code!

Example usage
-------------
```C#
List<string> names;
ObservableCollection<string> selectedNames;
ListView listView;

[TestInitialize]
public void TestInitialize()
{
names = new List<string>() { "Abraham", "Lincoln", "James", "Buchanan" };
selectedNames = new ObservableCollection<string>();
listView = new ListView();
listView.ItemsSource = names;
listView.SelectionMode = SelectionMode.Extended;
MultiSelectorBehaviours.SetSynchronizedSelectedItems(listView, (IList)selectedNames);
}

[TestMethod]
public void InitialiseToNoSelection()
{
this.selectedNames.Count().Should().Be(0);
}

[TestMethod]
public void ShouldSynchroniseListViewSelectAll()
{
// Act
this.listView.SelectAll();

// Assert
this.selectedNames.Count().Should().Be(this.names.Count());
}

[TestMethod]
public void ShouldSynchroniseListViewSetSelectedIndex()
{
// Act
this.listView.SelectedIndex = 0;

// Assert
this.selectedNames.Count().Should().Be(1);
}

[TestMethod]
public void ShouldSynchroniseListViewSetSelectedItem()
{
//Arrange
Random random = new Random(DateTime.Now.Millisecond);
object itemToSelect = this.listView.Items.GetItemAt(random.Next(this.names.Count));

// Act
this.listView.SelectedItem = itemToSelect;

// Assert
this.selectedNames.Count().Should().Be(1);
}

[TestMethod]
public void ShouldSynchroniseListViewAddSingleSelectedItem()
{
//Arrange
Random random = new Random(DateTime.Now.Millisecond);
object itemToSelect = this.listView.Items.GetItemAt(random.Next(this.names.Count));

// Act
this.listView.SelectedItems.Add(itemToSelect);

// Assert
this.selectedNames.Count().Should().Be(1);
}

[TestMethod]
public void ShouldSynchroniseListViewAddMultipleSelectedItems()
{
// Act
this.listView.SelectedItems.Add(this.listView.Items.GetItemAt(0));
this.listView.SelectedItems.Add(this.listView.Items.GetItemAt(1));

// Assert
this.selectedNames.ShouldBeEquivalentTo(this.listView.SelectedItems, opt => opt.WithStrictOrdering());
}
20 changes: 0 additions & 20 deletions SelectedItemsBindingDemo.sln

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading