Note that there are some explanatory texts on larger screens.

plurals
  1. POPropertyChangedEventHandler always null in silverlight binding
    primarykey
    data
    text
    <p>I've been trying to resolve this issue for some time. I'm trying to bind a TextBlock's text to a string property using the INotifyPropertyChanged interface. For some reason the PropertyChangedEventHandler is always null when the value of the property is changed thus the target never gets updated... Any suggestions? Code below:</p> <p>XAML code:</p> <pre><code>&lt;UserControl x:Class="MoleDashboard.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" xmlns:datacontrols="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data" xmlns:prop="clr-namespace:MoleDashboard" &lt;UserControl.Resources&gt; &lt;prop:YearScreen x:Key="YearScreenProps"/&gt; &lt;/UserControl.Resource&gt; &lt;TextBlock Margin="10 5" x:Name="DataGridLabel" Visibility="Visible" Text="{Binding YearProperty, Source={StaticResource YearScreenProps}, Mode=OneWay}"/&gt; </code></pre> <p>Bound property code:</p> <pre><code>public class YearScreen : INotifyPropertyChanged { private string metricProperty; private string yearProperty; public event PropertyChangedEventHandler PropertyChanged; public YearScreen() { } public string YearProperty { get { return yearProperty; } set { yearProperty = value; this.OnPropertyChanged("YearProperty"); } } public string MetricProperty { get { return metricProperty; } set { metricProperty = value; this.OnPropertyChanged("MetricProperty"); } } public void OnPropertyChanged(string property) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(property)); } } } </code></pre>
    singulars
    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