zoukankan      html  css  js  c++  java
  • wpf 绑定表达式和手动更新源

    <Window x:Class="BindingExpressionExam.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Slider Name="slider" Minimum="1" Maximum="100" TickFrequency="1" HorizontalAlignment="Left" Margin="118,58,0,0" VerticalAlignment="Top" Width="265"/>


            <!--绑定延时-->
            <!--<TextBox Name="txt" HorizontalAlignment="Left" Height="23" Margin="118,156,0,0" TextWrapping="Wrap" Text="{Binding ElementName=slider, Path=Value,UpdateSourceTrigger=PropertyChanged, Delay=1000}" VerticalAlignment="Top" Width="120"/>-->
            <TextBox Name="txt" HorizontalAlignment="Left" Height="23" Margin="118,156,0,0" TextWrapping="Wrap" Text="{Binding ElementName=slider, Path=Value,UpdateSourceTrigger=Explicit}" VerticalAlignment="Top" Width="120"/>

            <Button Content="Button" HorizontalAlignment="Left" Margin="326,156,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>

        </Grid>

    </Window>


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;


    namespace BindingExpressionExam
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }


            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                BindingExpression be= txt.GetBindingExpression(TextBox.TextProperty);
                be.UpdateSource();

            }
        }
    }


  • 相关阅读:
    python模块之__future__模块
    SQL之分组排序取top n
    SQL之层次查询
    win server 2008添加磁盘-脱机转换为联机状态方法
    拉链表-增量更新方法一
    一道hive SQL面试题
    一道与时间差有关的SQL面试题
    (转)linux中nmcli命令的使用及网络配置
    (转)内核模块操作命令-lsmod+rmmod+modinfo+modprobe
    (转)Linux 系统设置 : dmesg 命令详解
  • 原文地址:https://www.cnblogs.com/dxmfans/p/9434692.html
Copyright © 2011-2022 走看看