update ChatBox
This commit is contained in:
1 parent
b19436985c
commit
44b6d64e0a
2 files changed
+19
-2
No files matched your search
@@ -16,7 +16,7 @@
|
|||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.CanContentScroll="False" Background="Transparent" hc:ChatBubble.MaxWidth="300" BorderThickness="0" Style="{StaticResource StackPanelVerticalListBox}" ItemsSource="{Binding ChatInfos}">
|
<ListBox Name="ListBoxChat" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.CanContentScroll="False" Background="Transparent" hc:ChatBubble.MaxWidth="300" BorderThickness="0" Style="{StaticResource StackPanelVerticalListBox}" ItemsSource="{Binding ChatInfos}">
|
||||||
<hc:Interaction.Triggers>
|
<hc:Interaction.Triggers>
|
||||||
<hc:RoutedEventTrigger RoutedEvent="hc:ChatBubble.Selected">
|
<hc:RoutedEventTrigger RoutedEvent="hc:ChatBubble.Selected">
|
||||||
<hc:EventToCommand Command="{Binding ReadMessageCmd}" PassEventArgsToCommand="True" />
|
<hc:EventToCommand Command="{Binding ReadMessageCmd}" PassEventArgsToCommand="True" />
|
||||||
|
|||||||
@@ -1,10 +1,27 @@
|
|||||||
namespace HandyControlDemo.UserControl
|
using System.Windows.Controls;
|
||||||
|
using HandyControl.Tools;
|
||||||
|
|
||||||
|
namespace HandyControlDemo.UserControl
|
||||||
{
|
{
|
||||||
public partial class ChatBox
|
public partial class ChatBox
|
||||||
{
|
{
|
||||||
|
private ScrollViewer _scrollViewer;
|
||||||
|
|
||||||
public ChatBox()
|
public ChatBox()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
ListBoxChat.ItemContainerGenerator.ItemsChanged += ItemContainerGenerator_ItemsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ItemContainerGenerator_ItemsChanged(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (_scrollViewer == null)
|
||||||
|
{
|
||||||
|
_scrollViewer = VisualHelper.GetChild<ScrollViewer>(ListBoxChat);
|
||||||
|
}
|
||||||
|
|
||||||
|
_scrollViewer?.ScrollToBottom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user