机器Coding For WPF

declare @modelcode varchar(90)=‘AutoProjectType‘
declare @ns varchar(90)=‘WpfApplication‘
declare @datamodel varchar(90)=‘wv_‘ [email protected]
declare @model varchar(90)=replace(@datamodel,‘wv_‘,‘‘)+‘Model‘
declare @modelFolder varchar(90)=‘PriceRequest‘
declare @viewmodelNamespace varchar(90)=‘‘
DECLARE @dataprovidercls VARCHAR(300)=‘BizModel.Provider.VMRDataProvider‘
DECLARE @modelname VARCHAR(300)=‘合作伙伴报价确认管理‘

declare @modelpath varchar(300)=‘‘
declare @viewmodelpath varchar(300)=‘‘
declare @dgviewpath varchar(300)=‘‘
declare @listviewpath varchar(300)=‘‘
declare @dataproviderpath varchar(300)=‘‘

declare @mid int

select @mid=projectid from UPDExt.[dbo].ext_AutoProjectModel where [email protected]
select @modelpath=xpath from UPDExt.[dbo].[ext_AutoProjectParts] where [email protected] and type=2
select @viewmodelpath=xpath from UPDExt.[dbo].[ext_AutoProjectParts] where [email protected] and type=4
select @dgviewpath=xpath from UPDExt.[dbo].[ext_AutoProjectParts] where [email protected] and type=7
select @listviewpath=xpath from UPDExt.[dbo].[ext_AutoProjectParts] where [email protected] and type=6
select @dataproviderpath=xpath from UPDExt.[dbo].[ext_AutoProjectParts] where [email protected] and type=3

set @[email protected]+‘.ViewModels.‘[email protected]

declare @out VARCHAR(MAX)=‘‘
--type 0:注释,1:访问方法,2:model,3:dataprovider,4:viewmodel,5:codebehind,6:ListViewUI,7:DatagridUI,8读存储过程,9写存储过程
create table #(myfd VARCHAR(MAX),type int default 0,xpath varchar(200) default ‘‘)
declare @procname varchar(90)=‘‘
set @procname=‘wp_getPager_‘[email protected]+‘_ds‘

insert into #(myfd,type,xpath)
select ‘//****************************************class.cs*****************************************‘,0,‘‘
insert into #(myfd,type,xpath)
select ‘public List<‘[email protected]+‘> Get‘[email protected]+‘List(string parm,string userno)‘+char(10)+
‘{‘+char(10)+
‘ return ‘[email protected]+‘.GetObjectList(parm,userno);‘+char(10)+
‘}‘+char(10)
,1,‘‘
insert into #(myfd)
select ‘//****************************************‘[email protected]+‘*****************************************‘

select
@out=‘using System;‘
+char(10)+‘using BizModel.Model;‘
+char(10)+‘using System.Collections.Generic;‘
+char(10)+‘using System.Data; ‘
+char(10)+‘using System.Runtime.Serialization;‘
+char(10)+‘using System.Text;‘
+char(10)+‘using System.Threading.Tasks;‘
+char(10)+ ‘namespace ‘[email protected]+char(10)+‘{‘+char(10)+‘public class ‘[email protected]+‘:BaseModel‘+CHAR(10)+‘{‘

select @out+=char(10)+ case when b.data_type=‘datetime‘ then ‘string‘
when b.data_type=‘nvarchar‘ then ‘string‘
when b.data_type=‘varchar‘ then ‘string‘
when b.data_type=‘uniqueidentifier‘ then ‘string‘
when b.data_type=‘money‘ then ‘double‘
when b.data_type=‘bit‘ then ‘int‘
when b.DATA_TYPE=‘smallint‘ then ‘int‘
when b.DATA_TYPE=‘int‘ OR b.DATA_TYPE=‘bigint‘ then ‘int‘
when b.DATA_TYPE=‘decimal‘ then ‘double‘
else b.DATA_TYPE end+ ‘ _‘+
name+‘;public ‘+
case when b.data_type=‘datetime‘ then ‘string‘
when b.data_type=‘nvarchar‘ then ‘string‘
when b.data_type=‘varchar‘ then ‘string‘
when b.data_type=‘uniqueidentifier‘ then ‘string‘
when b.data_type=‘money‘ then ‘double‘
when b.data_type=‘bit‘ then ‘int‘
when b.DATA_TYPE=‘smallint‘ then ‘int‘
when b.DATA_TYPE=‘int‘ OR b.DATA_TYPE=‘bigint‘ then ‘int‘
when b.DATA_TYPE=‘decimal‘ then ‘double‘
else b.DATA_TYPE end+ ‘ ‘+
name+‘{get{return _‘+name+‘;}set{base.SetField(ref _‘+name+‘,value);}}‘
+‘‘ from syscolumns a,information_schema.columns b
where a.name=b.COLUMN_NAME
and [email protected] and object_name(id)[email protected]

select @out+=char(10)+ ‘bool _GroupChecked=false; public bool GroupChecked { get { return _GroupChecked; } set { base.SetField(ref _GroupChecked, value); } }‘

select @out+=char(10)+‘public ‘[email protected]+‘() { }‘

select @out+=char(10)+‘public ‘[email protected]+‘(DataRow dr) { ‘

select @out+=char(10)+
case when b.data_type=‘datetime‘ OR b.data_type=‘date‘ then ‘if(!Convert.IsDBNull(dr["‘+name+‘"]))‘
+‘this.‘+name+‘= Convert.ToDateTime(dr["‘+name+‘"]).ToString("yyyy-MM-dd hh:mm:ss");‘
+‘else this.‘+name +‘="";‘
when b.data_type=‘nvarchar‘ or b.data_type=‘varchar‘ or b.data_type=‘uniqueidentifier‘ then ‘this.‘+name+‘=dr["‘+name+‘"].ToString();‘
when b.data_type=‘money‘ or b.DATA_TYPE=‘decimal‘ then
‘if (Convert.IsDBNull(dr["‘+name+‘"]))‘+char(10)+
‘this.‘+name+‘=0;‘+char(10)+
‘else ‘+
‘this.‘+name+‘=Convert.ToDouble(dr["‘+name+‘"]);‘
when b.data_type=‘bit‘ or b.DATA_TYPE=‘smallint‘ or b.DATA_TYPE=‘int‘ then
‘if (Convert.IsDBNull(dr["‘+name+‘"]))‘+char(10)+
‘this.‘+name+‘=0;‘+char(10)+
‘else ‘+
‘this.‘+name+‘=Convert.ToInt32(dr["‘+name+‘"]);‘
else ‘‘ end
from syscolumns a,information_schema.columns b
where a.name=b.COLUMN_NAME
and [email protected] and object_name(id)[email protected]

select @out+=char(10)+‘}‘+char(10)+
‘public static List<‘[email protected]+‘> PopObjectList(string parm, string userno)‘+char(10)+
‘{‘+char(10)+
‘ Dictionary<string,object> parms=new Dictionary<string,object>();‘+char(10)+
‘ parms.Add("@userno",userno);‘+char(10)+
‘ DataTable dt = ‘[email protected]+‘.Get‘[email protected]+‘List(parms);‘+char(10)+
‘ List<‘[email protected]+‘> list = new List<‘[email protected]+‘>();‘+char(10)+
‘ foreach (DataRow dr in dt.Rows)‘+char(10)+
‘ {‘+char(10)+
‘ list.Add(new ‘[email protected]+‘(dr));‘+char(10)+
‘ }‘+char(10)+
‘ return list;‘+char(10)+
‘ }}}‘
insert into #(myfd,type,xpath)
select @out,2, @modelpath
insert into #(myfd)
select ‘//****************************************DATA Provider*****************************************‘

INSERT into #(myfd,type,xpath)
select ‘internal static DataTable Get‘[email protected]+‘List(Dictionary<string, object> parms)‘+char(10)+
‘{‘+char(10)+
‘ DataTable dt = _Instance.ExecStoreProcedureForGettingTable(parms, "wp_getPager_‘+replace(@model,‘object‘,‘‘)+‘_ds");‘+char(10)+
‘ return dt;‘+char(10)+
‘} ‘+char(10)
,3,@dataproviderpath

insert into #(myfd)
select ‘//****************************************ViewModel*****************************************‘
DECLARE @str VARCHAR(MAX)

set @str=
‘using BizModel.Model;‘+CHAR(10)+
‘using MyGlobal.Infrustructure;‘+CHAR(10)+
‘using System;‘+CHAR(10)+
‘using System.Collections.Generic;‘+CHAR(10)+
‘using System.Diagnostics;‘+CHAR(10)+
‘using System.Linq;‘+CHAR(10)+
‘using System.Net;‘+CHAR(10)+
‘using System.Text;‘+CHAR(10)+
‘using System.Threading.Tasks;‘+CHAR(10)+
‘using System.Windows;‘+CHAR(10)+
‘using System.Windows.Input;‘+CHAR(10)+
‘using WpfApplication.Views;‘+CHAR(10)+
‘namespace WpfApplication.ViewModels.‘[email protected]+CHAR(10)+
‘{‘+CHAR(10)+
‘public class ‘[email protected]+‘ViewModel‘+
‘ViewModel:NotifyChanged ‘+CHAR(10)+
‘{‘+CHAR(10)+
‘private List<‘[email protected]+‘> _mylist;‘+CHAR(10)+
‘public List<‘[email protected]+‘> MyListViewDS‘+CHAR(10)+
‘{‘+CHAR(10)+
‘get { return _mylist; }‘+CHAR(10)+
‘set { SetField(ref _mylist, value); }‘
+CHAR(10)+‘}‘

+CHAR(10)+‘public ICommand CHKSN_Command {‘
+CHAR(10)+‘get {‘
+CHAR(10)+‘return new RelayCommand<object>((o) => {‘
+CHAR(10)+‘foreach (PriceRequestReplyModel item in MyListViewDS)‘
+CHAR(10)+‘{‘
+CHAR(10)+‘ if (item.Apply_No == o.ToString()) item.GroupChecked = !item.GroupChecked;‘
+CHAR(10)+‘}}); } }‘
+CHAR(10)+‘public ICommand MyListView_PreviewMouseWheel‘
+CHAR(10)+‘{‘
+CHAR(10)+‘get‘
+CHAR(10)+‘{‘
+CHAR(10)+‘return new RelayCommand<ListView>((mylistview) =>‘
+CHAR(10)+‘{‘
+CHAR(10)+‘mylistview.PreviewMouseWheel += (sender, e) =>‘
+CHAR(10)+‘{‘
+CHAR(10)+‘ var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);‘
+CHAR(10)+‘ eventArg.RoutedEvent = UIElement.MouseWheelEvent;‘
+CHAR(10)+‘ eventArg.Source = sender;‘
+CHAR(10)+‘ mylistview.RaiseEvent(eventArg);‘
+CHAR(10)+‘};});}}‘

+CHAR(10)+‘public ICommand MyListView_SelectionChangedCommand {get{return new RelayCommand<object>((o) =>{ });}}‘

+CHAR(10)+‘public ICommand BtnQueryCommand‘+CHAR(10)+
‘{‘+CHAR(10)+
‘get‘+CHAR(10)+
‘{‘+CHAR(10)+
‘return new RelayCommand<string>(‘+CHAR(10)+
‘(o) =>‘+CHAR(10)+
‘{‘+CHAR(10)+
‘MyListViewDS = ‘[email protected]+‘.GetObjectList("","");‘+CHAR(10)+
‘});‘+CHAR(10)+
‘}‘+CHAR(10)+
‘}‘+CHAR(10)+
‘}‘+CHAR(10)+
‘}‘+CHAR(10)

PRINT @str
BEGIN TRY
INSERT INTO #(myfd,type,xpath)
SELECT @str,4,@viewmodelpath
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE()
END CATCH

insert into #(myfd)
select ‘//****************************************View behindcode*****************************************‘
INSERT INTO #(myfd,type,xpath)
SELECT
‘using MyGlobal.Infrustructure.Resources;‘+CHAR(10)+
‘using System;‘+CHAR(10)+
‘using System.Collections.Generic;‘+CHAR(10)+
‘using System.Linq;‘+CHAR(10)+
‘using System.Text;‘+CHAR(10)+
‘using System.Threading.Tasks;‘+CHAR(10)+
‘using System.Windows;‘+CHAR(10)+
‘using System.Windows.Controls;‘+CHAR(10)+
‘using System.Windows.Data;‘+CHAR(10)+
‘using System.Windows.Documents;‘+CHAR(10)+
‘using System.Windows.Input;‘+CHAR(10)+
‘using System.Windows.Media;‘+CHAR(10)+
‘using System.Windows.Media.Imaging;‘+CHAR(10)+
‘using System.Windows.Navigation;‘+CHAR(10)+
‘using System.Windows.Shapes;‘+CHAR(10)+
‘using WpfApplication.ViewModels.‘[email protected]+‘;‘+char(10)+
‘namespace WpfApplication.Views.‘[email protected]+char(10)+
‘{‘+char(10)+
‘public partial class ‘[email protected]+‘View : Page‘+char(10)+
‘{‘+char(10)+
‘public ‘[email protected]+‘View()‘+char(10)+
‘{‘+char(10)+
‘//*************************************引用全局单例样式代码******************************‘+char(10)+
‘this.Resources.MergedDictionaries.Add(SharedDictionaryStyleManager.SharedStylesDictionary);‘+char(10)+
‘this.Resources.MergedDictionaries.Add(SharedDictionaryStyleManager.ShareDataGridStylesDictionary);‘+char(10)+
‘this.DataContext = new ‘[email protected]+‘ViewModel();‘+char(10)+
‘InitializeComponent();‘+char(10)+
‘}‘+char(10)+
‘}‘+char(10)+
‘}‘+char(10)
,5,@dgviewpath

INSERT INTO #(myfd)
VALUES(‘--**********************************输出WPF数据UI For ListView**************************************‘)
DECLARE @str1 VARCHAR(MAX) =‘‘
SELECT @str1+=CHAR(10)+
‘<Page x:Class="WpfApplication.Views.‘[email protected]+‘.‘[email protected]+‘View"‘+CHAR(10)
+‘xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"‘+CHAR(10)
+‘xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"‘+CHAR(10)
+‘xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ‘+CHAR(10)
+‘xmlns:d="http://schemas.microsoft.com/expression/blend/2008" ‘+CHAR(10)
+‘xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" ‘+CHAR(10)

+‘mc:Ignorable="d" ‘+CHAR(10)
+‘d:DesignHeight="500" d:DesignWidth="790"‘+CHAR(10)
+‘Title="‘[email protected]+‘">‘+CHAR(10)

+CHAR(10)+‘<Page.Resources>‘
+CHAR(10)+‘<CollectionViewSource x:Key=‘‘src‘‘ Source="{Binding MyListViewDS}">‘
+CHAR(10)+‘<CollectionViewSource.GroupDescriptions>‘
+CHAR(10)+‘<PropertyGroupDescription PropertyName="Apply_No" />‘
+CHAR(10)+‘</CollectionViewSource.GroupDescriptions>‘
+CHAR(10)+‘</CollectionViewSource>‘
+CHAR(10)+‘<!--</SnippetGroupingCollectionViewSource>-->‘
+CHAR(10)+‘<Style TargetType="{x:Type ListViewItem}">‘
+CHAR(10)+‘<Setter Property="BorderThickness" Value="0,1,0,0" />‘
+CHAR(10)+‘<Setter Property="BorderBrush" Value="#BABABE" />‘
+CHAR(10)+‘</Style>‘
+CHAR(10)+‘</Page.Resources>‘

+‘<Grid>‘+CHAR(10)
+‘<Grid.RowDefinitions>‘+CHAR(10)
+‘<RowDefinition Height="40"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition Height="10"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition Height="25"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition Height="10"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition></RowDefinition>‘+CHAR(10)
+‘</Grid.RowDefinitions>‘+CHAR(10)
+‘<Grid.ColumnDefinitions>‘+CHAR(10)
+‘<ColumnDefinition Width="*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="2*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="2*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="*"></ColumnDefinition>‘+CHAR(10)
+‘</Grid.ColumnDefinitions>‘+CHAR(10)

+‘<Border Style="{StaticResource csTitleBorder}" Grid.ColumnSpan="5" >‘+CHAR(10)
+‘<StackPanel Background="{StaticResource gbTitleBg}">‘+CHAR(10)
+‘<TextBlock Text="‘[email protected]+‘" VerticalAlignment="Center" Style="{StaticResource gbTextBlock}"></TextBlock>‘
+CHAR(10)+‘</StackPanel>‘
+CHAR(10)+‘</Border>‘
+CHAR(10)+‘<Label Grid.Row="2" Style="{StaticResource csLabel}">姓名</Label>‘
+CHAR(10)+‘<TextBox Text="{Binding SearchName}" Grid.Row="2" Grid.Column="1" VerticalContentAlignment="Center" Name="fefe"></TextBox>‘
+CHAR(10)+‘<Label Grid.Row="2" Grid.Column="2" Style="{StaticResource csLabel}">工号</Label>‘
+CHAR(10)+‘<TextBox Text="{Binding SearchNO}" Grid.Row="2" Grid.Column="3" VerticalContentAlignment="Center"></TextBox>‘
+CHAR(10)+‘<Button Grid.Row="2" Grid.Column="4" Command="{Binding DataContext.QueryUsersCommand,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}}" >查询</Button>‘
+CHAR(10)+‘<ListView Name="MyListView" Grid.Row="4" Grid.ColumnSpan="5" ItemsSource=‘‘{Binding Source={StaticResource src}}‘‘ BorderThickness="0">‘

+CHAR(10)+‘<i:Interaction.Triggers>‘
+CHAR(10)+‘<i:EventTrigger EventName="PreviewMouseWheel">‘
+CHAR(10)+‘<i:InvokeCommandAction Command="{Binding DataContext.MyListView_PreviewMouseWheel, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListView}}" CommandParameter="{Binding ElementName=MyListView}" >‘
+CHAR(10)+‘</i:InvokeCommandAction>‘
+CHAR(10)+‘</i:EventTrigger>‘
+CHAR(10)+‘<i:EventTrigger EventName="SelectionChanged">‘
+CHAR(10)+‘<i:InvokeCommandAction Command="{Binding DataContext.MyListView_SelectionChangedCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListView}}" CommandParameter="{Binding}" >‘
+CHAR(10)+‘</i:InvokeCommandAction>‘
+CHAR(10)+‘</i:EventTrigger>‘
+CHAR(10)+‘</i:Interaction.Triggers>‘

+CHAR(10)+‘<ListView.GroupStyle>‘
+CHAR(10)+‘<GroupStyle>‘
+CHAR(10)+‘<GroupStyle.ContainerStyle>‘
+CHAR(10)+‘<Style TargetType="{x:Type GroupItem}">‘
+CHAR(10)+‘<Setter Property="Margin" Value="0,0,0,5"/>‘
+CHAR(10)+‘<Setter Property="Template">‘
+CHAR(10)+‘<Setter.Value>‘
+CHAR(10)+‘<ControlTemplate TargetType="{x:Type GroupItem}">‘
+CHAR(10)+‘<Border BorderBrush="Blue" BorderThickness="0.5" CornerRadius="3,3,3,3" Margin="3,3,3,3">‘
+CHAR(10)+‘<Expander IsExpanded="True" BorderBrush="Blue" BorderThickness="0,0,0,0">‘
+CHAR(10)+‘<Expander.Header>‘
+CHAR(10)+‘<DockPanel>‘
+CHAR(10)+‘<Rectangle DockPanel.Dock="Bottom" Fill="Black" Height="1" ></Rectangle>‘

+CHAR(10)+‘<CheckBox Name="CHKSN">‘
+CHAR(10)+‘<i:Interaction.Triggers>‘
+CHAR(10)+‘<i:EventTrigger EventName="Click">‘
+CHAR(10)+‘<i:InvokeCommandAction Command="{Binding DataContext.CHKSN_Command, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ListView}}" CommandParameter="{Binding Name}" >‘
+CHAR(10)+‘</i:InvokeCommandAction>‘
+CHAR(10)+‘</i:EventTrigger>‘
+CHAR(10)+‘</i:Interaction.Triggers>‘
+CHAR(10)+‘</CheckBox>‘

+CHAR(10)+‘<TextBlock FontWeight="Bold" Foreground="Blue" Text="{Binding Path=Name,StringFormat=‘‘SN:\{0\}‘‘}" Margin="5,0,0,0" Width="150"/>‘
+CHAR(10)+‘<TextBlock FontWeight="Bold" Foreground="Blue" Text="{Binding Path=ItemCount,StringFormat=‘‘数量:\{0\}‘‘}"/>‘

+CHAR(10)+‘</DockPanel>‘
+CHAR(10)+‘</Expander.Header>‘
+CHAR(10)+‘<Expander.Content>‘
+CHAR(10)+‘<ItemsPresenter />‘
+CHAR(10)+‘</Expander.Content>‘
+CHAR(10)+‘</Expander>‘
+CHAR(10)+‘</Border>‘
+CHAR(10)+‘</ControlTemplate>‘
+CHAR(10)+‘</Setter.Value>‘
+CHAR(10)+‘</Setter>‘
+CHAR(10)+‘</Style>‘
+CHAR(10)+‘</GroupStyle.ContainerStyle>‘
+CHAR(10)+‘</GroupStyle>‘
+CHAR(10)+‘</ListView.GroupStyle>‘
+CHAR(10)+‘<!--</SnippetListViewGroups>-->‘
+CHAR(10)+‘<ListView.View>‘
+CHAR(10)+‘<GridView>‘

SELECT @str1+=char(10)
+‘<GridViewColumn Header="‘ + CAST(CASE WHEN ISNULL(g.[value],‘‘)=‘‘ THEN a.name ELSE g.[value] END AS VARCHAR)
+‘" Width="100" CellTemplateSelector="{x:Null}">‘+CHAR(10)
+‘<GridViewColumn.CellTemplate>‘+CHAR(10)
+‘<DataTemplate>‘+CHAR(10)
+‘<DockPanel LastChildFill="True">‘+CHAR(10)
+‘<Rectangle DockPanel.Dock="Right" Fill="#BABABE" Width="1" ></Rectangle>‘+CHAR(10)
+‘<TextBlock DockPanel.Dock="Left" Text="{Binding ‘+a.name+‘}" Width="100" HorizontalAlignment="Left"></TextBlock>‘+CHAR(10)
+‘</DockPanel>‘+CHAR(10)
+‘</DataTemplate>‘+CHAR(10)
+‘</GridViewColumn.CellTemplate>‘+CHAR(10)
+‘</GridViewColumn>‘+CHAR(10)
---- (case when a.colorder=1 then d.name else ‘‘ end) 表名,

FROM syscolumns a left join systypes b
on a.xtype=b.xusertype
inner join sysobjects d
on a.id=d.id and d.name<>‘dtproperties‘
left join sys.extended_properties g
on a.id=g.major_id AND a.colid = g.minor_id
WHERE d.[name] [email protected] --你要查看的表名,注释掉,查看当前数据库所有表的字段信息
order by a.id,a.colorder

SET @str1+=char(10)
+‘</GridView>‘
+‘</ListView.View>‘
+‘<!--<SnippetListViewEnd>-->‘
+‘</ListView>‘
+‘<!--</SnippetListViewEnd>-->‘
+‘</Grid></Page>‘
INSERT INTO #(myfd,type,xpath)
SELECT @str1,6,@dgviewpath

INSERT INTO #(myfd)
VALUES(‘--**********************************输出WPF数据UI For DataGrid**************************************‘)

SELECT @str1=
‘<Page x:Class="WpfApplication.Views.‘[email protected]+‘.‘[email protected]+‘View"‘+CHAR(10)
+‘xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"‘+CHAR(10)
+‘xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"‘+CHAR(10)
+‘xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" ‘+CHAR(10)
+‘xmlns:d="http://schemas.microsoft.com/expression/blend/2008" ‘+CHAR(10)
+‘xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" ‘+CHAR(10)

+‘mc:Ignorable="d" ‘+CHAR(10)
+‘d:DesignHeight="500" d:DesignWidth="790"‘+CHAR(10)
+‘Title="‘[email protected]+‘">‘
+CHAR(10)+‘<Page.Resources>‘
+CHAR(10)+‘<CollectionViewSource x:Key=‘‘src‘‘ Source="{Binding MyListViewDS}">‘
+CHAR(10)+‘<CollectionViewSource.GroupDescriptions>‘
+CHAR(10)+‘<PropertyGroupDescription PropertyName="Apply_No" />‘
+CHAR(10)+‘</CollectionViewSource.GroupDescriptions>‘
+CHAR(10)+‘</CollectionViewSource>‘
+CHAR(10)+‘<!--</SnippetGroupingCollectionViewSource>-->‘
+CHAR(10)+‘<Style TargetType="{x:Type ListViewItem}">‘
+CHAR(10)+‘<Setter Property="BorderThickness" Value="0,1,0,0" />‘
+CHAR(10)+‘<Setter Property="BorderBrush" Value="#BABABE" />‘
+CHAR(10)+‘</Style>‘
+CHAR(10)+‘</Page.Resources>‘

+‘<Grid>‘+CHAR(10)
+‘<Grid.RowDefinitions>‘+CHAR(10)
+‘<RowDefinition Height="40"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition Height="10"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition Height="25"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition Height="10"></RowDefinition>‘+CHAR(10)
+‘<RowDefinition></RowDefinition>‘+CHAR(10)
+‘</Grid.RowDefinitions>‘+CHAR(10)
+‘<Grid.ColumnDefinitions>‘+CHAR(10)
+‘<ColumnDefinition Width="*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="2*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="2*"></ColumnDefinition>‘+CHAR(10)
+‘<ColumnDefinition Width="*"></ColumnDefinition>‘+CHAR(10)
+‘</Grid.ColumnDefinitions>‘+CHAR(10)

+‘<Border Style="{StaticResource csTitleBorder}" Grid.ColumnSpan="5" >‘+CHAR(10)
+‘<StackPanel Background="{StaticResource gbTitleBg}">‘+CHAR(10)
+‘<TextBlock Text="‘[email protected]+‘" VerticalAlignment="Center" Style="{StaticResource gbTextBlock}"></TextBlock>‘
+CHAR(10)+‘</StackPanel>‘
+CHAR(10)+‘</Border>‘
+CHAR(10)+‘<Label Grid.Row="2" Style="{StaticResource csLabel}">姓名</Label>‘
+CHAR(10)+‘<TextBox Text="{Binding SearchName}" Grid.Row="2" Grid.Column="1" VerticalContentAlignment="Center" Name="fefe"></TextBox>‘
+CHAR(10)+‘<Label Grid.Row="2" Grid.Column="2" Style="{StaticResource csLabel}">工号</Label>‘
+CHAR(10)+‘<TextBox Text="{Binding SearchNO}" Grid.Row="2" Grid.Column="3" VerticalContentAlignment="Center"></TextBox>‘
+CHAR(10)+‘<Button Grid.Row="2" Grid.Column="4" Command="{Binding DataContext.QueryUsersCommand,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}}" >查询</Button>‘

+CHAR(10)+‘<DataGrid Name="MyListView" Grid.Row="4" AutoGenerateColumns="False" Grid.ColumnSpan="5" ItemsSource=‘‘{Binding Source={StaticResource src}}‘‘ CanUserAddRows="False" BorderThickness="0">‘
+CHAR(10)+‘<i:Interaction.Triggers>‘
+CHAR(10)+‘<i:EventTrigger EventName="SelectionChanged">‘
+CHAR(10)+‘<i:InvokeCommandAction Command="{Binding DataContext.MyListView_SelectionChangedCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}" CommandParameter="{Binding}" >‘
+CHAR(10)+‘</i:InvokeCommandAction>‘
+CHAR(10)+‘</i:EventTrigger>‘
+CHAR(10)+‘</i:Interaction.Triggers>‘

+CHAR(10)+‘<DataGrid.GroupStyle>‘
+CHAR(10)+‘<GroupStyle>‘
+CHAR(10)+‘<GroupStyle.ContainerStyle>‘
+CHAR(10)+‘<Style TargetType="{x:Type GroupItem}">‘
+CHAR(10)+‘<Setter Property="Margin" Value="0,0,0,5"/>‘
+CHAR(10)+‘<Setter Property="Template">‘
+CHAR(10)+‘<Setter.Value>‘
+CHAR(10)+‘<ControlTemplate TargetType="{x:Type GroupItem}">‘
+CHAR(10)+‘<Border BorderBrush="Blue" BorderThickness="0.5" CornerRadius="3,3,3,3" Margin="3,3,3,3">‘
+CHAR(10)+‘<Expander IsExpanded="True" BorderBrush="Blue" BorderThickness="0,0,0,0">‘
+CHAR(10)+‘<Expander.Header>‘
+CHAR(10)+‘<DockPanel>‘
+CHAR(10)+‘<Rectangle DockPanel.Dock="Bottom" Fill="Black" Height="1" ></Rectangle>‘

+CHAR(10)+‘<CheckBox Name="CHKSN">‘
+CHAR(10)+‘<i:Interaction.Triggers>‘
+CHAR(10)+‘<i:EventTrigger EventName="Click">‘
+CHAR(10)+‘<i:InvokeCommandAction Command="{Binding DataContext.CHKSN_Command, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Name}" >‘
+CHAR(10)+‘</i:InvokeCommandAction>‘
+CHAR(10)+‘</i:EventTrigger>‘
+CHAR(10)+‘</i:Interaction.Triggers>‘
+CHAR(10)+‘</CheckBox>‘

+CHAR(10)+‘<TextBlock FontWeight="Bold" Foreground="Blue" Text="{Binding Path=Name,StringFormat=‘‘SN:\{0\}‘‘}" Margin="5,0,0,0" Width="150"/>‘
+CHAR(10)+‘<TextBlock FontWeight="Bold" Foreground="Blue" Text="{Binding Path=ItemCount,StringFormat=‘‘数量:\{0\}‘‘}"/>‘

+CHAR(10)+‘</DockPanel>‘
+CHAR(10)+‘</Expander.Header>‘
+CHAR(10)+‘<Expander.Content>‘
+CHAR(10)+‘<ItemsPresenter />‘
+CHAR(10)+‘</Expander.Content>‘
+CHAR(10)+‘</Expander>‘
+CHAR(10)+‘</Border>‘
+CHAR(10)+‘</ControlTemplate>‘
+CHAR(10)+‘</Setter.Value>‘
+CHAR(10)+‘</Setter>‘
+CHAR(10)+‘</Style>‘
+CHAR(10)+‘</GroupStyle.ContainerStyle>‘
+CHAR(10)+‘</GroupStyle>‘
+CHAR(10)+‘</DataGrid.GroupStyle>‘
+CHAR(10)+‘<DataGrid.Columns>‘

SELECT @str1+=char(10)
+‘<DataGridTemplateColumn Header="‘ + CAST(CASE WHEN ISNULL(g.[value],‘‘)=‘‘ THEN a.name ELSE g.[value] END AS VARCHAR)
+‘" Width="100" >‘+CHAR(10)
+‘<DataGridTemplateColumn.CellTemplate>‘+CHAR(10)
+‘<DataTemplate>‘+CHAR(10)
+‘<DockPanel LastChildFill="True">‘+CHAR(10)
+‘<Border BorderThickness="0,0.5,0.5,0" BorderBrush="#BABABE">‘+CHAR(10)
+‘<TextBlock DockPanel.Dock="Left" Text="{Binding ‘+a.name+‘}" Width="100" HorizontalAlignment="Left"></TextBlock></Border>‘+CHAR(10)
+‘</DockPanel>‘+CHAR(10)
+‘</DataTemplate>‘+CHAR(10)
+‘</DataGridTemplateColumn.CellTemplate>‘+CHAR(10)
+‘</DataGridTemplateColumn>‘+CHAR(10)
---- (case when a.colorder=1 then d.name else ‘‘ end) 表名,

FROM syscolumns a left join systypes b
on a.xtype=b.xusertype
inner join sysobjects d
on a.id=d.id and d.name<>‘dtproperties‘
left join sys.extended_properties g
on a.id=g.major_id AND a.colid = g.minor_id
WHERE d.[name] [email protected] --你要查看的表名,注释掉,查看当前数据库所有表的字段信息
order by a.id,a.colorder

SET @str1+=char(10)
+‘ </DataGrid.Columns>‘
+‘</DataGrid>‘
+‘</Grid></Page>‘
INSERT INTO #(myfd,type,xpath)
SELECT @str1,7,@listviewpath

insert into #(myfd)values(‘
--***********************************************读取数据存储过程************************************************‘)
--***********************************************读取数据存储过程**************************************************
declare @fields varchar(max)=‘‘,@sqlstr varchar(max)=‘‘,@orderfields varchar(90)=‘‘
select @fields=stuff((select ‘,‘+name from syscolumns
where object_name(id)=‘‘[email protected]+‘‘ order by colorder for xml path(‘‘)),1,1,‘‘)
select top 1 @orderfields=name from syscolumns where object_name(id)=‘‘[email protected]+‘‘ order by colorder
set @sqlstr+=‘--‘+convert(varchar(10),getdate(),120)+‘‘
+char(10)+‘--读取‘[email protected]+‘‘
+char(10)+‘--‘[email protected]+‘ @parm=‘‘‘‘‘
+char(10)+‘create PROC ‘[email protected]+‘‘
+char(10)+‘@id INT=-1,‘
+char(10)+‘@parm nvarchar(90)=‘‘‘‘, ‘
+char(10)+‘@userno VARCHAR(20)=‘‘‘‘,‘
+char(10)+‘@isvalid INT =-1,‘
+char(10)+‘@sortfields nvarchar(100)=‘‘‘‘,‘
+char(10)+‘@pageindex int=1,‘
+char(10)+‘@pagesize int=500‘
+char(10)+‘AS‘
+char(10)+‘begin ‘
+char(10)+‘--******************************************数据准备**************************************‘

+char(10)+‘--*******************************************变量定义***************************************‘

+char(10)+‘--构建执行脚本‘
+char(10)+‘declare @sql nvarchar(1800)=‘‘‘‘,‘
+char(10)+‘--存储对象‘
+char(10)+‘@tablename NVARCHAR(50)=‘‘‘[email protected]+‘‘‘,‘
+char(10)+‘--返回字段‘
+char(10)+‘@returnfields nvarchar(1000)=‘‘‘‘,‘
+char(10)+‘--where 条件‘
+char(10)+‘@where nvarchar(200)=‘‘ where 1=1‘‘,‘
+char(10)+‘--上次查询数量‘
+char(10)+‘@lastcount int =-1 ‘

+char(10)+‘--计算前面查询的数据总数‘
+char(10)+‘set @lastcount=(@pageindex-1)*@pagesize‘
+char(10)+‘if @lastcount<0 set @lastcount=0‘
+char(10)+‘--判断排序字段‘
+char(10)+‘if @sortfields=‘‘‘‘‘
+char(10)+‘set @sortfields=‘‘‘[email protected]+‘‘‘‘
+char(10)+‘--*******************************************返回字段设定*****************************************‘
+char(10)+‘--select stuff((select ‘‘,‘‘+name from syscolumns ‘
+char(10)+‘--where object_name(id)=‘‘ext_AutoRunRegister‘‘ order by colorder for xml path(‘‘‘‘)),1,1,‘‘‘‘)‘
+char(10)+‘set @returnfields=‘‘‘[email protected]+‘‘‘‘
+char(10)+‘--*******************************************由条件构建Where***************************************‘
+char(10)+‘if @id<>-1‘
+char(10)+‘set @where+=‘‘ and id =‘‘+CAST(@id AS VARCHAR)‘
+char(10)+‘if @userno<>‘‘‘‘‘
+char(10)+‘set @where+=‘‘ and userno like ‘‘‘‘%‘‘[email protected]+‘‘%‘‘‘‘‘‘‘
+char(10)+‘--*******************************************由条件构建SQL***************************************‘
+char(10)+‘set @sql=‘‘‘

+char(10)+‘declare @lastmaxid int=0,@total int‘
+char(10)+‘--缓存的临时表,并创建检索rowID‘
+char(10)+‘if object_id(‘‘‘‘tempdb..#t‘‘‘‘) is not null‘
+char(10)+‘ drop table #t‘

+char(10)+‘select row_number() over (order by ‘‘[email protected]+‘‘) rowid, * into #t from ‘‘[email protected]‘

+char(10)+‘set @sql += @where‘

+char(10)+‘--获取按照执行排序,前面查询的数据的最大ID‘
+char(10)+‘set @sql +=‘‘ select top ‘‘+cast(@lastcount as nvarchar)+‘‘ @lastmaxid=max(rowid) from #t‘‘‘
+char(10)+‘set @sql+= ‘‘ group by rowid‘‘‘

+char(10)+‘--获取符合条件的数据总数‘
+char(10)+‘set @sql+=‘‘ select @total=count(*) from #t‘‘‘

+char(10)+‘--**********************************************构造执行返回结果的SQL*****************************************‘
+char(10)+‘set @sql+=‘‘ select ‘‘‘
+char(10)+‘if @pagesize>0‘
+char(10)+‘ set @sql+=‘‘top ‘‘+cast(@pagesize as nvarchar) ‘
+char(10)+‘ set @sql+=‘‘ rowid ‘‘‘

+char(10)+‘ if @returnfields<>‘‘‘‘‘
+char(10)+‘ begin‘
+char(10)+‘ set @sql+=‘‘,‘‘[email protected] ‘
+char(10)+‘ end ‘
+char(10)+‘ set @sql+=‘‘ from #t where rowid>@lastmaxid order by rowid‘‘‘

+char(10)+‘set @sql+=‘‘ select @total total,‘‘+cast(@pagesize as nvarchar)+‘‘ pagesize,‘‘+cast(@pageindex as nvarchar)+‘‘ pageindex‘‘‘

+char(10)+‘set @sql+=‘‘ if object_id(‘‘‘‘tempdb..#t‘‘‘‘) is not null‘
+char(10)+‘ drop table #t‘‘‘
+char(10)+‘set @sql+=‘‘ if object_id(‘‘‘‘tempdb..#x‘‘‘‘) is not null‘
+char(10)+‘ drop table #x‘‘‘

+char(10)+‘exec(@sql) ‘

+char(10)+‘END‘

insert into #(myfd,type,xpath)
select @sqlstr,8,‘‘

insert into #(myfd)values(‘
--***********************************************写入数据存储过程************************************************‘)
--***********************************************写入数据存储过程**************************************************

declare
@yesUpdateCondition VARCHAR(300)=‘@id>0‘ --更新表时需要满足此条件
,@tbcols VARCHAR(2000)=‘‘
,@tbcolsp VARCHAR(2000)=‘‘
,@tbcolspv VARCHAR(2000)=‘‘
,@space VARCHAR(10)=‘ ‘

SELECT @tbcols= stuff((select ‘,‘+name from syscolumns
where object_name(id)[email protected] order by colorder for xml path(‘‘)),1,1,‘‘)

SELECT @tbcolsp= stuff((select ‘,@‘+name from syscolumns
where object_name(id)[email protected] order by colorder for xml path(‘‘)),1,1,‘‘)

SELECT @tbcolspv= stuff((select ‘,‘+name+‘[email protected]‘+name from syscolumns
where object_name(id)[email protected] order by colorder for xml path(‘‘)),1,1,‘‘)

create table #w(id INT IDENTITY(1,1),myfd varchar(max))
insert into #w(myfd)
SELECT ‘create proc wp_‘[email protected]+‘_change‘
insert into #w(myfd)
SELECT ‘@‘+ a.name+‘ ‘+
CASE when b.data_type=‘datetime‘ OR b.data_type=‘date‘ then ‘datetime=‘‘1900-01-01‘‘‘
when b.data_type=‘nvarchar‘ OR b.data_type=‘varchar‘ then ‘nvarchar(‘+CAST(a.length AS VARCHAR)+‘)=‘‘‘‘‘

when b.data_type=‘uniqueidentifier‘ then ‘varchar(‘+CAST(a.length AS VARCHAR)+‘)=‘‘‘‘‘
when b.data_type=‘money‘ then ‘money=0‘
when b.data_type=‘bit‘ then ‘smallint=0‘
when b.DATA_TYPE=‘smallint‘ then ‘smallint=0‘
when b.DATA_TYPE=‘int‘ then ‘int=0‘
when b.DATA_TYPE=‘decimal‘ then ‘decimal(18,4)=0‘
else b.DATA_TYPE end+ ‘,‘
FROM syscolumns a,information_schema.columns b
where a.name=b.COLUMN_NAME
and [email protected] and object_name(id)[email protected]

UPDATE #w SET myfd=REPLACE(myfd,‘,‘,‘‘) WHERE [email protected]@ROWCOUNT+1
insert into #w(myfd)
select ‘as‘
insert into #w(myfd)
select ‘SET XACT_ABORT on‘
insert into #w(myfd)
select ‘begin tran‘
insert into #w(myfd)
select ‘ begin try‘
insert into #w(myfd)
select @space+‘ ‘+‘declare @count int,@msg varchar(200)=‘‘‘‘‘
INSERT INTO #w(myfd)
SELECT @space+‘ if(‘[email protected]+‘) ‘
INSERT INTO #w(myfd)
SELECT @space+‘ begin‘
INSERT INTO #w(myfd)
SELECT @[email protected]+‘ update ‘[email protected]+‘ set ‘[email protected]
INSERT INTO #w(myfd)
SELECT @[email protected]+‘ where 1=1‘
INSERT INTO #w(myfd)
SELECT @[email protected]+‘ select @[email protected]@rowcount ‘
INSERT INTO #w(myfd)
SELECT @space+‘ end ‘
INSERT INTO #w(myfd)
SELECT @space+‘ else ‘
INSERT INTO #w(myfd)
SELECT @space+‘ begin ‘
INSERT INTO #w(myfd)
SELECT @[email protected]+‘ insert into ‘[email protected]+‘(‘[email protected]+‘)‘
INSERT INTO #w(myfd)
SELECT @[email protected]+‘ select ‘[email protected]
INSERT INTO #w(myfd)
SELECT @[email protected]+‘ select @[email protected]@rowcount ‘
INSERT INTO #w(myfd)
SELECT @space+‘ end ‘
INSERT INTO #w(myfd)
SELECT @space+‘ select @count tcount,case when @count>0 then ‘‘执行成功‘‘ else ‘‘执行失败‘‘ end msg ‘
INSERT INTO #w(myfd)
SELECT @space+‘ commit tran ‘
INSERT INTO #w(myfd)
SELECT ‘ end try‘
INSERT INTO #w(myfd)
SELECT ‘ begin catch ‘
INSERT INTO #w(myfd)
SELECT @space+‘ select @msg=error_message() ‘
INSERT INTO #w(myfd)
SELECT @space+‘ select 0 tcount,@msg msg‘
INSERT INTO #w(myfd)
SELECT @space+‘ rollback tran ‘
INSERT INTO #w(myfd)
SELECT ‘ end catch‘

select * from #
select * from #w
drop table #w
drop table #

时间: 2024-10-10 21:12:38

机器Coding For WPF的相关文章

机器Coding For WinForm

declare @objname varchar(90)='AutoProjectModel'declare @modelns varchar(90)='ACL.Models'declare @dpclsname varchar(200)='ACL.UPDExtDataProvider'--model数据提供类名declare @datamodel varchar(90)='ext_' [email protected]declare @clsname varchar(90)=replace(@

Coding theano under remote ubuntu server from local Mac (在本地mac机器上,写、跑、调试、看-远程ubuntu上的theano代码)

本人是奇葩,最近鼓捣了一套在mac上coding远程ubuntu上的theano代码的东东,记之以期造福后人. Overview: 下图是我的编程环境和网络环境 我期望能在本地mac机器上对远程的ubuntu theano server进行write.run.debug.view matplotlib图片. mac设置(参考这里) 考虑到在Mac本地调试一部分代码,我把mac也设置好了科学计算环境. 1.1 python mac安装xcode后会自带很多东西,python就是其中一个.但mac提

DevExpress for WPF 使用换肤控件后在其他机器上无法运行问题

本人使用的DevExpress13.2.6的破解版.WPF的 在项目中使用了DevExpress的控件后在其他机器上无法运行,吓我一跳,然后我发现DLL都复制到本地了.这个是什么原因呢? 猜想是DLL引用了其他的DLL,或者是某些DLL需要注册.但是DLL那么多,并不知道是差哪些DLL,总不能全部弄过去吧,那么大.后来找了些资料问了下其他人用这个的问题,他们都说差DevExpress.Utils.v13.2.dll.但是实际上他们是winfrom的 和WPF不一样.根本不适合. 后来我一个个调试

搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 (1)

搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 原文地址(英文):http://www.networkcomms.net/creating-a-wpf-chat-client-server-application/ 注意:本教程是相当广泛的,如果你是在短请也看到我们的东西 开始和 如何在几分钟内创建一个客户端服务器应用程序教程. 注2:本例中包括,明显延长进一步证明功能,在包中包含的示例 包下载. 在我们开始之前确保您已经安装了Vis

WPF性能提升的十个技巧

[IT168 专稿]WPF(Windows Presentation Foundation)应用程序在没有图形加速设备的机器上运行速度很慢是个公开的秘密,给用户的感觉是它太吃资源了,WPF程序的性能和硬件确实有很大的关系,越高档的机器性能越有优势. 程序性能改善不是一蹴而就的,好的设计可以消除影响性能的问题,例如,在运行时构造对象就会对程序的性能造成影响.虽然WPF通过增强的导航等功能提供了更丰富的用户界面,但你应该考虑你的用户是否的确需要富图形界面,尽管WPF有这样那样的问题,但在UI设计,特

在WPF中使用fortawesome之类的字体图标

我之前在博客中介绍过几个矢量图库网站,在WPF程序中,一般接触到的矢量图标资源有XAML.SVG.字体这三种格式.XAML是标准格式就不说了,SVG并不是直接支持的,不过微软提供了Expression Design可以非常方便我们将其转换为XAML格式的资源.而对于字体,虽然WPF是直接支持的,但由于字体图标其特殊性,要将其显示为图标还是需要费点劲的.本文这里就以Font-Awesome为例,介绍一下如何在WPF中使用字体图标. 首先添加一个样式,为了使用方便,建议直接做为全局样式: <Styl

Simple Validation in WPF

A very simple example of displaying validation error next to controls in WPF Introduction This is a simple example of validation in XAML for WPF controls and displaying error messages. Background I was looking for something out-of-the-box from WPF wh

Spark学习笔记——在远程机器中运行WordCount

1.通过realy机器登录relay-shell ssh [email protected] 2.登录了跳板机之后,连接可以用的机器 XXXX.bj 3.在本地的idea生成好程序的jar包(word-count_2.11-1.0.jar)之后,把jar包和需要put到远程机器的hdfs文件系统中的文件通过scp命令从开发机传到远程的机器中 scp 开发机用户名@开发机ip地址:/home/XXXXX/文件 . #最后一个.表示cd的根目录下 object WordCount { def mai

通过WinForm控件创建的WPF控件无法输入的问题

今天把写的一个WPF程序发布到别的机器上执行,发现一个比较奇怪的问题:在那个机器上用英文输入法无法输入数字,非要切换到中文输入法才行:但在我的机器上却是好好的. 最开始以为是输入法的问题,弄了好一阵子后,终于找到了原因:虽然这个程序是个WPF程序,但为了复用之前的部分代码,使用着一个WinForm的菜单控件,后续的子窗口都是通过这个WinForm菜单创建的.而用WinForm控件创建的WPF控件可能出现无法正确响应键盘事件的情况. 找到了原因后,一个常规的解决方法是:将WinForm控件换成WP