Skip to content

How to auto select first item? #611

Answered by RolandPheasant
a44281071 asked this question in Q&A
Discussion options

You must be logged in to vote

There's a lot of options for selecting the first item. For example you can:

        private IDisposable CreateCountryBind()
        {
            var handle = dataAccessor.CountryCache.Connect()
                .Transform(dd => new CountryViewModel(dd))
                .Sort(SortExpressionComparer<CountryViewModel>.Ascending(p => p.Info.Name))
                .ObserveOnDispatcher()
                .Bind(CountryItems)
                .Subscribe();

            var selector = CountryItems.ToObservableChangeSet()
                .ToCollection()
                .Select(items => items.FirstOrDefault())
                .Where(vm => vm != null)
                .Take(1)  //Take 1 to run task once…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by RolandPheasant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants