WPF控件模仿HTML控制台

时间:2018-10-06 02:20:15

标签: c# html wpf

我猜测没有一个控件可以自动执行此操作,但是我正在寻找一种在wpf应用程序中实现类似功能的方法。这就是我想要的。

  • 像cli一样接受命令(这可以是一个单独的文本框 如有必要)。
  • 输出普通文本并支持HTML颜色。
  • 每个命令后,光标向下移动时,滚动历史记录。
  • HTML格式的div,表格和文本格式(无需js)
  • 不大于100x100的小图片

如何开始制作?我要从StackPanel开始吗?

1 个答案:

答案 0 :(得分:0)

I Added two rows with four colomns in a grid panel
In the first row fourth colomn add a stackpanel for normal text

Out side the grid you also add image as well as inside 
That I include for your reference

The grid is nested in the scroll


<Window x:Class="Wpftest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Wpftest"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <ScrollViewer Margin="5" CanContentScroll="False"
              HorizontalScrollBarVisibility="Auto">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <Image Source="Augustus.jpg" Height="100" Margin="10"/>
            <Label Grid.Column="1" Content="Augustus - 63BC - 14AD" />

            <Image Grid.Column="2" Source="Tiberius.jpg" Height="100" Margin="10"/>
            <Label Grid.Column="3" Content="Tiberius - 42BC - 37AD"/>
            <StackPanel Grid.Row="0" Grid.Column="4">

                <TextBlock FontSize="15">Your Normal text</TextBlock>

            </StackPanel>
            <Button Grid.Row="1" Content="Learn"
                HorizontalAlignment="Center" VerticalAlignment="Center"
                Padding="10,5"/>
            <Button Grid.Row="1" Grid.Column="2" Content="Learn"
                HorizontalAlignment="Center" VerticalAlignment="Center"
                Padding="10,5"/>
            <Button Grid.Row="1" Grid.Column="4" Content="Inputs"
                HorizontalAlignment="Center" VerticalAlignment="Center"
                Padding="10,5"/>
        </Grid>
    </ScrollViewer>
</Window>