WPF完成相似360平安衛士界面的法式源碼分享。本站提示廣大學習愛好者:(WPF完成相似360平安衛士界面的法式源碼分享)文章只能為提供參考,不一定能成為您想要的結果。以下是WPF完成相似360平安衛士界面的法式源碼分享正文
上面經由過程圖文並茂的方法給年夜家引見WPF完成相似360平安衛士界面的法式源碼分享,點擊此處下載源碼哦。
之前進修Windows Form編程的時刻,總感到本身做的界面很丑,看到360平安衛士、迅雷等軟件的UI設計都異常雅觀,心裡老是向往著如果本身能完成如許的UI後果該多好!!!另外一個困擾我的成績是,這個UI皮膚是若何用技巧完成的呢?!固然很多多少年曩昔了,但心裡的向往和困惑一向沒有消逝,並且愈來愈激烈。在平常的任務和進修中,本身在網上也常常留心相似的技巧或許文章。比來在進修WPF的進程中,看到網上也有仿360和仿迅雷UI設計的資本,經由過程對資本的進修和本身的著手理論,終究完成了上面的仿360平安衛士界面:
因為項目文件比擬多,這裡枚舉出焦點的進程和代碼:
1、VS處理計劃構造:
WpfPageTransitions是一個WPF類庫,完成UI頁面切換動畫後果,支撐多種動畫,可以經由過程TransitionType屬性停止設置,其道理是界說了多個切換動畫類型的Storyboard,法式依據設置裝備擺設的TransitionType去履行婚配的Storyboard動畫(分收支動畫,xxxxxxIn和xxxxxxOut)。360UI是一個WPF 桌面運用法式,styles文件夾下寄存了界說的按鈕款式、菜單項款式、頁簽款式等款式和須要的一切UI切圖資本。pages文件夾下寄存切換的具體子頁面。
(備注:圖片資本和部門文件來自互聯網,特殊感激KXFang360項目供給的360整套配圖和結構文件)
2、頁面切換控件焦點代碼:
<UserControl x:Class="WpfPageTransitions.PageTransition" xmlns="http://schemas.microsoft.com/winfx//xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx//xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/" xmlns:d="http://schemas.microsoft.com/expression/blend/" xmlns:local="clr-namespace:WpfPageTransitions" mc:Ignorable="d" d:DesignHeight="" d:DesignWidth=""> <UserControl.Resources> <Style TargetType="{x:Type ContentPresenter}"> <Setter Property="LayoutTransform"> <Setter.Value> <ScaleTransform /> </Setter.Value> </Setter> </Style> <local:CenterConverter x:Key="centerConverter"/> <!-- Slide and Fade --> <Storyboard x:Key="SlideAndFadeIn" > <ThicknessAnimation Duration="::." Storyboard.TargetProperty="Margin" From=",,-," To="" DecelerationRatio="." /> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" From="" To="" /> </Storyboard> <Storyboard x:Key="SlideAndFadeOut"> <ThicknessAnimation Duration="::." Storyboard.TargetProperty="Margin" To="-,,," AccelerationRatio="."/> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" To="" /> </Storyboard> <!-- Fade --> <Storyboard x:Key="FadeIn" > <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" From="" To="" /> </Storyboard> <Storyboard x:Key="FadeOut"> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" To="" /> </Storyboard> <!-- Slide --> <Storyboard x:Key="SlideIn" > <ThicknessAnimation Duration="::." Storyboard.TargetProperty="Margin" From=",,-," To="" DecelerationRatio="." /> </Storyboard> <Storyboard x:Key="SlideOut"> <ThicknessAnimation Duration="::." Storyboard.TargetProperty="Margin" To="-,,," AccelerationRatio="."/> </Storyboard> <!-- Grow --> <Storyboard x:Key="GrowIn" > <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" From="" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" From="" To="" Duration="::." DecelerationRatio="." /> </Storyboard> <Storyboard x:Key="GrowOut"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" To="" Duration="::." AccelerationRatio="." /> </Storyboard> <!-- Grow and Fade --> <Storyboard x:Key="GrowAndFadeIn" > <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" From="" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" From="" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" From="" To="" /> </Storyboard> <Storyboard x:Key="GrowAndFadeOut"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" To="" /> </Storyboard> <!-- Flip --> <Storyboard x:Key="FlipIn" > <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleX)" From="-" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleY)" From="-" To="" Duration="::." DecelerationRatio="." /> </Storyboard> <Storyboard x:Key="FlipOut"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleX)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleY)" To="" Duration="::." AccelerationRatio="." /> </Storyboard> <!-- Flip and Fade --> <Storyboard x:Key="FlipAndFadeIn" > <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleX)" From="-" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleY)" From="-" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" From="" To="" /> </Storyboard> <Storyboard x:Key="FlipAndFadeOut"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleX)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(SkewTransform.AngleY)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" To="" /> </Storyboard> <!-- Spin --> <Storyboard x:Key="SpinIn" > <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(RotateTransform.Angle)" From="-" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" From="" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" From="" To="" Duration="::." DecelerationRatio="." /> </Storyboard> <Storyboard x:Key="SpinOut"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(RotateTransform.Angle)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" To="" Duration="::." AccelerationRatio="." /> </Storyboard> <!-- Spin and Fade --> <Storyboard x:Key="SpinAndFadeIn" > <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(RotateTransform.Angle)" From="-" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" From="" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" From="" To="" Duration="::." DecelerationRatio="." /> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" From="" To="" /> </Storyboard> <Storyboard x:Key="SpinAndFadeOut"> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(RotateTransform.Angle)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleX)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Storyboard.TargetProperty="(RenderTransform).(TransformGroup.Children)[].(ScaleTransform.ScaleY)" To="" Duration="::." AccelerationRatio="." /> <DoubleAnimation Duration="::." Storyboard.TargetProperty="Opacity" To="" /> </Storyboard> </UserControl.Resources> <Grid Name="page"> <ContentControl Name="contentPresenter" > <ContentControl.RenderTransform> <TransformGroup> <ScaleTransform ScaleX="" ScaleY="" CenterX="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualWidth, Converter={StaticResource centerConverter}}" CenterY="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualHeight, Converter={StaticResource centerConverter}}" /> <SkewTransform AngleX="" AngleY="" CenterX="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualWidth, Converter={StaticResource centerConverter}}" CenterY="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualHeight, Converter={StaticResource centerConverter}}" /> <RotateTransform Angle="" CenterX="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualWidth, Converter={StaticResource centerConverter}}" CenterY="{Binding RelativeSource={RelativeSource AncestorType=Grid, Mode=FindAncestor}, Path=ActualHeight, Converter={StaticResource centerConverter}}" /> <TranslateTransform X="" Y="" /> </TransformGroup> </ContentControl.RenderTransform> </ContentControl> </Grid> </UserControl> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Threading.Tasks; using System.Windows.Media.Animation; namespace WpfPageTransitions { public partial class PageTransition : UserControl { Stack<UserControl> pages = new Stack<UserControl>(); public UserControl CurrentPage { get; set; } public static readonly DependencyProperty TransitionTypeProperty = DependencyProperty.Register("TransitionType", typeof(PageTransitionType), typeof(PageTransition), new PropertyMetadata(PageTransitionType.SlideAndFade)); public PageTransitionType TransitionType { get { return (PageTransitionType)GetValue(TransitionTypeProperty); } set { SetValue(TransitionTypeProperty, value); } } public PageTransition() { InitializeComponent(); } public void ShowPage(UserControl newPage) { pages.Push(newPage); Task.Factory.StartNew(() => ShowNewPage()); } void ShowNewPage() { Dispatcher.Invoke((Action)delegate { if (contentPresenter.Content != null) { UserControl oldPage = contentPresenter.Content as UserControl; if (oldPage != null) { oldPage.Loaded -= newPage_Loaded; UnloadPage(oldPage); } } else { ShowNextPage(); } }); } void ShowNextPage() { UserControl newPage = pages.Pop(); newPage.Loaded += newPage_Loaded; contentPresenter.Content = newPage; } void UnloadPage(UserControl page) { Storyboard hidePage = (Resources[string.Format("{}Out", TransitionType.ToString())] as Storyboard).Clone(); hidePage.Completed += hidePage_Completed; hidePage.Begin(contentPresenter); } void newPage_Loaded(object sender, RoutedEventArgs e) { Storyboard showNewPage = Resources[string.Format("{}In", TransitionType.ToString())] as Storyboard; showNewPage.Begin(contentPresenter); CurrentPage = sender as UserControl; } void hidePage_Completed(object sender, EventArgs e) { contentPresenter.Content = null; ShowNextPage(); } } }
3、Like360Main焦點代碼為:
個中AllowsTransparency="True" Window Background="{x:Null}"的目標是讓WPF窗體隱蔽默許的邊框,如許可以許可用配景圖片填充WPF界說窗體外不雅。在這區間可以自界說封閉、最小化和最年夜化按鈕等。
MouseLeftButtonDown="Window_MouseLeftButtonDown" 目標是為了支撐窗體拖動。FontFamily="SimSun" TextOptions.TextFormattingMode="Display"的目標是為懂得決WPF中文字體顯示隱約的成績。
<Window x:Class="_UI.LikeMain" xmlns="http://schemas.microsoft.com/winfx//xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx//xaml" Title="LikeMain" Height="" Width="" FontFamily="SimSun" AllowsTransparency="True" Window xmlns:pageTransitions="clr-namespace:WpfPageTransitions;assembly=WpfPageTransitions" Background="{x:Null}" MouseLeftButtonDown="Window_MouseLeftButtonDown" TextOptions.TextFormattingMode="Display" > <Window.Resources> <LinearGradientBrush x:Key="MyBrush" EndPoint=".," StartPoint=".,"> <GradientStop Color="#CFFFFFFF"/> <GradientStop Color="#FFEBDD" Offset=""/> </LinearGradientBrush> </Window.Resources> <Border BorderBrush="Black" BorderThickness="" CornerRadius="" Margin=""> <Border.Effect> <DropShadowEffect ShadowDepth="" Opacity="."/> </Border.Effect> <Border.Background> <ImageBrush ImageSource="styles/skin/frame.jpg"/> </Border.Background> <Grid> <Grid.RowDefinitions> <RowDefinition Height="."/> <RowDefinition Height="."/> <RowDefinition/> <RowDefinition Height="."/> </Grid.RowDefinitions> <!--上題目欄--> <Label Content="平安衛士界面" HorizontalAlignment="Left" Width="." Foreground="#AEFF" FontWeight="Bold" TextOptions.TextFormattingMode="Display"/> <Rectangle Margin="" Stroke="Black" HorizontalAlignment="Right" Width="." Grid.Row="" StrokeThickness=""> <Rectangle.Fill> <ImageBrush ImageSource="styles/skin/logo.png" Stretch="Uniform"/> </Rectangle.Fill> </Rectangle> <Button Content="x" HorizontalAlignment="Right" Margin=",,.," Width="." Name="closeButton" Click="closeButton_Click" /> <Button Content="max" HorizontalAlignment="Right" Margin=",,.," Width="." Name="maxButton" Click="maxButton_Click"> <Button.Background> <ImageBrush ImageSource="styles/skin/Button/MAX.png" Stretch="Uniform"/> </Button.Background> </Button> <Button Content="mni" HorizontalAlignment="Right" Margin=",,.," Width="." Name="mniButton" Click="mniButton_Click"> <Button.Background> <ImageBrush ImageSource="styles/skin/Button/MNI.png" Stretch="Uniform"/> </Button.Background> </Button> <Button x:Name="menuButton" HorizontalAlignment="Right" Margin=",,.," Width="." Click="menuButton_Click"> <Button.Background> <ImageBrush ImageSource="styles/skin/Button/M.png" Stretch="Uniform"/> </Button.Background> </Button> <Popup x:Name="Menu" AllowsTransparency="True" Margin=",-,," PlacementTarget="{Binding ElementName=menuButton}" StaysOpen="False" PopupAnimation="Scroll"> <Grid Height="." Width="" Margin="" HorizontalAlignment="Left"> <Border BorderThickness="" CornerRadius="" Background="#FFEFEFEF" Margin=""> <Border.Effect> <DropShadowEffect ShadowDepth="" Opacity="."/> </Border.Effect> <StackPanel Margin=","> <MenuItem Header="設 置" /> <MenuItem Header="更 新"/> <MenuItem Header="關 於"/> <MenuItem Header="退 出"/> </StackPanel> </Border> </Grid> </Popup> <Rectangle Stroke="Black" StrokeThickness="" Width="" Margin=",,.,." HorizontalAlignment="Right" Height=""> <Rectangle.Fill> <LinearGradientBrush EndPoint=".," StartPoint=".,"> <GradientStop Color="#"/> <GradientStop Offset="" Color="#ADDD"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Stroke="Black" StrokeThickness="" Width="" Margin=",,.,." HorizontalAlignment="Right" Height=""> <Rectangle.Fill> <LinearGradientBrush EndPoint=".," StartPoint=".,"> <GradientStop Color="#"/> <GradientStop Offset="" Color="#ADDD"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Stroke="Black" StrokeThickness="" Width="" Margin=",,.,." HorizontalAlignment="Right" Height=""> <Rectangle.Fill> <LinearGradientBrush EndPoint=".," StartPoint=".,"> <GradientStop Color="#"/> <GradientStop Offset="" Color="#ADDD"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Height="" Margin=",,.," Stroke="Black" StrokeThickness="" VerticalAlignment="Top"> <Rectangle.Fill> <LinearGradientBrush EndPoint=".," StartPoint=".,"> <GradientStop Color="#FFFFFF"/> <GradientStop Offset="" Color="#ADDD"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <!--上導航欄--> <TabControl Name="tab" Grid.RowSpan="" Margin="" Grid.Row="" Background="{x:Null}" SelectionChanged="TabControl_SelectionChanged"> <TabItem Header="電腦體驗" Height="" Margin=",,," Width="" TextOptions.TextFormattingMode="Display"> <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_Examine.png"/> </TabItem.Background> <Grid Margin="" Background="{DynamicResource MyBrush}"> <Grid.ColumnDefinitions> <ColumnDefinition Width=".*"/> <ColumnDefinition Width=".*"/> <ColumnDefinition Width=".*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="."/> <RowDefinition Height="."/> <RowDefinition Height="."/> <RowDefinition Height="."/> </Grid.RowDefinitions> <!--具體--> <Label Content="電腦體檢" HorizontalAlignment="Left" Margin="" Width="." Height="" FontSize="." FontWeight="Bold" Grid.Column="" Grid.Row="" Grid.ColumnSpan="" /> <pageTransitions:PageTransition Name="pTransitionControl_" Margin="" TransitionType="SlideAndFade" Grid.Column="" Grid.Row="" Grid.ColumnSpan="" Grid.RowSpan=""/> </Grid> </TabItem> <TabItem Header="查殺木馬" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_dsmain.png"/> </TabItem.Background> <Grid Margin="" Background="{DynamicResource MyBrush}"> <Grid.ColumnDefinitions> <ColumnDefinition Width=".*"/> <ColumnDefinition Width=".*"/> <ColumnDefinition Width=".*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="."/> <RowDefinition Height="."/> <RowDefinition Height="."/> <RowDefinition Height="."/> </Grid.RowDefinitions> <!--具體--> <Label Content="查殺木馬" HorizontalAlignment="Left" Margin="" Width="." Height="" FontSize="." FontWeight="Bold" Grid.Column="" Grid.Row="" Grid.ColumnSpan="" /> <pageTransitions:PageTransition Name="pTransitionControl_" Margin="" TransitionType="SlideAndFade" Grid.Column="" Grid.Row="" Grid.ColumnSpan="" Grid.RowSpan=""/> </Grid> </TabItem> <TabItem Header="清算插件" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_PluginCleaner.png"/> </TabItem.Background> <Grid Margin="" Background="{DynamicResource MyBrush}"> <Grid.ColumnDefinitions> <ColumnDefinition Width=".*"/> <ColumnDefinition Width=".*"/> <ColumnDefinition Width=".*"/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="."/> <RowDefinition Height="."/> <RowDefinition Height="."/> <RowDefinition Height="."/> </Grid.RowDefinitions> <!--具體--> <Label Content="清算插件" HorizontalAlignment="Left" Margin="" Width="." Height="" FontSize="." FontWeight="Bold" Grid.Column="" Grid.Row="" Grid.ColumnSpan="" /> <pageTransitions:PageTransition Name="pTransitionControl_" Margin="" TransitionType="SlideAndFade" Grid.Column="" Grid.Row="" Grid.ColumnSpan="" Grid.RowSpan=""/> </Grid> </TabItem> <TabItem Header="修復破綻" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_VulRepair.png"/> </TabItem.Background> <Grid Background="{DynamicResource MyBrush}"/> </TabItem> <TabItem Header="清算渣滓" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_RubbishCleaner.png"/> </TabItem.Background> <Grid Background="{DynamicResource MyBrush}"/> </TabItem> <TabItem Header="清算陳跡" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_TraceCleaner.png"/> </TabItem.Background> <Grid Background="{DynamicResource MyBrush}"/> </TabItem> <TabItem Header="體系修復" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_SysRepair.png"/> </TabItem.Background> <Grid Background="{DynamicResource MyBrush}"/> </TabItem> <TabItem Header="功效年夜全" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_AdvTools.png"/> </TabItem.Background> <Grid Background="{DynamicResource MyBrush}"/> </TabItem> <TabItem Header="軟件管家" Height="" Margin=",,," Width="" > <TabItem.Background> <ImageBrush ImageSource="styles/skin/ico/ico_softmgr.png"/> </TabItem.Background> <Grid Background="{DynamicResource MyBrush}"/> </TabItem> </TabControl> <!--導航具體--> <!--下狀況欄--> <Label Content="迎接應用仿體系" Margin="" Grid.Row="" Foreground="#AEFF" FontWeight="Bold" BorderThickness="" BorderBrush="White" HorizontalAlignment="Left" Width="." TextOptions.TextFormattingMode="Display" /> <Label Content="已銜接收集" Margin="" Grid.Row="" Foreground="#AEFF" FontWeight="Bold" BorderThickness="" BorderBrush="White" HorizontalAlignment="Right" Width="" TextOptions.TextFormattingMode="Display" /> </Grid> </Border> </Window> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace _UI { /// <summary> /// LikeMain.xaml 的交互邏輯 /// </summary> public partial class LikeMain : Window { public LikeMain() { InitializeComponent(); } private void closeButton_Click(object sender, RoutedEventArgs e) { this.Close(); } private void maxButton_Click(object sender, RoutedEventArgs e) { if (WindowState == WindowState.Normal) WindowState = WindowState.Maximized; else WindowState = WindowState.Normal; } private void mniButton_Click(object sender, RoutedEventArgs e) { this.WindowState = WindowState.Minimized; } private void menuButton_Click(object sender, RoutedEventArgs e) { Menu.IsOpen = true; } private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { //拖動 this.DragMove(); } private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { int index = this.tab.SelectedIndex; if (index == ) { //可以設置TransitionType WpfPage 來更改界面收支的動畫後果 //this.pTransitionControl_.TransitionType = WpfPageTransitions.PageTransitionType.SpinAndFade; pages.index newPage = new pages.index(); this.pTransitionControl_.ShowPage(newPage); } else if (index == ) { pages.scan newPage = new pages.scan(); this.pTransitionControl_.ShowPage(newPage); } else if (index == ) { pages.scan newPage = new pages.scan(); this.pTransitionControl_.ShowPage(newPage); } else { pages.index newPage = new pages.index(); this.pTransitionControl_.ShowPage(newPage); } } } }
當用戶單擊Tab頁簽時(切換事宜),法式 用pages.index newPage = new pages.index();先實例化一個page子頁面(現實繼續UserControl),然後挪用 this.pTransitionControl_1.ShowPage(newPage);將子頁面停止加載(實質上是pTransitionControl_1.Content=newpage)。
4、運轉代碼,界面以下:
上面是360平安衛士界面截圖,可比較一下,照樣比擬類似的。