电子药箱通讯服务端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

MainWindow.xaml 3.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <Window
  2. x:Class="Tcp.Test2.MainWindow"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:Tcp.Test2"
  7. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  8. Title="MainWindow"
  9. Width="800"
  10. Height="450"
  11. mc:Ignorable="d">
  12. <Grid>
  13. <Grid.RowDefinitions>
  14. <RowDefinition Height="*" />
  15. <RowDefinition Height="Auto" />
  16. <RowDefinition Height="300" />
  17. <RowDefinition Height="Auto" />
  18. </Grid.RowDefinitions>
  19. <Border Grid.Row="0">
  20. <ListBox ItemsSource="{Binding ListMessage}">
  21. <ListBox.ItemTemplate>
  22. <DataTemplate>
  23. <Border
  24. Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=ListBox}}"
  25. Margin="0,0,-50,0"
  26. TextBlock.Foreground="Blue">
  27. <Grid Name="GridMessage" Margin="0,0,50,0">
  28. <Grid.RowDefinitions>
  29. <RowDefinition Height="Auto" />
  30. <RowDefinition Height="*" />
  31. </Grid.RowDefinitions>
  32. <TextBlock
  33. x:Name="TxtTime"
  34. Grid.Row="0"
  35. Text="{Binding CreateTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" />
  36. <TextBlock
  37. Name="TxtMessage"
  38. Grid.Row="1"
  39. Text="{Binding Message}" />
  40. </Grid>
  41. </Border>
  42. <DataTemplate.Triggers>
  43. <DataTrigger Binding="{Binding IsAck}" Value="true">
  44. <Setter TargetName="TxtTime" Property="Foreground" Value="red" />
  45. <Setter TargetName="TxtMessage" Property="Foreground" Value="red" />
  46. <Setter TargetName="TxtTime" Property="HorizontalAlignment" Value="Right" />
  47. <Setter TargetName="TxtMessage" Property="HorizontalAlignment" Value="Right" />
  48. </DataTrigger>
  49. </DataTemplate.Triggers>
  50. </DataTemplate>
  51. </ListBox.ItemTemplate>
  52. </ListBox>
  53. </Border>
  54. <GridSplitter
  55. Grid.Row="1"
  56. Height="5"
  57. HorizontalAlignment="Stretch"
  58. VerticalAlignment="Center"
  59. ResizeDirection="Rows" />
  60. <Border Grid.Row="2">
  61. <TextBox
  62. AcceptsReturn="True"
  63. Text="{Binding CurrentInput, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  64. TextWrapping="Wrap" />
  65. </Border>
  66. <Border Grid.Row="3">
  67. <Grid>
  68. <TextBlock VerticalAlignment="Center" Text="{Binding StatusMessage}" />
  69. <Button
  70. Width="200"
  71. Height="30"
  72. Margin="5"
  73. HorizontalAlignment="Right"
  74. Command="{Binding SendCommand}"
  75. Content="发送" />
  76. </Grid>
  77. </Border>
  78. </Grid>
  79. </Window>