Skip to content
This repository was archived by the owner on Aug 26, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/ChatGPT.UI/CustomMarkdownScrollViewer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Avalonia.Controls;
using Avalonia.Input;
using Markdown.Avalonia;

namespace AI
{

public class CustomMarkdownScrollViewer : MarkdownScrollViewer
{
public CustomMarkdownScrollViewer()
{
Plugins = new MdAvPlugins();
AddHandler(RequestBringIntoViewEvent, OnRequestBringIntoView, handledEventsToo: true);
}

private void OnRequestBringIntoView(object? sender, RequestBringIntoViewEventArgs e)
{
e.Handled = true;
}
}


}
23 changes: 12 additions & 11 deletions src/ChatGPT.UI/Views/Chat/Messages/ChatMarkdownMessageView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
xmlns:vm="clr-namespace:ChatGPT.ViewModels.Chat;assembly=ChatGPT.Core"
xmlns:md="clr-namespace:Markdown.Avalonia;assembly=Markdown.Avalonia"
xmlns:ctxt="clr-namespace:ColorTextBlock.Avalonia;assembly=ColorTextBlock.Avalonia"
xmlns:ai="clr-namespace:AI"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ChatGPT.Views.Chat.Messages.ChatMarkdownMessageView"
x:CompileBindings="True" x:DataType="vm:ChatMessageViewModel">
<md:MarkdownScrollViewer Markdown="{Binding Message}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Margin="16,16,16,16"
TextElement.FontSize="{DynamicResource MessageFontSize}"
IsVisible="{Binding Message, Converter={x:Static ObjectConverters.IsNotNull}}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Classes.error="{Binding IsError}">
<md:MarkdownScrollViewer.Styles>
<ai:CustomMarkdownScrollViewer Markdown="{Binding Message}"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Margin="16,16,16,16"
TextElement.FontSize="{DynamicResource MessageFontSize}"
IsVisible="{Binding Message, Converter={x:Static ObjectConverters.IsNotNull}}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Classes.error="{Binding IsError}">
<ai:CustomMarkdownScrollViewer.Styles>
<Style Selector="md|MarkdownScrollViewer.error ctxt|CTextBlock">
<Setter Property="Foreground" Value="{DynamicResource MessageErrorBrush}" />
</Style>
</md:MarkdownScrollViewer.Styles>
</md:MarkdownScrollViewer>
</ai:CustomMarkdownScrollViewer.Styles>
</ai:CustomMarkdownScrollViewer>
</UserControl>