欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

C#中如何實(shí)現(xiàn)WPF聯(lián)系人列表

這篇文章將為大家詳細(xì)講解有關(guān)C#中如何實(shí)現(xiàn)WPF聯(lián)系人列表,小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,希望大家閱讀完這篇文章后可以有所收獲。

成都創(chuàng)新互聯(lián)服務(wù)項(xiàng)目包括晉安網(wǎng)站建設(shè)、晉安網(wǎng)站制作、晉安網(wǎng)頁制作以及晉安網(wǎng)絡(luò)營(yíng)銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,晉安網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到晉安省份的部分城市,未來相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

1.本文背景

本文效果如下: 

C#中如何實(shí)現(xiàn)WPF聯(lián)系人列表  
聯(lián)系人列表

2.代碼實(shí)現(xiàn)

使用 .Net CORE 3.1 創(chuàng)建名為 “Chat” 的WPF項(xiàng)目,添加 MaterialDesignThemes(3.0.1)、MaterialDesignColors(1.2.2)兩個(gè)Nuget庫,文中部分圖片可在文末視頻配套源碼中下載。

2.1 引入MD控件樣式文件

使用MD控件的常規(guī)操作,需要在App.xaml中引入4個(gè)樣式文件

<Application x:Class="Chat.App"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            StartupUri="MainWindow.xaml">
   <Application.Resources>
       <ResourceDictionary>
           <ResourceDictionary.MergedDictionaries>
               <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
               <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
               <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Green.xaml" />
               <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
           </ResourceDictionary.MergedDictionaries>
       </ResourceDictionary>
   </Application.Resources>
</Application>


2.2 界面布局

純粹的布局代碼:

<Window x:Class="Chat.MainWindow"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
       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"
       mc:Ignorable="d"
       Height="600" Width="1080" ResizeMode="NoResize" MouseLeftButtonDown="Window_MouseLeftButtonDown"
       WindowStartupLocation="CenterScreen" WindowStyle="None">
   <Grid>
       <Grid.ColumnDefinitions>
           <ColumnDefinition Width="270"/>
           <ColumnDefinition Width="*"/>
           <ColumnDefinition Width="270"/>
       </Grid.ColumnDefinitions>

       <Grid Grid.Column="1" Background="#FFE4E4E4"/>

       <StackPanel Grid.Column="0" Background="{StaticResource PrimaryHueDarkBrush}">
           <StackPanel Orientation="Horizontal" Background="White">
               <Image Width="210" Height="80" Source="Assets/logo.png"/>
               <Button Style="{StaticResource MaterialDesignFlatButton}">
                   <materialDesign:PackIcon Kind="PlusCircle" Width="24" Height="24"/>
               </Button>
           </StackPanel>
           <TextBox Margin="20 10" Style="{StaticResource MaterialDesignFloatingHintTextBox}" materialDesign:HintAssist.Hint="搜索" Foreground="White"/>
           <Grid>
               <Grid.ColumnDefinitions>
                   <ColumnDefinition Width="*"/>
                   <ColumnDefinition Width="*"/>
                   <ColumnDefinition Width="*"/>
                   <ColumnDefinition Width="*"/>
               </Grid.ColumnDefinitions>

               <Button Style="{StaticResource MaterialDesignFlatButton}" Grid.Column="0">
                   <materialDesign:PackIcon Kind="History" Foreground="White"/>
               </Button>
               <Button Style="{StaticResource MaterialDesignFlatButton}" Grid.Column="1">
                   <materialDesign:PackIcon Kind="People" Foreground="White"/>
               </Button>
               <Button Style="{StaticResource MaterialDesignFlatButton}" Grid.Column="2">
                   <materialDesign:PackIcon Kind="Contacts" Foreground="White"/>
               </Button>
               <Button Style="{StaticResource MaterialDesignFlatButton}" Grid.Column="3">
                   <materialDesign:PackIcon Kind="Archive" Foreground="White"/>
               </Button>
           </Grid>
           <ListView>
               <ListViewItem HorizontalAlignment="Stretch">
                   <Grid HorizontalAlignment="Center" Margin="5">
                       <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="50"/>
                           <ColumnDefinition Width="150"/>
                           <ColumnDefinition Width="50*"/>
                       </Grid.ColumnDefinitions>

                       <Border Width="40" Height="40" CornerRadius="25" BorderBrush="White" BorderThickness="0.6">
                           <Border.Background>
                               <ImageBrush ImageSource="https://img.dotnet9.com/logo.png"/>
                           </Border.Background>
                       </Border>
                       <Border Width="10" Height="10" VerticalAlignment="Bottom" Margin="5" HorizontalAlignment="Right" CornerRadius="15" Background="LightGreen"/>

                       <StackPanel Grid.Column="1">
                           <TextBlock Text="Dotnet9.com" Margin="10 0"/>
                           <TextBlock Text="一個(gè)熱衷于互聯(lián)網(wǎng)分享精神的程序員的網(wǎng)站!" Margin="10 0" TextTrimming="CharacterEllipsis" Opacity="0.6" FontSize="11"/>
                       </StackPanel>

                       <Border Grid.Column="2" Width="20" Height="20" CornerRadius="15" Background="White" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="5">
                           <TextBlock FontSize="11" Text="9" Foreground="{StaticResource PrimaryHueDarkBrush}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                       </Border>
                   </Grid>
               </ListViewItem>
           </ListView>
       </StackPanel>

   </Grid>
</Window>


2.2.3 窗體拖動(dòng)

后臺(tái)代碼

private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
   DragMove();
}

關(guān)于“C#中如何實(shí)現(xiàn)WPF聯(lián)系人列表”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,使各位可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),請(qǐng)把它分享出去讓更多的人看到。

當(dāng)前文章:C#中如何實(shí)現(xiàn)WPF聯(lián)系人列表
分享路徑:http://chinadenli.net/article2/gdggoc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司網(wǎng)站收錄ChatGPT網(wǎng)站建設(shè)標(biāo)簽優(yōu)化App開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計(jì)