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