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
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>