1、wpf中点击button按钮后怎么让TextBlock显示button按钮的值?
<TextBlock x:Name="CurProtext" Grid.Column="1" FontWeight="Bold"></TextBlock>
<Button Grid.Column="1" Grid.Row="0" Content="{Binding Path=ProSelectInfor.AppFormulaList[0].Name}" Click="ProBut_click" FontWeight="Bold"></Button>
/// <summary>
/// 项目选择按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ProBut_click(object sender, RoutedEventArgs e) { string s = (string)((Button)sender).Content; CurProtext.Text = s;}
2、如何在wpf中画出多行多列的列表,使用什么控件实现?
DataGrid
<DataGrid
ItemsSource="{Binding Path=RunRecordList}" AutoGenerateColumns="False" > <DataGrid.Columns> <DataGridTextColumn Binding="{Binding Path=ProId}" Header="序号" MinWidth="120"/> <DataGridTextColumn Binding="{Binding Path=ProName}" Header="程序名" MinWidth="120"/> <DataGridTextColumn Binding="{Binding Path=RunTime}" Header="运行时间" MinWidth="200"/> </DataGrid.Columns> </DataGrid>
3、打印问题
增加wpf控件进入流文档
InlineUIContainer和BlockUIContainer
InlineUIContainer 和 BlockUIContainer 提供了可以在Flow Document中插入WPF控件的能力。InlineUIContainer 可以被声明在像Paragraph等支持inline元素的对象中来Host任意的WPF控件,而BlockUIContainer可以被声明在像Section等支持block元素的对象中。他们都可以host任意的WPF控件。
<Section>
<Paragraph>
This contains some text and
<InlineUIContainer>
<Button>Button Control</Button>
</InlineUIContainer>
interspersed.
</Paragraph>
<Section>
<BlockUIContainer>
<Button>Host In Block Control</Button>
</BlockUIContainer>
</Section>
</Section>
4、如何外部读取一个文件夹内所有的xml文件的文件名,去掉后缀
private void ProRead()
{ObservableCollection < string >ss = new ObservableCollection<string>();
DirectoryInfo dir = new DirectoryInfo("E:\\1");
foreach (FileInfo d in dir.GetFiles()) { ss.Add(d.Name.Remove(d.Name.LastIndexOf("."))); } ss.ToArray(); ProSelectInfor.ProNameList = new ObservableCollection<string>(ss.ToArray());}