zoukankan      html  css  js  c++  java
  • WPF 得一些问题汇总

    1.CallMethodAction

    <TextBox Height="30" Name="txtUserName" Width="160" FontSize="20" VerticalContentAlignment="Center" Text="{Binding UserNme}">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="KeyDown">
                    <ei:CallMethodAction TargetObject="{Binding}" MethodName="UserNameKeyDown" />
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </TextBox>
    public void UserNameKeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            Login(null);
        }
    }

    2.TabControl

      

    <Window x:Class="wpfApplication" ... 
       Title="Window1" Height="100" Width="200">
    
    <ScrollViewer>
        <TabControl Height="500" Margin="20" SelectionChanged="TabControlSelectionChanged">
             <TabItem Header="tabItem1">
                <Grid>
                   <TextBox />
                <Grid>
             </TabItem>
             <TabItem Header="tabItem2">
                <Grid>
                   <TextBox />
                <Grid>
             </TabItem>
             <TabItem Header="tabItem3">
                <Grid>
                   <TextBox />
                <Grid>
             </TabItem>
        </TabControl>
    </ScrollViewer>
    
    </Window>

    C#代码:
    private void TabControlSelectionChanged(object sender, SelectionChangedEventArgs e){
       var item = tabControl1.SelectedItem as TabItem;
       if (e.Source is TabControl){
          item.Focus();
       }
    }
  • 相关阅读:
    stress-Linux系统压力测试工具使用及系统负载很高的几种场景测试
    execsnoop-短时进程追踪工具
    走迷宫--DFS
    马踏棋盘--dfs
    查询前缀出现的次数----字典树
    找两个质数和为偶数的两个数
    煤气灶---递归
    求合力
    hdu2089---不要62(数位DP)
    轻重匹配
  • 原文地址:https://www.cnblogs.com/wxf82610/p/3448253.html
Copyright © 2011-2022 走看看