zoukankan      html  css  js  c++  java
  • Windows Phone 系列 使用 MVVM绑定时无法获取当前值

    在使用 MVVM绑定时无法获取当前值

    后来发现一个方法,就是在changed事件中更新绑定

    如:textbox

    private void tbsearchCard_TextChanged(object sender, TextChangedEventArgs e)
    {
    UpdateTextBoxSource(sender);
    }

    public void UpdateTextBoxSource(object sender)
    {

    if (sender is TextBox)
    {
    TextBox tb = sender as TextBox;




    BindingExpression binding = tb.GetBindingExpression(TextBox.TextProperty);
    if (binding != null)
    binding.UpdateSource();
    }

    }

    如:Pivot

          private void pvtSearch_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
    if (sender is Pivot)
    {
    Pivot pvt = sender as Pivot;


    BindingExpression binding = pvt.GetBindingExpression(Pivot.SelectedIndexProperty);
    if (binding != null)
    binding.UpdateSource();
    }
    }

    OK

  • 相关阅读:
    第一轮 J
    第一轮 M
    第一轮 L
    第一轮 K
    第一轮 I
    第一轮 H
    第一轮 F
    第一轮 E
    第一轮 C
    12杭州online E 模拟
  • 原文地址:https://www.cnblogs.com/sunjunlin/p/2417119.html
Copyright © 2011-2022 走看看