国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03

這篇具有很好參考價(jià)值的文章主要介紹了Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

?一.實(shí)現(xiàn)左側(cè)菜單綁定

效果圖:Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpfWpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf


1.首先需要在項(xiàng)目中創(chuàng)建?mvvm 的架構(gòu)模式

Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf

  • ? 創(chuàng)建 Models ,放置實(shí)體類。

實(shí)體類需要繼承自Prism 框架的?BindableBase,目的是讓實(shí)體類支持?jǐn)?shù)據(jù)的動(dòng)態(tài)變更!

  • ?例如: 系統(tǒng)導(dǎo)航菜單實(shí)體類
/ <summary>
	/// 系統(tǒng)導(dǎo)航菜單實(shí)體類
	/// </summary>
public class MenuBar:BindableBase
 {
		private string icon;

		/// <summary>
		/// 菜單圖標(biāo)
		/// </summary>
		public string Icon
		{
get { return icon; }
set { icon = value; }
		}

		private string title;

		/// <summary>
		/// 菜單名稱
		/// </summary>
		public string Title
		{
get { return title; }
set { title = value; }
		}

		private string nameSpace;

		/// <summary>
		/// 菜單命名空間
		/// </summary>
		public string NameSpace
		{
get { return nameSpace; }
set { nameSpace = value; }
		}

	}

  • 創(chuàng)建View文件夾? 放置前端顯示頁面 。例如:創(chuàng)建首頁:MainView.xaml
  • 創(chuàng)建ViewModel 文件夾,放置前端邏輯處理類。意思是:有前端頁面同時(shí),也要有對(duì)應(yīng)的后臺(tái)業(yè)務(wù)邏輯處理類。例如:MainViewModel

?Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf

  1. 使用了Prism 框架,一些視圖或類的定義都是有約定的。例如:視圖統(tǒng)一使用xxxView?結(jié)尾。視圖模形統(tǒng)一使用xxxViewModel 結(jié)尾。這樣做的原因是:第一規(guī)范,第二,方便使用 Prism 進(jìn)行動(dòng)態(tài)的方式綁定上下文的時(shí)候,能自動(dòng)找到對(duì)應(yīng)類。
  2. Prism 動(dòng)態(tài)上下文綁定方式,引入命名空間,把 AutoWireViewModel 設(shè)置成 True
 xmlns:prism="http://prismlibrary.com/"
 prism:ViewModelLocator.AutoWireViewModel="True"

2.創(chuàng)建MainViewModel 邏輯處理類

MainViewModel 類同樣也需要繼承自Prism 框架的?BindableBase?

  • ?創(chuàng)建左側(cè)菜單的數(shù)據(jù),需要使用到一個(gè)動(dòng)態(tài)的屬性集合 ObservableCollection 來存放菜單的數(shù)據(jù)

Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf

  • 創(chuàng)建菜單數(shù)據(jù)
    public class MainViewModel: BindableBase
    {
        public MainViewModel()
        {
            MenuBars=new ObservableCollection<MenuBar>();
            CreateMenuBar();
        }
        private ObservableCollection<MenuBar> menuBars;

        public ObservableCollection<MenuBar> MenuBars
        {
            get { return menuBars; }
            set { menuBars = value; RaisePropertyChanged(); }
        }
        void CreateMenuBar()
        {
            MenuBars.Add(new MenuBar() { Icon="Home",Title="首頁",NameSpace="IndexView"});
            MenuBars.Add(new MenuBar() { Icon = "NotebookCheckOutline", Title = "待辦事項(xiàng)", NameSpace = "ToDoView" });
            MenuBars.Add(new MenuBar() { Icon = "NotebookPlusOutline", Title = "忘備錄", NameSpace = "MemoView" });
            MenuBars.Add(new MenuBar() { Icon = "Cog", Title = "設(shè)置", NameSpace = "SettingsView" });
        }
    }
  • NameSpace:主要用于導(dǎo)航
  • Icon:是Material DesignThemes UI 框架里面的圖標(biāo)名稱

3.MainView.xaml 前端綁定數(shù)據(jù)

  • ?列表數(shù)據(jù)的綁定,使用ListBox 的自定義模板,也就是?ListBox.ItemTemplate,并且寫法是固定的
<!--列表-->
<ListBox>
    <ListBox.ItemTemplate>
        <DataTemplate>
            <!--在這里添加內(nèi)容數(shù)據(jù)-->
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
  • 例如:結(jié)合上面創(chuàng)建MainViewModel 類,給MainView.xaml 渲染數(shù)據(jù)
<!--列表-->
<ListBox ItemsSource="{Binding MenuBars}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <materialDesign:PackIcon Kind="{Binding Icon}" Margin="15,0" />
                <TextBlock Text="{Binding Title}" Margin="10,0"/>
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
  • ?MainView.xaml 添加動(dòng)態(tài)綁定 上下文
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True"

注意:項(xiàng)目中的MainWindow.xaml 已經(jīng)改成了MainView.xaml,并且把啟動(dòng)頁設(shè)置成 MainView了

Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf

  • 最終項(xiàng)目結(jié)構(gòu)?

Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf

?4.左側(cè)菜單樣式調(diào)整

  • 在App.xaml 資源文件中,更改默認(rèn)的主題顏色

Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf

  • 更改左側(cè)列表選擇的樣式?

?重寫自定義樣式

  • 在App.xaml 文件中 資源字典 ResourceDictionary 節(jié)點(diǎn)中,設(shè)置Style 屬性來進(jìn)行樣式重寫

Style 使用方式

  1. ?TargetType :設(shè)置作用的目標(biāo)類型
  2. ?Setter :設(shè)計(jì)器,里面有2個(gè)常用屬性,分別是Property 和Value。用來改變設(shè)置作用的目標(biāo)類型一些屬性的值
  3. key: 通過指定的key 來使用重寫的樣式

例如:設(shè)置ListBoxItem 屬性中的最小行高為40

<Style TargetType="ListBoxItem">
    <Setter Property="MinHeight" Value="40"/>
</Style>

? ? ?3.?Property 中有一個(gè)特別的屬性:Template。用于改變控件的外觀樣式。并且也有固定的寫法

<Setter Property="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:Type ListBoxItem}">
            
        </ControlTemplate>
    </Setter.Value>
</Setter>

?TargetType 有2種寫法

  1. 一種是直接用Style 設(shè)置一些屬性,可以這樣寫 TargetType="ListBoxItem"
  2. 另外一種寫法是,當(dāng)需要使用到自定義模板,也就是要改變控件的外觀樣式時(shí),Property 設(shè)置的值為?Template,里面TargetType 寫法就變成這樣?TargetType="{x:Type ListBoxItem}"
  3. 使用自定義的模板時(shí),需要使用到一個(gè)屬性?ContentPresenter,把原有模板的屬性原封不動(dòng)的投放到自定義模板。

? ? 4. 觸發(fā)器,它按條件應(yīng)用屬性值或執(zhí)行操作

?如果使用Template 自定義控件樣式后,需要搭配觸發(fā)器進(jìn)行使用。

例如:

<ControlTemplate TargetType="{x:Type ListBoxItem}">
    <Grid>
        <!--內(nèi)容最左側(cè)的樣式-->
        <Border x:Name="borderHeader"/>
        <!--內(nèi)容選中的樣式-->
        <Border x:Name="border"/>
        <!--內(nèi)容呈現(xiàn),使用自定義模板時(shí),不加該屬性,原先的內(nèi)容無法呈現(xiàn)-->
        <ContentPresenter 
            HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
    </Grid>
     <!--觸發(fā)器-->
    <ControlTemplate.Triggers>
        <!--如果是選中狀態(tài)-->
        <Trigger Property="IsSelected" Value="True">
            <!--第一個(gè)Border 設(shè)置邊框樣式-->
            <Setter Property="BorderThickness" TargetName="borderHeader" Value="4,0,0,0"/>
            <!--第一個(gè)Border 設(shè)置邊框顏色,value 動(dòng)態(tài)綁定主要是為了適應(yīng)主題顏色更改時(shí),邊框也著變-->
            <Setter Property="BorderBrush" TargetName="borderHeader" Value="{DynamicResource PrimaryHueLightBrush}"/>
            <!--第二個(gè)border 設(shè)置選中的樣式-->
            <Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/>
            <!--第二個(gè)border 設(shè)置選中的透明度-->
            <Setter Property="Opacity" TargetName="border" Value="0.2"/>
        </Trigger>
        <!--鼠標(biāo)懸停觸發(fā)器,如果鼠標(biāo)懸停時(shí)-->
        <Trigger Property="IsMouseOver" Value="True">
            <!--第二個(gè)border 設(shè)置選中的樣式-->
            <Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/>
            <!--第二個(gè)border 設(shè)置選中的透明度-->
            <Setter Property="Opacity" TargetName="border" Value="0.2"/>
        </Trigger>
    </ControlTemplate.Triggers>
</ControlTemplate>

? ?5. 樣式寫完后,需要在MainView.xmal 的ListBox中使用這個(gè)樣式資源文件,通過指定Key 來使用。

Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03,WPF入門,wpf文章來源地址http://www.zghlxwxcb.cn/news/detail-714195.html

?二.源碼

1.MainView.xaml

<Window x:Class="MyToDo.Views.MainView"
        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:MyToDo"
        xmlns:prism="http://prismlibrary.com/"
        prism:ViewModelLocator.AutoWireViewModel="True"
        WindowStyle="None" WindowStartupLocation="CenterScreen" AllowsTransparency="True"
         Style="{StaticResource MaterialDesignWindow}"
        TextElement.Foreground="{DynamicResource MaterialDesignBody}"
        Background="{DynamicResource MaterialDesignPaper}"
        TextElement.FontWeight="Medium"
        TextElement.FontSize="14"
        FontFamily="{materialDesign:MaterialDesignFont}"
        mc:Ignorable="d"
        xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
        Title="MainWindow" Height="768" Width="1280">
    <materialDesign:DialogHost DialogTheme="Inherit"
                           Identifier="RootDialog"
                           SnackbarMessageQueue="{Binding ElementName=MainSnackbar, Path=MessageQueue}">

        <materialDesign:DrawerHost IsLeftDrawerOpen="{Binding ElementName=MenuToggleButton, Path=IsChecked}">
            <!--左邊菜單-->
            <materialDesign:DrawerHost.LeftDrawerContent>
                <DockPanel MinWidth="220" >
                 
                    <!--頭像-->
                    <StackPanel DockPanel.Dock="Top" Margin="0,20">
                        <Image Source="/Images/user.jpg" Width="50" Height="50">
                            <Image.Clip>
                                <EllipseGeometry Center="25,25" RadiusX="25" RadiusY="25" />
                            </Image.Clip>
                        </Image>
                        <TextBlock Text="WPF gg" Margin="0,10" HorizontalAlignment="Center" />
                    </StackPanel>
                    
                    <!--列表-->
                    <ListBox ItemContainerStyle="{StaticResource MyListBoxItemStyle}" ItemsSource="{Binding MenuBars}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" Background="Transparent">
                                    <materialDesign:PackIcon Kind="{Binding Icon}" Margin="15,0" />
                                    <TextBlock Text="{Binding Title}" Margin="10,0"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    
                    
                </DockPanel>
            </materialDesign:DrawerHost.LeftDrawerContent>

            <DockPanel >
                <!--導(dǎo)航條色塊-->
                <materialDesign:ColorZone Padding="16" x:Name="ColorZone"
                                materialDesign:ElevationAssist.Elevation="Dp4"
                                DockPanel.Dock="Top"
                                Mode="PrimaryMid">
                    <DockPanel LastChildFill="False">
                        <!--上左邊內(nèi)容-->
                        <StackPanel Orientation="Horizontal">
                            <ToggleButton x:Name="MenuToggleButton"
                          AutomationProperties.Name="HamburgerToggleButton"
                          IsChecked="False"
                          Style="{StaticResource MaterialDesignHamburgerToggleButton}" />

                            <Button Margin="24,0,0,0"
                    materialDesign:RippleAssist.Feedback="{Binding RelativeSource={RelativeSource Self}, Path=Foreground, Converter={StaticResource BrushRoundConverter}}"
                    Command="{Binding MovePrevCommand}"
                    Content="{materialDesign:PackIcon Kind=ArrowLeft,
                                                      Size=24}"
                    Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"
                    Style="{StaticResource MaterialDesignToolButton}"
                    ToolTip="Previous Item" />

                            <Button Margin="16,0,0,0"
                    materialDesign:RippleAssist.Feedback="{Binding RelativeSource={RelativeSource Self}, Path=Foreground, Converter={StaticResource BrushRoundConverter}}"
                    Command="{Binding MoveNextCommand}"
                    Content="{materialDesign:PackIcon Kind=ArrowRight,
                                                      Size=24}"
                    Foreground="{Binding RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}, Path=(TextElement.Foreground)}"
                    Style="{StaticResource MaterialDesignToolButton}"
                    ToolTip="Next Item" />
                            <TextBlock Margin="16,0,0,0"
                             HorizontalAlignment="Center"
                             VerticalAlignment="Center"
                             AutomationProperties.Name="Material Design In XAML Toolkit"
                             FontSize="22"
                             Text="筆記本" />
                        </StackPanel>
                        <!--上右邊圖標(biāo)-->
                        <StackPanel DockPanel.Dock="Right" Orientation="Horizontal">
                            <Image Source="/Images/user.jpg" Width="25" Height="25">
                                <Image.Clip>
                                    <EllipseGeometry Center="12.5,12.5" RadiusX="12.5" RadiusY="12.5" />
                                </Image.Clip>
                            </Image>
                            <Button x:Name="btnMin" Style="{StaticResource MaterialDesignFlatMidBgButton}">
                                <materialDesign:PackIcon Kind="MoveResizeVariant" />
                            </Button>
                            <Button x:Name="btnMax" Style="{StaticResource MaterialDesignFlatMidBgButton}">
                                <materialDesign:PackIcon Kind="CardMultipleOutline" />
                            </Button>
                            <Button x:Name="btnClose" Style="{StaticResource MaterialDesignFlatMidBgButton}" Cursor="Hand">
                                <materialDesign:PackIcon Kind="WindowClose" />
                            </Button>
                        </StackPanel>
                    </DockPanel>

                </materialDesign:ColorZone>


            </DockPanel>
        </materialDesign:DrawerHost>
    </materialDesign:DialogHost>
</Window>

2.MainViewModel

namespace MyToDo.ViewModels
{
    public class MainViewModel: BindableBase
    {
        public MainViewModel()
        {
            MenuBars=new ObservableCollection<MenuBar>();
            CreateMenuBar();
        }
        private ObservableCollection<MenuBar> menuBars;

        public ObservableCollection<MenuBar> MenuBars
        {
            get { return menuBars; }
            set { menuBars = value; RaisePropertyChanged(); }
        }
        void CreateMenuBar()
        {
            MenuBars.Add(new MenuBar() { Icon="Home",Title="首頁",NameSpace="IndexView"});
            MenuBars.Add(new MenuBar() { Icon = "NotebookCheckOutline", Title = "待辦事項(xiàng)", NameSpace = "ToDoView" });
            MenuBars.Add(new MenuBar() { Icon = "NotebookPlusOutline", Title = "忘備錄", NameSpace = "MemoView" });
            MenuBars.Add(new MenuBar() { Icon = "Cog", Title = "設(shè)置", NameSpace = "SettingsView" });
        }
    }
}

3.App.xaml

<prism:PrismApplication x:Class="MyToDo.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:MyToDo"
             xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
             xmlns:prism="http://prismlibrary.com/">
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <materialDesign:BundledTheme BaseTheme="Dark" PrimaryColor="DeepPurple" SecondaryColor="Lime" />
                <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style x:Key="MyListBoxItemStyle" TargetType="ListBoxItem">
                <Setter Property="MinHeight" Value="40"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                            <Grid>
                                <!--內(nèi)容最左側(cè)的樣式-->
                                <Border x:Name="borderHeader"/>
                                <!--內(nèi)容選中的樣式-->
                                <Border x:Name="border"/>
                                <!--內(nèi)容呈現(xiàn),使用自定義模板時(shí),不加該屬性,原先的內(nèi)容無法呈現(xiàn)-->
                                <ContentPresenter 
                                    HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </Grid>
                             <!--觸發(fā)器-->
                            <ControlTemplate.Triggers>
                                <!--如果是選中狀態(tài)-->
                                <Trigger Property="IsSelected" Value="True">
                                    <!--第一個(gè)Border 設(shè)置邊框樣式-->
                                    <Setter Property="BorderThickness" TargetName="borderHeader" Value="4,0,0,0"/>
                                    <!--第一個(gè)Border 設(shè)置邊框顏色,value 動(dòng)態(tài)綁定主要是為了適應(yīng)主題顏色更改時(shí),邊框也著變-->
                                    <Setter Property="BorderBrush" TargetName="borderHeader" Value="{DynamicResource PrimaryHueLightBrush}"/>
                                    <!--第二個(gè)border 設(shè)置選中的樣式-->
                                    <Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/>
                                    <!--第二個(gè)border 設(shè)置選中的透明度-->
                                    <Setter Property="Opacity" TargetName="border" Value="0.2"/>
                                </Trigger>
                                <!--鼠標(biāo)懸停觸發(fā)器,如果鼠標(biāo)懸停時(shí)-->
                                <Trigger Property="IsMouseOver" Value="True">
                                    <!--第二個(gè)border 設(shè)置選中的樣式-->
                                    <Setter Property="Background" TargetName="border" Value="{DynamicResource PrimaryHueLightBrush}"/>
                                    <!--第二個(gè)border 設(shè)置選中的透明度-->
                                    <Setter Property="Opacity" TargetName="border" Value="0.2"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>
    </Application.Resources>
</prism:PrismApplication>

到了這里,關(guān)于Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day03的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day13

    Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day13

    在上一節(jié)? ToDoController 控制器,或 IToDoService 服務(wù)接口中,方法的傳參都是直接傳的實(shí)體類。但在實(shí)際開發(fā)過程中,這樣是不允許的。標(biāo)準(zhǔn)且規(guī)范的做法是,定義一個(gè)數(shù)據(jù)傳輸層,即Dto層。 1. 創(chuàng)建 BaseDto 基類,用于存放共用屬性。 2. 創(chuàng)建待辦事項(xiàng) Dto類,并繼承自 BaseDto 基類

    2024年01月20日
    瀏覽(42)
  • Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day10

    Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day10

    1-9章節(jié)已經(jīng)把基本功能都做好了,但頁面的數(shù)據(jù)是后臺(tái)模擬生成的靜態(tài)數(shù)據(jù)。接下來所有章節(jié)就是實(shí)現(xiàn),頁面的所有數(shù)據(jù)都是從數(shù)據(jù)庫中獲取,并且實(shí)現(xiàn)頁面數(shù)據(jù)的持久化以及增刪改查。 使用Sqlite 做為數(shù)據(jù)庫? 1.打開 MyToDo.Api項(xiàng)目,右鍵=》選擇 管理NuGet 程序包?,進(jìn)行下載安

    2024年01月25日
    瀏覽(21)
  • Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day11

    Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day11

    ?倉儲(chǔ)(rep):倉儲(chǔ)接口定義了對(duì)實(shí)體類訪問數(shù)據(jù)庫及操作的方法。它統(tǒng)一管理數(shù)據(jù)訪問的邏輯,并與業(yè)務(wù)邏輯層進(jìn)行解耦。 簡單的理解就是對(duì)訪問數(shù)據(jù)庫的一層接口封裝。 工作單元(uow):用來保證我們處理業(yè)務(wù)邏輯的,穩(wěn)定性,完整性。防止在業(yè)務(wù)操作過程中,涉及對(duì)數(shù)據(jù)

    2024年02月02日
    瀏覽(31)
  • Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day08

    Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day08

    1.效果圖 MemoView.xaml 頁面代碼 ? ? ?1. 在? ItemsControl 中,添加滾動(dòng)條? ScrollViewer ?這樣使用 ScrollViewer 把內(nèi)容區(qū)域包裹起來,就能讓內(nèi)容區(qū)域支持滾動(dòng)了 ? ? ?? 2 . 添加滾動(dòng)條后的效果圖如下:? 使用md 中的一個(gè)自帶動(dòng)畫 md:TransitioningContent 來實(shí)現(xiàn)該功能? 需要設(shè)置一個(gè)屬性,

    2024年02月03日
    瀏覽(20)
  • Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day19

    Wpf 使用 Prism 實(shí)戰(zhàn)開發(fā)Day19

    由于待辦事項(xiàng)功能頁,數(shù)據(jù)已正常渲染出來了。但頁面新增,查詢,修改,刪除等功能還未實(shí)現(xiàn)。本章節(jié)來實(shí)現(xiàn)頁面的請(qǐng)求后臺(tái)實(shí)現(xiàn)CURD(增刪改查) 根據(jù)渲染出來的待辦事項(xiàng),點(diǎn)擊對(duì)應(yīng)的待辦事項(xiàng)時(shí),查找出該條數(shù)據(jù),顯展示在編輯窗口中。 同時(shí)在搜索框中輸入的參數(shù)或選

    2024年04月23日
    瀏覽(26)
  • WPF超好用的框架Prism入門使用,上位機(jī)趕緊學(xué)起來!

    WPF框架Prism是一種用于開發(fā)模塊化、可重用和可測試的WPF應(yīng)用程序的框架。它提供了一種簡單而強(qiáng)大的方式來管理復(fù)雜應(yīng)用程序的代碼和構(gòu)建高度可擴(kuò)展的應(yīng)用程序。 如果您想使用Prism框架來開發(fā)WPF應(yīng)用程序,需要學(xué)習(xí)以下幾個(gè)方面: MVVM模式 :Prism基于MVVM模式,因此需要了

    2024年02月01日
    瀏覽(44)
  • WPF開發(fā)學(xué)生信息管理系統(tǒng)【W(wǎng)PF+Prism+MAH+WebApi】(四)

    WPF開發(fā)學(xué)生信息管理系統(tǒng)【W(wǎng)PF+Prism+MAH+WebApi】(四)

    最近通過WPF開發(fā)項(xiàng)目,為了對(duì)WPF知識(shí)點(diǎn)進(jìn)行總結(jié),所以利用業(yè)余時(shí)間,開發(fā)一個(gè)學(xué)生信息管理系統(tǒng)【Student Information Management System】。前三篇文章進(jìn)行了框架搭建和模塊劃分,后臺(tái)WebApi接口編寫,以及課程管理模塊開發(fā),本文在前三篇基礎(chǔ)之上,繼續(xù)深入開發(fā)學(xué)生信息管理系統(tǒng)

    2024年02月04日
    瀏覽(33)
  • WPF開發(fā)之Prism詳解【內(nèi)附源碼】

    WPF開發(fā)之Prism詳解【內(nèi)附源碼】

    在實(shí)際應(yīng)用開發(fā)中,隨著項(xiàng)目業(yè)務(wù)逐漸復(fù)雜,耦合度會(huì)越來越高,維護(hù)成本也會(huì)直線上升,所以解耦也變得越來越重要。Prism框架為WPF開發(fā)中解耦提供了非常便捷的應(yīng)用。今天主要以一個(gè)簡單的小例子,簡述WPF開發(fā)中Prism框架的簡單應(yīng)用,如有不足之處,還請(qǐng)指正。 Prism是一個(gè)

    2023年04月16日
    瀏覽(30)
  • WPF Prism的簡單使用

    新建 WPF 項(xiàng)目,我是基于 .net 5.0-windows 創(chuàng)建的。 引入 Prism.DryIoc(8.1.97) 的 Nuget 包。 App.xaml 中引入命名空間。 將 App.xaml 中 Application 標(biāo)簽更改成 prism:PrismApplication 并去除 StartUri 屬性,將 App.xaml.cs 中 Application 更改成 PrismApplication 。 實(shí)現(xiàn) PrismApplication (實(shí)際上是 PrismApplicationBas

    2023年04月14日
    瀏覽(17)
  • WPF框架Prism的使用 二

    這是第二篇關(guān)于Prism-WPF的介紹,第一篇中我們簡單介紹了Prism,然后講述了如何搭建一個(gè)MVVM的簡單頁面程序。其實(shí)我寫的文章就是把github上面的官方例子摘出來自己跑了一遍,然后加上了一些自己的理解,簡單給大家分享一下。 下面放上傳送門: 第一篇的鏈接 官方提供的示

    2024年04月10日
    瀏覽(26)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包