時(shí)間如流水,只能流去不流回迟赃!點(diǎn)贊再看,養(yǎng)成習(xí)慣实辑,這是您給我創(chuàng)作的動(dòng)力捺氢!本文 Dotnet9 https://dotnet9.com 已收錄,站長(zhǎng)樂(lè)于分享dotnet相關(guān)技術(shù)剪撬,比如Winform摄乒、WPF、ASP.NET Core等残黑,亦有C++桌面相關(guān)的Qt Quick和Qt Widgets等馍佑,只分享自己熟悉的、自己會(huì)的梨水。
閱讀導(dǎo)航:
一拭荤、先看效果
二、本文背景
三疫诽、代碼實(shí)現(xiàn)
四舅世、文章參考
五、代碼下載
一奇徒、先看效果
二雏亚、本文背景
在YouTube上看到的一個(gè)視頻,文末有鏈接摩钙,使用前端時(shí)間介紹的開(kāi)源C# WPF 控件庫(kù)HandyControl罢低,用到了其中的頭像控件、水波紋控件胖笛、拖動(dòng)條控件等网持。
三宜岛、代碼實(shí)現(xiàn)
站長(zhǎng)使用.Net Core 3.1創(chuàng)建的WPF工程,創(chuàng)建名稱為“CustomControlsHandyOrg”的解決方案后功舀,需要添加Nuget庫(kù):HandyControl萍倡。
代碼不多,首先在App.xaml中添加HandyControl兩個(gè)樣式文件:
<Application x:Class="CustomControlsHandyOrg.App"
? ? ? ? ? ? xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
? ? ? ? ? ? xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
? ? ? ? ? ? xmlns:local="clr-namespace:CustomControlsHandyOrg"
? ? ? ? ? ? StartupUri="MainWindow.xaml">
? ? <Application.Resources>
? ? <ResourceDictionary>
? ? ? ? <ResourceDictionary.MergedDictionaries>
? ? ? ? ? ? <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/>
? ? ? ? ? ? <ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/>
? ? ? ? </ResourceDictionary.MergedDictionaries>
? ? </ResourceDictionary>
? ? </Application.Resources>
</Application>
另外一個(gè)代碼文件是MainWindow.xaml日杈,首先引入HandyControl命名空間
xmlns:hc="https://handyorg.github.io/handycontrol"
代碼確實(shí)不多遣铝,關(guān)鍵代碼也就10行左右
<Window x:Class="CustomControlsHandyOrg.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:CustomControlsHandyOrg"
? ? ? ? mc:Ignorable="d"
? ? ? ? xmlns:hc="https://handyorg.github.io/handycontrol"
? ? ? ? Height="450" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowStyle="None">
? ? <Grid Background="#FF222222">
? ? ? ? <StackPanel VerticalAlignment="Center">
? ? ? ? ? ? <hc:Gravatar Id="{Binding Value,ElementName=slider}"/>
? ? ? ? ? ? <TextBlock FontSize="18" Text="DOWNLOADING" Margin="5 15" Foreground="White" HorizontalAlignment="Center"/>
? ? ? ? ? ? <hc:WaveProgressBar Value="{Binding Value,ElementName=slider}" Maximum="100" Background="#FF555555" WaveFill="#ff563380" WaveStroke="#FF5675" WaveThickness="1" Foreground="White"/>
? ? ? ? ? ? <Button Content="STOP" Margin="15" HorizontalAlignment="Stretch" Background="#FF563380" BorderBrush="#FF482480" Foreground="White"/>
? ? ? ? ? ? <hc:PreviewSlider x:Name="slider" Maximum="100" Margin="20"/>
? ? ? ? </StackPanel>
? ? </Grid>
</Window>
四、文章參考
上面的代碼是Dotnet9看 Disign com WPF 大神視頻手敲的莉擒,下面是大神youtube地址及本實(shí)例學(xué)習(xí)視頻酿炸。
參考:
Design com WPF:?https://www.youtube.com/watch?v=8uW5uY6PvDQ
五、代碼下載
文章中代碼已經(jīng)全部貼出涨冀,就這么幾行代碼填硕,不要奇怪,就是這么多鹿鳖。
除非注明扁眯,文章均由?Dotnet9?整理發(fā)布,歡迎轉(zhuǎn)載翅帜。轉(zhuǎn)載請(qǐng)注明本文地址:https://dotnet9.com/2019/12/it-technology/csharp/wpf/trying-handy-org-custom-controls.html如有所收獲姻檀,請(qǐng)大力轉(zhuǎn)發(fā)(能點(diǎn)贊及推薦那是極好的);如覺(jué)小編寫(xiě)文不易涝滴,歡迎給Dotnet9站點(diǎn)打賞绣版,小編謝謝了;謝謝大家對(duì)dotnet技術(shù)的關(guān)注和支持 歼疮。