-
-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WinForms IBindingList Collection Support #182
Comments
@RolandPheasant You should actually be able to make a |
Hi, I agree this needs adding to the lib. In the meantime there is a sample implementation which you can copy into your project binding list example |
The example in the link is for a list, not a cache. I will ensure both list and cache are supported. Also I will post a cache example later so you can test it before release. |
I have added What I have not done is to support Also the suggestion by @glennawatson to create a read-only binding list and bind using an out param is not implemented. I will probably do it in the near future. @bchavez since this is new functionality I could deploy to Nuget without breaking any code so I will do this very soon. However it would be good if you can download the packages from here AppVeyor Build v99.99.99.2523-branches and test first |
@bchavez I've merge it in, so you need to download v6.7.0 from the AppVeyor artefacts |
Hey @RolandPheasant , I think it works! Thanks again so much for your help @RolandPheasant and @glennawatson . Such amazing work! I really appreciate it. BTW, here is my public class Account
{
public int Id { get; set; }
public string Name { get; set; }
public string Number { get; set; }
}
public class MainViewModel : ReactiveObject
{
public MainViewModel()
{
this.Accounts = new BindingList<Account>();
this.AccountCache = new SourceCache<Account, int>(f => f.Id);
this.AccountCache.Connect()
.Bind(this.Accounts)
.Subscribe();
var hasAccounts = this.AccountCache.CountChanged
.Select(x => x > 0);
this.AddAccount = ReactiveCommand2.Create(AddAccountImpl, Observable.Return(true));
this.RemoveAccount = ReactiveCommand2.Create(RemoveAccountImpl, hasAccounts);
}
private Account selectedAccount;
public Account SelectedAccount
{
get => selectedAccount;
set => this.RaiseAndSetIfChanged(ref selectedAccount, value);
}
public ReactiveCommand2<Unit, Unit> AddAccount { get; }
public ReactiveCommand2<Unit, Unit> RemoveAccount { get; }
public BindingList<Account> Accounts { get; }
public SourceCache<Account, int> AccountCache { get; }
private void RemoveAccountImpl()
{
if( this.selectedAccount != null )
this.AccountCache.Remove(this.selectedAccount);
}
private int nextId = 0;
private void AddAccountImpl()
{
var id = nextId++;
var a = new Account
{
Id = id,
Name = $"Account {id}",
Number = "12345"
};
this.AccountCache.AddOrUpdate(a);
}
} I hope I'm using the new |
That's great to see. I will deploy it now. Are you on slack? There is an active community with channels for Rx, RxUI and DynamicData. It is a great place to ask questions Link to join slack |
On second thoughts it is late here and I need to update the release notes before I deploy. Will do it in the next couple days. |
@RolandPheasant , yep! Just joined slack yesterday my username is @bchavez. It was @glennawatson on slack who suggested I raise the issue about Again, thanks for all the help and support! ❤️ I have a long road ahead to learn all the ins and outs, but this |
Feel free to ask any questions and report any issues |
Fixed by PR #183 |
Hello,
ReactiveUI has deprecated
ReactiveBindingList<T>
which had support forIBindingList
. The obsolete message reads:So I searched here for any type that implements
IBindingList
and couldn't find anything. Effectively, without some type implementingIBindingList
there doesn't seem to be a story for binding collections to WinForms controls such as aListBox
.I think what we need is a type similar to WPF's
ObservableCollectionExtended<T>
, but for WinForms likeObservableBindingListExtended<T>
that implementsIBindingList
(orBindingList<T>
) that can be used similar to:Let me know your thoughts.
Thanks,
Brian
The text was updated successfully, but these errors were encountered: