Skip to content
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

I'm having a similar issue, but it only seems to happen when I have a ListBox bound to to a collection of ObservableCollection<string>, and I add strings with identical content. #4114

Closed
tracydemery36 opened this issue Jun 14, 2020 · 2 comments
Labels

Comments

@tracydemery36
Copy link

I'm having a similar issue, but it only seems to happen when I have a ListBox bound to to a collection of ObservableCollection<string>, and I add strings with identical content.

            <ListBox AutoScrollToSelectedItem="True"
                   Grid.Row="1"
                   ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                   SelectedIndex="{Binding SIndex}"
                   Items="{Binding LogItems}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding .}" TextWrapping="Wrap" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        private ObservableCollection<string> LogItems { get; } = new ObservableCollection<string>();

        private int _sIndex;
        public int SIndex {
            get { return _sIndex; }
            set { this.RaiseAndSetIfChanged(ref _sIndex, value); }
        }

        public void Log(string s) {
            var lines = s.Split('\n');
            foreach (var line in lines) {
                if (!string.IsNullOrWhiteSpace(line)) {
                    LogItems.Add($"{DateTime.Now.ToString("HH:mm tt")}: {line}");
                    SIndex = LogItems.Count - 1;
                }
            }
        }

Originally posted by @lenonk in #2569 (comment)

@FoggyFinder
Copy link
Contributor

This was fixed. Otherwise, can you provide MCVE?

@grokys grokys added the bug label Dec 2, 2022
@grokys
Copy link
Member

grokys commented Dec 9, 2022

Closing as should be fixed, and no MVCE from reporter.

@grokys grokys closed this as completed Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants