zoukankan      html  css  js  c++  java
  • WPF 01 基础

    效果图

     逻辑代码

        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void ApliButton_Click(object sender, RoutedEventArgs e)
            {
                MessageBox.Show($"The Description is hi");
            }
    
            private void ResetButton_Click(object sender, RoutedEventArgs e)
            {
                WeldCheckbox.IsChecked = AssemblyCheckbox.IsChecked = PlasmaCheckbox.IsChecked = LaserCheckbox.IsChecked = PurchesCheckbox.IsChecked =false;
            }
    
            private void Checkbox_Checked(object sender, RoutedEventArgs e)
            {
                this.LengthText.Text += ((CheckBox)sender).Content.ToString();
            }
    
            private void FinishedDropDown_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                if(this.NoteText == null)
                {
                    return;
                }
                var cb = (ComboBox)sender;
                var value = (ComboBoxItem)cb.SelectedValue;
                this.NoteText.Text += (string)value.Content;
            }
    
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                FinishedDropDown_SelectionChanged(FinishedDropDown, null);
            }
    
            private void SupplierNameText_TextChanged(object sender, TextChangedEventArgs e)
            {
                this.MassText.Text = this.SupplierNameText.Text;
            }
        }

    样式代码

    <Window x:Class="Wpf01Base.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:Wpf01Base"
            mc:Ignorable="d"
            Title="MainWindow" Height="788.75" Width="540" Loaded="Window_Loaded">
        
        <Border Padding="10">
            <StackPanel>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Button x:Name="ApliButton" Click="ApliButton_Click" Margin="0 0 10 0" Grid.Column="0" Content="Apply"></Button>
                    <Button x:Name="ResetButton" Click="ResetButton_Click" Grid.Column="1" Content="Reset"></Button>
                    <Button Margin="10 0 0 0 " Grid.Column="2" Content="Refresh"></Button>
                </Grid>
                <TextBlock Text="Pilse Properties" FontWeight="Bold" Margin="0 10"></TextBlock>
                <TextBlock x:Name="DecriptionText" Text="Description"></TextBlock>
                <TextBox Padding="2"></TextBox>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="2*"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Column="0" Margin="0 0 10 0">
                        <TextBlock Text="Status"/>
                        <TextBox IsReadOnly="True" Padding="2" Background="#eee"/>
                    </StackPanel>
                    <StackPanel Grid.Column="1">
                        <TextBlock Text="Revision"/>
                        <TextBox IsReadOnly="True" Padding="2" Background="#eee"/>
                    </StackPanel>
                </Grid>
                <TextBlock Text="Part Number"></TextBlock>
                <TextBox Padding="2" Background="#eee" IsReadOnly="True"></TextBox>
                <TextBlock Text="Raw Material" FontWeight="Bold" Margin=" 0 10 "></TextBlock>
                <TextBlock Text="Material"></TextBlock>
                <ComboBox Padding="2"/>
                <TextBlock Text="Manufactureing Info" FontWeight="Bold" Margin=" 0 10 "></TextBlock>
                <TextBlock Text="Work Centers" Margin="0 0 0 10"></TextBlock>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Column="0" Margin="0 0 10 0">
                        <CheckBox Checked="Checkbox_Checked" x:Name="WeldCheckbox" Content="Weld"/>
                        <CheckBox Checked="Checkbox_Checked" x:Name="AssemblyCheckbox" Content="Assembly"/>
                        <CheckBox Checked="Checkbox_Checked" x:Name="PlasmaCheckbox" Content="Plasma"/>
                        <CheckBox Checked="Checkbox_Checked" x:Name="LaserCheckbox" Content="Laser"/>
                        <CheckBox Checked="Checkbox_Checked" x:Name="PurchesCheckbox" Content="Purches"/>
                    </StackPanel>
                    <StackPanel Grid.Column="1">
                        <CheckBox Content="Lathe"/>
                        <CheckBox Content="Drill"/>
                        <CheckBox Content="Fold"/>
                        <CheckBox Content="Roll"/>
                        <CheckBox Content="Saw"/>
                    </StackPanel>
                </Grid>
                <TextBlock  Text="Length"/>
                <TextBox x:Name="LengthText" Padding="2"/>
                <TextBlock Text="Mass"/>
                <TextBox x:Name="MassText" Padding="2" IsReadOnly="True" Background="#eee"/>
                <TextBlock Text="Finish"/>
                <ComboBox x:Name="FinishedDropDown" SelectionChanged="FinishedDropDown_SelectionChanged" Padding="2" IsReadOnly="True" Background="#eee">
                    <ComboBoxItem IsSelected="True">Painted</ComboBoxItem>
                    <ComboBoxItem>No Painted</ComboBoxItem>
                </ComboBox>
                <TextBlock Text="Purches Information"/>
                <ComboBox Padding="2" IsReadOnly="True" Background="#eee">
                    <ComboBoxItem IsSelected="True">Rubber</ComboBoxItem>
                    <ComboBoxItem>No Rubber</ComboBoxItem>
                </ComboBox>
                <TextBlock Text="Supplier Name"/>
                <TextBox x:Name="SupplierNameText" TextChanged="SupplierNameText_TextChanged"  Padding="2"/>
                <TextBlock Text="Supplier Code"/>
                <TextBox Padding="2"/>
                <TextBlock Text="Additional Information" FontWeight="Bold" Margin=" 0 10 "></TextBlock>
                <TextBlock Text="Note"></TextBlock>
                <TextBox x:Name="NoteText" Padding="2"/>
            </StackPanel>
            
            
        </Border>
        
        
    </Window>
  • 相关阅读:
    内置函数拾遗
    jQuery与其他JS库冲突解决
    ckeditor+ckfinder添加水印。
    PostgreSQL与mysql的比较
    php函数 之 iconv 不是php的默认函数,也是默认安装的模块。需要安装才能用的。
    php mb_substr()函数的详细解释!
    成为一名PHP专家其实并不难
    php中级程序员的进化标准
    鼠标经过图片切换效果。
    计算两个日期之间的工作日
  • 原文地址:https://www.cnblogs.com/techdreaming/p/12728719.html
Copyright © 2011-2022 走看看