<Grid >
<Grid x:Name="bubble_right" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Right"
Visibility="{Binding showright}" MinWidth="80">
<Grid Margin="5,5,15,5" MaxWidth="400" MinWidth="50" MinHeight="80">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="15"/>
<ColumnDefinition Width="80"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Column="0" Grid.RowSpan="2" MaxWidth="400">
<Rectangle StrokeThickness="0" Fill="#FF6accfd" RadiusY="4" RadiusX="4" Margin="0,10,0,0" MaxWidth="400" MinWidth="100"/>
<StackPanel Orientation="Vertical" MaxWidth="400">
<TextBlock FontSize="24" Text="为飞撒的反馈师傅" Grid.Column="0" Padding="5,0" MinWidth="30"
Foreground="Black" Margin="5,20,5,0" Tag="0" TextAlignment="Left" TextWrapping="Wrap" />
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="2015-12-21 12:12:15" Foreground="Black"
VerticalAlignment="Top" Height="16" Margin="5,0,5,5" Grid.Column="0" FontSize="15"/>
</StackPanel>
</Grid>
<Path Data="M29.5,14 L25.25,14 L25.25,17.75" Fill="#ffdadada" HorizontalAlignment="Left" Grid.Column="1"
Height="16" Stretch="Fill" Stroke="Transparent" VerticalAlignment="Top" Width="15" StrokeThickness="0" Margin="0,20,0,0"/>
<Grid Grid.Column="2" Grid.RowSpan="2" Margin="0,5" Width="80">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Image Source="/Assets/sound.png" Grid.Row="0"/>
<Image Source="/Assets/PrivateMsgLock.png" Width="30" Grid.Row="1" Margin="25,0"/>
</Grid>
</Grid>
</Grid>
<Grid x:Name="bubble_left" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left"
Visibility="{Binding showleft}" MinWidth="80">
<Grid Margin="5,5,15,5" MaxWidth="400" MinWidth="50" MinHeight="80">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="15"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Column="2" Grid.RowSpan="2" MaxWidth="400">
<Rectangle StrokeThickness="0" Fill="#FF6accfd" RadiusY="4" RadiusX="4" Margin="0,10,0,0" MaxWidth="400" MinWidth="100"/>
<StackPanel Orientation="Vertical" MaxWidth="400">
<TextBlock FontSize="24" x:Name="inTB" Text="动" Grid.Column="2" Padding="5,0" MinWidth="30"
Foreground="Black" Margin="5,20,5,0" Tag="0" TextAlignment="Left" TextWrapping="Wrap" />
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="2015-12-21 12:12:15" Foreground="Black"
VerticalAlignment="Top" Height="16" Margin="5,0,5,5" Grid.Column="2" FontSize="15"/>
</StackPanel>
</Grid>
<Grid Grid.Column="0" Grid.RowSpan="2" Margin="0,5" Width="80">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Image Source="/Assets/sound.png" Grid.Row="0"/>
<Image Source="/Assets/PrivateMsgLock.png" Width="30" Grid.Row="1" Margin="25,0"/>
</Grid>
<Path Data="M29.5,14 L25.25,14 L25.25,17.75" Fill="#FF6accfd" HorizontalAlignment="Left"
Height="16" Stretch="Fill" Stroke="Transparent" VerticalAlignment="Top" Width="15" StrokeThickness="0"
Margin="0,20,0,0" UseLayoutRounding="False" Grid.Column="1" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<CompositeTransform ScaleX="-1"/>
</Path.RenderTransform>
</Path>
</Grid>
</Grid>
</Grid>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="list" Margin="0,0,0,155" Background="White" ItemsSource="{Binding}" ItemTemplate="{StaticResource DataTemplate2}">
<!-- 确保listboxitem被stretch到listbox的宽度 -->
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
<TextBox x:Name="inputbox" Margin="0,453,0,72" TextWrapping="Wrap"
Text="TextBox" Background="#BFE4AFAF"
BorderBrush="#BF906060"
Padding="1" SelectionBackground="#FFE21BB4" />
<Button Content="Add to right" Grid.Row="1" Height="72" HorizontalAlignment="Left"
Margin="0,535,0,0" Name="button1" VerticalAlignment="Top" Width="181" FontSize="20" Click="button1_Click" />
<Button Content="Add to Left" Height="72" HorizontalAlignment="Left"
Margin="186,535,0,0" Name="button2" VerticalAlignment="Top" Width="181" FontSize="20" Click="button2_Click" />
</Grid>
public class msg_class
{
public String content { get; set; }
public Visibility showleft { get; set; }
public Visibility showright { get; set; }
public msg_class(String content, Visibility showleft, Visibility showright)
{
this.content = content;
this.showleft = showleft;
this.showright = showright;
}
}
void showmsg(String msg, bool isself)
{
if (isself)
{
list.Items.Add(new msg_class(msg, Visibility.Collapsed, Visibility.Visible));
}
else
{
list.Items.Add(new msg_class(msg, Visibility.Visible, Visibility.Collapsed));
};
}
void readmsg(int index)
{
string s = ((msg_class)(list.Items[index])).content;
list.Items[index] = new msg_class(s, Visibility.Visible, Visibility.Collapsed);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
showmsg("我地方暗示法sdf撒的反馈地方发生的疯狂暗示法的是嘎达", true);
list.ScrollIntoView(list.Items[0]);
}
private void button2_Click(object sender, RoutedEventArgs e)
{
showmsg(inputbox.Text, false);
list.ScrollIntoView(list.Items[0]);
}