Listbox Conversation verhält sich etwas natürlicher
This commit is contained in:
@@ -294,6 +294,16 @@ namespace BeWo.Core
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void ScrollToTop(ListBox listBox)
|
||||
{
|
||||
if (VisualTreeHelper.GetChildrenCount(listBox) > 0)
|
||||
{
|
||||
Border border = (Border)VisualTreeHelper.GetChild(listBox, 0);
|
||||
ScrollViewer scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(border, 0);
|
||||
scrollViewer.ScrollToTop();
|
||||
}
|
||||
}
|
||||
|
||||
public static void ScrollToBottom(ListBox listBox)
|
||||
{
|
||||
if (VisualTreeHelper.GetChildrenCount(listBox) > 0)
|
||||
|
||||
@@ -122,7 +122,8 @@
|
||||
ItemsSource="{Binding VMList}"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
SelectedItem="{Binding SelectedVM, Mode=TwoWay}">
|
||||
SelectedItem="{Binding SelectedVM, Mode=TwoWay}"
|
||||
SelectionChanged="listbox_conversations_SelectionChanged">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
@@ -221,7 +222,10 @@
|
||||
Content="Senden"
|
||||
Visibility="Visible" />
|
||||
</Grid>
|
||||
<Grid Grid.Column="1" Grid.RowSpan="2" Margin="4">
|
||||
<Grid
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="4">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="0" />
|
||||
<ColumnDefinition Width="*" />
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace BeWo.View.Detail.AI
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
((INotifyCollectionChanged)listbox_messages.Items).CollectionChanged += listbox_conversations_SelectionChanged;
|
||||
((INotifyCollectionChanged)listbox_messages.Items).CollectionChanged += listbox_messages_SelectionChanged;
|
||||
|
||||
popup_settings.Closed += (s, e) => ViewModel.UpdateConfig();
|
||||
|
||||
@@ -62,7 +62,15 @@ namespace BeWo.View.Detail.AI
|
||||
ViewModel.ReloadConversationsCommand.Execute(null);
|
||||
}
|
||||
|
||||
private void listbox_conversations_SelectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
private void listbox_conversations_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (ViewModel.IsNewConversationVisible)
|
||||
BeWoWpfUtils.ScrollToTop(listbox_conversations);
|
||||
else
|
||||
listbox_conversations.ScrollIntoView(listbox_conversations.SelectedItem);
|
||||
}
|
||||
|
||||
private void listbox_messages_SelectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
BeWoWpfUtils.ScrollToBottom(listbox_messages);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user