Files
YwxApp.AiChat/Views/ChatMdView.xaml
2025-03-13 01:06:32 +08:00

78 lines
3.6 KiB
XML
Raw Permalink 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: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" xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
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 >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="120" />
</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">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>
<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>
<Button x:Name="BtnSubmit" Content="提交" FontSize="18" Margin="5"
Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1"
Style="{StaticResource RoundCornerButtonStyle}" Command="{Binding SubmitQuestionCommand}" />
</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>