This is a migrated thread and some comments may be shown as answers.

NotifyChanged is allways null

1 Answer 48 Views
TimeBar
This is a migrated thread and some comments may be shown as answers.
Eric
Top achievements
Rank 1
Eric asked on 03 Aug 2012, 12:54 AM
Hello,

I have a user control which implments INotifyPropertyChanged, and has a radTimeBar declared in xaml.  I set the datacontext in codebehind to "this".  However, the Property changed never gets set, so I can't update the time bar properties.  Any Idea why this might be?  Here is a code sample:
Thanks,
Eric
public partial class PerfPresenter : INotifyPropertyChanged
    {
         public static readonly DependencyProperty VisiblePeriodStartProperty =
            DependencyProperty.Register("VisiblePeriodStart", typeof(DateTime), typeof(PerfPresenter));
 
        public static readonly DependencyProperty VisiblePeriodEndProperty =
            DependencyProperty.Register("VisiblePeriodEnd", typeof(DateTime), typeof(PerfPresenter));
        public DateTime VisiblePeriodStart
        {
            get { return (DateTime)GetValue(VisiblePeriodStartProperty); }
            set
            {
                SetValue(VisiblePeriodStartProperty, value);
                NotifyPropertyChanged(VisiblePeriodStartProperty.Name);
            }
        }
 
        public DateTime VisiblePeriodEnd
        {
            get { return (DateTime)GetValue(VisiblePeriodEndProperty); }
            set
            {
                SetValue(VisiblePeriodEndProperty, value);
                NotifyPropertyChanged(VisiblePeriodEndProperty.Name);
            }
        }
        public PerfPresenter()
        {
            this.DataContext = this;
            InitializeComponent();
        }
 
public event PropertyChangedEventHandler PropertyChanged;
 
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
}

<UserControl x:Class="Microsoft.Office.Engineering.PerfPresenter"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:Microsoft.Office.Engineering"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
        <Grid x:Name="PerfGrid" DataContext="{Binding}">
<
telerik:RadTimeBar x:Name="radTimeBar" DataContext="{Binding}"
                             
                            Grid.Column="1" Background="Transparent"
                            ItemIntervalChanged="RadTimeBar_ItemIntervalChanged"
                            PeriodStart="{Binding PeriodStart, Mode=OneWay}" PeriodEnd="{Binding PeriodEnd, Mode=OneWay}"
                            VisiblePeriodStart="{Binding VisiblePeriodStart, Mode=TwoWay}" VisiblePeriodEnd="{Binding VisiblePeriodEnd,Mode=TwoWay}"
                            Selection="{Binding TimeSelection, Mode=OneWayToSource}" MinSelectionRange="{Binding MinimumSelectionRange, Mode=OneWay}" SelectionChanged="TimeBarSelectionChanged"
                            MinZoomRange="{Binding ActualMinZoomRange, Mode=OneWayToSource}"
                            MouseDoubleClick="RadTimeBarMouseDoubleClick"
                            VisiblePeriodChanged="RadTimeBarVisiblePeriodChanged">
            <telerik:RadTimeBar.Margin>
                <Thickness Left="0"
                           Right="{x:Static SystemParameters.VerticalScrollBarWidth}"
                           Top="0"
                           Bottom="0"/>
            </telerik:RadTimeBar.Margin>
            <telerik:RadTimeBar.Intervals>
                <telerik:MinuteInterval IntervalSpans="1, 5, 10, 15" />
            </telerik:RadTimeBar.Intervals>
            <Grid x:Name="radTimeBarGrid">
            </Grid>
        </telerik:RadTimeBar>
</Grid>
</UserControl>

1 Answer, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 07 Aug 2012, 01:58 PM
Hi Eric,

In case you are using dependency properties, you should use the propertyChangedCallback of their PropertyMetadata to execute any custom logic, when the values of these properties change.

Kind regards,
Tsvetie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TimeBar
Asked by
Eric
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Share this question
or