Listview完整显示用户头像及昵称信息
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
<ColumnDefinition Width="200*"/>
|
||||
<ColumnDefinition Width="200*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListView x:Name="UsersList" Margin="0,0,0,0" IsEnabled="True" SelectionChanged="UsersList_SelectionChanged" Grid.Row="1" Grid.RowSpan="2"/>
|
||||
<ListView x:Name="UsersList" Margin="0,0,0,0" IsEnabled="True" SelectionChanged="UsersList_SelectionChanged" Grid.Row="1" Grid.RowSpan="2">
|
||||
</ListView>
|
||||
<TextBox x:Name="InputBox" Margin="0,0,0,0" TextWrapping="Wrap" Text="" Grid.Row="2" Grid.ColumnSpan="3" Grid.Column="1" />
|
||||
<Button Content="Send" HorizontalAlignment="Right" Margin="0,0,0,0" VerticalAlignment="Bottom" Width="75" Click="Button_Click" Height="20" Grid.Row="2" Grid.Column="3"/>
|
||||
<ScrollViewer Grid.ColumnSpan="3" Grid.Column="1" Margin="0,0,0,0" Grid.Row="1" >
|
||||
@@ -27,6 +28,6 @@
|
||||
<StackPanel x:Name="OutBox" Margin="0,0,0,0" Grid.ColumnSpan="3" Grid.Column="1" Grid.Row="1" ScrollViewer.VerticalScrollBarVisibility="Hidden"/>
|
||||
</ScrollViewer.Content>
|
||||
</ScrollViewer>
|
||||
<Button x:Name="button" Content="Button" Grid.Column="2" HorizontalAlignment="Left" Margin="73,31,0,0" Grid.Row="2" VerticalAlignment="Top" Width="75" Click="button_Click_1"/>
|
||||
<Button x:Name="button" Content="更改头像" Grid.Column="1" HorizontalAlignment="Left" Margin="0,64,0,-2" Grid.Row="2" VerticalAlignment="Top" Width="75" Click="button_Click_1"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -25,7 +25,13 @@ namespace StormChatWPF
|
||||
{
|
||||
foreach (var user in Chat.ContactsList)
|
||||
{
|
||||
UsersList.Items.Add(user.NickName);
|
||||
if (user.Name !=User.Me.Name)
|
||||
{
|
||||
UsersList.Items.Add(new UI.ContactsInfo(user)
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}//向联系人列表listview中添加元素
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<Compile Include="UI\Contacts.xaml.cs">
|
||||
<DependentUpon>Contacts.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\UserInfo.cs" />
|
||||
<Compile Include="UI\ContactsInfo.cs" />
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:StormChatWPF.UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="40" d:DesignWidth="120">
|
||||
d:DesignHeight="40" d:DesignWidth="120" HorizontalAlignment="Stretch">
|
||||
<Grid>
|
||||
<WrapPanel HorizontalAlignment="Left" Height="40" VerticalAlignment="Stretch" Width="120">
|
||||
<WrapPanel Height="40" VerticalAlignment="Stretch">
|
||||
<Image x:Name="HeadPicture" HorizontalAlignment="Left" Height="40" Width="40"/>
|
||||
<Label x:Name="text" Content="Label" Height="40" Width="80"/>
|
||||
<Label x:Name="text" Content="Label" Height="40" FontSize="14" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</WrapPanel>
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ using System.IO;
|
||||
|
||||
namespace StormChatWPF.UI
|
||||
{
|
||||
internal class UserInfo : Contacts
|
||||
internal class ContactsInfo : Contacts
|
||||
{
|
||||
public UserInfo(User user)
|
||||
public ContactsInfo(User user)
|
||||
{
|
||||
image.BeginInit();
|
||||
image.StreamSource = user.Photo;
|
||||
Reference in New Issue
Block a user