1. 程式人生 > >wpf 繫結表示式和手動更新源

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


        }
    }
}

相關推薦

wpf 表示式手動更新

<Window x:Class="BindingExpressionExam.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmln

WPF中PopupContextMenu類無法以常規方式資料命令,但只能通過引數PlacementTarget獲得父控制元件

比如 <Window x:Name="window"> <ItemsControl Items="{Binding BookItems}"> <ItemsControl.ItemTemplate> <DataTemplate&g

WPF datagridlist容器無法更新顯示

Xml程式碼片段: <DataGrid x:Name="DataGridGap_y"  RowHeaderWidth="0"  AlternationCount="2" Grid.Row="1" Grid.Column="0"   AutoGenerateColumn

wpf 資料無法更新ui控制元件可能存在的問題

BindingMode的列舉值有: ① OneWay ② TwoWay ③ OneTime:根據源端屬性值設定目標屬性值,之後的改變會被忽略,除非呼叫BindingExpression.UpdateTarge方法 ④ OneWayToSource:與OneWay類似,

WPF到linq表示式

using ClassLibrary;using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Linq;using System.Text;

關於LookUpEdit資料來源取值

首先在GridControl裡在Repository中新增一個GridLookUpEdit 在設定DisPlayMember(介面顯示欄位) 然後在後臺繫結資料 List<EntityBrand> entityBrand = client.GetBrandList(); this.rep

Windows 7下用arp命令IPMAC地址,提示“ARP 項新增失敗: 拒絕訪問”的解決方法

在Win 7版本以管理員身份執行時提示:“ARP 項新增失敗:請求的操作需要提升。”    解決辦法: CMD中輸入:netsh i  i show in  //注意兩個i之間是有空格的 然後找到“本地連線”對應的 “Idx” (我的是

jQuery的onclick直接click區別

狀況之外 在之前的公司並沒有遇到這個問題,也就沒有深究。直到自己換了現在的公司,剛來第二天就開始寫別人寫到一半的專案,很無奈,不是原生就是jquery,由於專案急,已經來不及切換框架重新佈局,只能繼續了。 狀況之中 到處都是列表,到處都是js建立的動態頁面,好吧,那我也繼續吧,突然,意外發生了

python3__面向物件__靜態方法 / 類方法 / 屬性方法 / 例項動態屬性方法 / 類動態屬性方法

0.普通方法 普通方法訪問類屬性:self.__class__.類屬性名稱 class Test(object): n = 123 def __init__(self, n): self.n = n def tell(self):

WPF--自定義資料型別

WPF作為資料繫結的目標: 使用DataContext屬性,表示當前控制元件中的每個元素都繫結此資料: 資料型別定義: public class FamilyData { private string m_familyName; private string m_widt

jQuery中用on事件用bind事件的區別

jQuery兩種繫結事件,舉例說明: 以上三種方法都是對ul下的li進行繫結 其中方法一和方法二完全一樣,作用是:給ul下已經存在的li新增繫結事件,方法繫結在了li上,一旦出現新的li,點選方法是無法繫結在新的li上的。 因為繫結方法已經完成,任務分發到各個li上,

v-bind class style 的幾種方法

v-bind 繫結class  一、物件語法: 1. 資料屬性物件語法: <style> <!--新建一個active 的class--> .active{color:red} </style> <!--v-bind

WPF兩個ComboBox互相響應對方的選擇不成功請求幫助

windows2008無法執行.netremoting服務程式在XP,win2003下一切正常如何為ListView的每一ListViewItem新增MouseMove事件windows2008無法執行.netremoting服務程式在XP,win2003下一切正常如何為Li

Android8.0 HIDL直通式區別

原址 備註:這裡已Camera模組為例,如問題,歡迎討論。    以往的hal和framwork的程式碼緊密聯絡起來的,為此google為了framework  升級的方便在Android 8.0 上對 Android 作業系統底層進行了重新架構。新的架構已經瞭解一部分,但仍

Hadoop異常拒絕連線問題的解決

繫結異常 Hadoop BindException 和 Connection Refused 1. java.net.BindException: Address already in use 如果其他程式已經佔用了該地址或埠就會發生這樣的錯誤。 netstat -a -t

python學習之-方法方法

繫結方法 @classmethod 函式功能上面新增這個內建函式就是繫結給類 繫結給類的,引數裡面就是cls,cls這個是規範的寫法,cls就是指傳入的是類 特殊之處: 繫結給誰就應該由誰來呼叫,會將呼叫者(點左邊的就是呼叫者)當做第一個引數自動傳入 繫結物件的方法: 類中定義的函式在沒有

Vue某些情況下 v-model資料不實時更新解決辦法

有的時候我們變化data內的內容,console.log列印的時候是顯示已經變化了的,但並沒有渲染到介面上去。受 ES5 的限制,Vue.js 不能檢測到物件屬性的新增或刪除。因為 Vue.js 在初始化例項時將屬性轉為 getter/setter,所以屬性必須

wpf全域性靜態變數(mvvm)

原文 wpf繫結全域性靜態變數(mvvm) 在實際的開發中,有一些集合或者屬性可能是全域性的,比如當你做一個oa的時候,可能需要展示所有的人員,這時這個所有的人員列表顯然可以作為全域性引數,比如這裡有一個全域性的靜態屬性UserList。而你在使用mvvm做wpf開發的時候,一般每個view都已經

Ubuntu 16.04anaconda3anaconda2

1.開啟終端並輸入: sudo gedit  ~/.bashrc   2.在.bashrc檔案末尾新增:(路徑換成自己的) export PATH=/home/pico/anaconda3/bin:$PATH  然後儲存,關閉檔案  3

CentOS Ubuntu 更新

yum,是Yellow dog Updater, Modified 的簡稱,是杜克大學為了提高RPM 軟體包安裝性而開發的一種軟體包管理器。起初是由yellow dog 這一發行版的開發者Terra Soft 研發,用Python 寫成,那時還叫做yup(yel