Files
YwxApp.AiChat/Views/ChatMdView.xaml
2025-03-12 20:02:52 +08:00

75 lines
3.3 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<UserControl x:Class="YwxApp.AiChat.Views.ChatMdView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources >
<ResourceDictionary>
<!--Resource dictionaryAdd control style.-->
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Style/ButtonStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid Background="#0F000F">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="200" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<!--First line: Display output text to "Markdown" container-->
<Grid Grid.Row="0">
<ScrollViewer Background="#FFFFFF" x:Name="MarkDownScrollViewer">
<!--Bind event command to the ScrollViewer-->
<i:Interaction.Triggers>
<i:EventTrigger EventName="ScrollChanged">
<i:InvokeCommandAction Command = "{Binding ScrollToEndCommand}"
CommandParameter="{Binding ElementName=MarkDownScrollViewer}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<!--scrollviewer internal container-->
<markdig:MarkdownViewer x:Name="MarkdownOutputBox" Markdown="{Binding MarkdownContent}" />
</ScrollViewer>
</Grid>
<!-- the second line -->
<Grid Grid.Row="1">
<TextBox x:Name="InputBox"
Text="{Binding InputText , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Grid.Row="1" Margin="5" AcceptsReturn="True"
VerticalScrollBarVisibility="Auto">
<!--key binding of "Enter"-->
<TextBox.InputBindings>
<KeyBinding Command="{Binding SubmitQuestionCommand}" Key="Enter"/>
</TextBox.InputBindings>
</TextBox>
</Grid>
<!-- The third line submit button -->
<Grid Grid.Row="2">
<WrapPanel Grid.Row="2" HorizontalAlignment="Right">
<Button x:Name="BtnNewChat" Content="新建会话"
HorizontalAlignment="Right"
Style="{StaticResource RoundCornerButtonStyle}"
Command="{Binding NewSessionCommand}"
Width="100"
Height="30"/>
<Button x:Name="BtnSubmit" Content="提交"
HorizontalAlignment="Right"
Style="{StaticResource RoundCornerButtonStyle}"
Command="{Binding SubmitQuestionCommand}"
Width="100"
Height="30"/>
</WrapPanel>
</Grid>
</Grid>
</UserControl>