• 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>
  • 相关阅读:
    Java并发编程:线程池的使用
    AlarmManager与PendingIntent
    ConnectivityManager与检查网络连接的使用
    IntentService的使用
    Service(Local Service)简介
    Looper、Hander、HandlerThread
    XML_PULL解析
    android AsyncTask 的使用(转载)
    android 连接网络的简单实例
    xml drawable
  • 原文地址:https://www.cnblogs.com/techdreaming/p/12728719.html
Copyright © 2020-2023  润新知