• WPF-编程问题和解决


    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控件进入流文档

    InlineUIContainerBlockUIContainer

    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()); 

    }

  • 相关阅读:
    C#将datatable生成easyui的绑定tree 的json数据格式
    asp.net DataTable转JSON
    asp.net面试题
    windows笔记线程的一些性质
    windows笔记创建线程的另一个函数_beginthreadex
    windows笔记【内核对象线程同步】等待定时器内核对象
    windows笔记用哪个创建线程CreateThread还是_beginthread
    windows笔记【内核对象线程同步】信标内核对象
    windows笔记【内核对象线程同步】事件内核对象
    windows笔记【内核对象线程同步】等待函数
  • 原文地址:https://www.cnblogs.com/MiLu/p/6006769.html
Copyright © 2020-2023  润新知