WPF中采用MVVM模式编写win10中的便签样式

首先引入MVVM模式

在这里插入图片描述
在这里插入图片描述

win10的界面便笺设计

首先设计主窗体的mainwindow.xmal的样式
在这里插入图片描述

  • 这个button控件是图像按钮----采用SVG引入
    -如何引入SVG图像

  • 在阿里巴巴矢量库(iconfont矢量图)中先去下载用的素材,下载之后解压后是这样的
    在这里插入图片描述

  • 在项目中引入SVG的步骤

  • .ttf文件的的添加—>APP.xmal中引入iconfont.ttf—>运用到事例中去
    在这里插入图片描述
    在这里插入图片描述

子页面的样式

在这里插入图片描述

MainWindow.xmal样式代码

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="40" />
            <RowDefinition Height="40" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid x:Name="header"
              Grid.Row="0"
              Panel.ZIndex="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button x:Name="creatButton"
                    Grid.Column="0"
                    Width="40"
                    Height="40"
                    Click="creatButton_Click"
                    Content="&#xe627;"
                    FontFamily="{DynamicResource Iconfont}"
                    FontSize="16"
                    Style="{DynamicResource Button_Icon}" />
            <Grid x:Name="title"
                  Grid.Column="1"
                  Background="Transparent" />
            <StackPanel Grid.Column="2" Orientation="Horizontal">
                <Button x:Name="settingButton"
                        Width="40"
                        Height="40"
                        Content="&#xe60b;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="16"
                        Style="{DynamicResource Button_Icon}" />
                <Button x:Name="closeButton"
                        Width="40"
                        Height="40"
                        Click="closeButton_Click"
                        Content="&#xe742;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="16"
                        Style="{DynamicResource Button_Icon}" />
            </StackPanel>
        </Grid>
        <TextBlock Grid.Row="1"
                   Margin="10,5"
                   VerticalAlignment="Center"
                   FontFamily="微软雅黑"
                   FontSize="22"
                   FontWeight="Bold"
                   Text="便笺" />
        <Controls:SerachBar Grid.Row="2" />
        <StackPanel Grid.Row="3">
            <ListBox Width="300"
                     Height="490"
                     ItemsSource="{Binding NoteTextProperty}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Background="{Binding Background}">
                            <StackPanel>
                                <TextBlock Width="300"
                                           Height="100"
                                           FontSize="{Binding FontSize}"
                                           Text="{Binding Content}"
                                           TextWrapping="Wrap" />
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <vm:EventToCommand Command="{Binding TextCommand}" PassEventArgsToCommand="True" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </ListBox>
        </StackPanel>
    </Grid>

NoteWindow.xmal样式代码

 <Grid Background="#D3D3D3">
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition />
            <RowDefinition Height="40" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Background="#696969">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40" />
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button x:Name="creatButton"
                    Grid.Column="0"
                    Width="40"
                    Height="40"
                    Click="creatButton_Click"
                    Content="&#xe627;"
                    FontFamily="{DynamicResource Iconfont}"
                    FontSize="16"
                    Style="{DynamicResource Button_Icon}" />
            <Grid x:Name="title"
                  Grid.Column="1"
                  Background="Transparent">
                <Grid.RowDefinitions>
                    <RowDefinition Height="17*" />
                    <RowDefinition Height="23*" />
                </Grid.RowDefinitions>
            </Grid>
            <StackPanel Grid.Column="2" Orientation="Horizontal">
                <Button x:Name="settingButton"
                        Width="40"
                        Height="40"
                        Click="settingButton_Click"
                        Content="&#xe609;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="16"
                        Style="{DynamicResource Button_Icon}" />
                <Popup x:Name="settingPop1"
                       AllowsTransparency="True"
                       HorizontalOffset="-350"
                       Placement="Bottom"
                       PlacementTarget="{Binding ElementName=settingButton}">
                    <Grid Width="430" Height="78">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <RadioButton Grid.Column="0"
                                     IsChecked="True"
                                     Style="{DynamicResource RadioThemeColor}" />
                        <RadioButton Grid.Column="1"
                                     Background="Bisque"
                                     Style="{DynamicResource RadioThemeColor}" />
                        <RadioButton Grid.Column="2"
                                     Background="LightBlue"
                                     Style="{DynamicResource RadioThemeColor}" />
                        <RadioButton Grid.Column="3"
                                     Background="White"
                                     Style="{DynamicResource RadioThemeColor}" />
                        <RadioButton Grid.Column="4"
                                     Background="Gray"
                                     Style="{DynamicResource RadioThemeColor}" />
                    </Grid>
                </Popup>
                <Button x:Name="closeButton"
                        Width="40"
                        Height="40"
                        Click="closeButton_Click"
                        Content="&#xe742;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="16"
                        Style="{DynamicResource Button_Icon}" />
            </StackPanel>
        </Grid>
        <TextBox x:Name="noteText"
                 Grid.Row="1"
                 Background="{Binding Background}"
                 FontFamily="{Binding FontFamily}"
                 FontSize="{Binding FontSize}"
                 Text="{Binding Content, UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"
                 TextWrapping="Wrap" AcceptsReturn="True" />
        <Grid Grid.Row="2" Background="#BEBEBE">
            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal ">
                <Button x:Name="boldButton"
                        Width="40"
                        Height="40"
                        Content="&#xe611;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="14"
                        Style="{DynamicResource Button_Icon}" />
                <Button x:Name="tiltButton"
                        Width="40"
                        Height="40"
                        Content="&#xe608;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="16"
                        Style="{DynamicResource Button_Icon}" />
                <Button x:Name="UnderscoreButton"
                        Width="40"
                        Height="40"
                        Content="&#xe628;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="20"
                        Style="{DynamicResource Button_Icon}" />
                <Button x:Name="deleteButton"
                        Width="40"
                        Height="40"
                        Content="&#xe605;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="14"
                        Style="{DynamicResource Button_Icon}" />
                <Button x:Name="projectButton"
                        Width="40"
                        Height="40"
                        Content="&#xe6c1;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="12"
                        Style="{DynamicResource Button_Icon}" />
                <Button x:Name="imageButton"
                        Width="40"
                        Height="40"
                        Content="&#xe616;"
                        FontFamily="{DynamicResource Iconfont}"
                        FontSize="22"
                        Style="{DynamicResource Button_Icon}" />
            </StackPanel>
        </Grid>
    </Grid>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
代码介绍 MetroForWinForm(win8风格模版) using System; using System.Drawing; using System.Globalization; using System.Windows.Forms; using MetroFramework.Forms; namespace MetroFramework.Demo { public partial class MainForm : MetroForm { public MainForm() { InitializeComponent(); metroStyleManager.Theme = MetroThemeStyle.Default; metroStyleManager.Style = MetroColorStyle.Teal; } private void metroTileSwitch_Click(object sender, EventArgs e) { var m = new Random(); int next = m.Next(0, 13); metroStyleManager.Style = (MetroColorStyle)next; } private void metroTile1_Click(object sender, EventArgs e) { metroStyleManager.Theme = metroStyleManager.Theme == MetroThemeStyle.Light ? MetroThemeStyle.Dark : MetroThemeStyle.Light; } private void metroButton1_Click(object sender, EventArgs e) { MetroTaskWindow.ShowTaskWindow(this, "SubControl in TaskWindow", new TaskWindowControl(), 10); } private void metroButton2_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "Do you like this metro message box?", "Metro Title", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Asterisk); } private void metroButton5_Click(object sender, EventArgs e) { metroContextMenu1.Show(metroButton5, new Point(0, metroButton5.Height)); } private void metroButton6_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `OK` only button", "MetroMessagebox", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void metroButton10_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `OK` and `Cancel` button", "MetroMessagebox", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); } private void metroButton7_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Yes` and `No` button", "MetroMessagebox", MessageBoxButtons.YesNo, MessageBoxIcon.Question); } private void metroButton8_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Yes`, `No` and `Cancel` button", "MetroMessagebox", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); } private void metroButton11_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Retry` and `Cancel` button. With warning style.", "MetroMessagebox", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning); } private void metroButton9_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample MetroMessagebox `Abort`, `Retry` and `Ignore` button. With Error style.", "MetroMessagebox", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); } private void metroButton12_Click(object sender, EventArgs e) { MetroMessageBox.Show(this, "This is a sample `default` MetroMessagebox ", "MetroMessagebox"); } private void metroButton4_Click(object sender, EventArgs e) { var testform = new TestForm1(); testform.ShowDialog(); } private void metroButton4_Click_1(object sender, EventArgs e) { metroTextBox2.Focus(); } } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值