Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Binding to textbox not updating
    primarykey
    data
    text
    <p>I have am writing a WPF application, and I have a textbox for the user to enter a frames per second value for video playback. The value of this textbox is bound to a dependency property in the code behind (trying to follow MVVM like a good designer). My problem is that the textbox is not updating automatically when the FPS value is changed externally. For example, the user can control the value using a slider. The dependency properties value is changed correctly by the slider, but the textboxes text never updates, unless, of course, i do it manualy using GetBindingExpression(..).UpdateTarget() which is what I have implemented pending a better solution. Does anyone know if this is intended functionality or am I setting something up wrong?</p> <p>Thanks, Max</p> <p>TextBox tag in XAML:</p> <pre><code>&lt;TextBox Text="{Binding FPS}" Name="tbFPS" FlowDirection="RightToLeft"/&gt; </code></pre> <p>Code behind for dependency property:</p> <pre><code> #region public dependency property int FPS public static readonly DependencyProperty FPSProperty = DependencyProperty.Register("FPSProperty", typeof(int), typeof(GlobalSettings), new PropertyMetadata(MainWindow.appState.gSettings.fps,FPSChanged,FPSCoerce), FPSValidate); public int FPS { get { return (int)GetValue(FPSProperty); } set { SetValue(FPSProperty, value); } } private static bool FPSValidate(object value) { return true; } private static object FPSCoerce(DependencyObject obj, object o) { return o; } private static void FPSChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { //why do i need to update the binding manually? isnt that the point of a binding? // (obj as GlobalSettings).tbFPS.GetBindingExpression(TextBox.TextProperty).UpdateTarget(); } #endregion </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload