winForm改写到WPF的一些常见变化

WPF可以用 来自适应窗体大小
WPF可以用 AllowsTransparency="True" WindowStyle="None" 两个自带属性把窗体周围边框去掉
WPF可以用WindowState="Maximized"实现窗体最大化
winForm内容器panel在WPF内可以用Grid替代
WPF的GroupBox内有多个控件应在外围使用Grid
WPF内DataGrid用法,其内还包含多种属性,可自查:

<DataGrid  CanUserAddRows="False"  CanUserResizeColumns="False" CanUserResizeRows="False" AlternatingRowBackground="Lavender" Background="White" ColumnHeaderHeight="40" RowHeight="40" SelectionUnit="FullRow" SelectionMode="Single" GridLinesVisibility="None"   SelectedIndex="0" >
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Name}" Header="名称" Width="73">DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Id}" Header="编号" Width="73">DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Spec}" Header="规格" Width="73">DataGridTextColumn>
                    <DataGridTextColumn Binding="{Binding Mfrs}" Header="生产商" Width="73">DataGridTextColumn>
                DataGrid.Columns>
            DataGrid>

WinForm内的Text在WPF内为Content
WinForm内的btn.BackColor = Color.LightGray;在WPF内为 btn.Background = new SolidColorBrush(Colors.LightGray);
WPF内控件的显示和隐藏Box.Visibility = System.Windows.Visibility.Visible;

你可能感兴趣的:(WPF)