Hi
I am trying to implement a custom RadToolBar control using control templating mechanism. I am having trouble with exposing Items property and not able to figure out how to expose it.
Code in Generic.Xaml
Base Class Code:
Custom Toolbar Class:
public class TngToolBar : TngBaseTemplateControl
{
private Object _itemsSource;
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
RadToolBar menu = this.Template.FindName("PART_BaseControl", this) as RadToolBar;
}
static TngToolBar()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TngToolBar), new FrameworkPropertyMetadata(typeof(TngToolBar)));
}
#region Property: DataContext
private Object _dataContext;
public Object DataContext
{
get { return GetValue(DataContextProperty); }
set { SetValue(DataContextProperty, value); }
}
public static readonly DependencyProperty DataContextProperty =
DependencyProperty.Register(
"DataContext", typeof(Object), typeof(TngToolBar),
new FrameworkPropertyMetadata
{
PropertyChangedCallback = (obj, e) =>
{
(obj as TngToolBar).UpdateDataContext((Object)e.NewValue);
}
});
private void UpdateDataContext(Object sel)
{
_dataContext = sel;
}
#endregion
#region Property: ItemsSource
public Object ItemsSource
{
get { return GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
"ItemsSource", typeof(Object), typeof(TngToolBar),
new FrameworkPropertyMetadata
{
PropertyChangedCallback = (obj, e) =>
{
(obj as TngToolBar).UpdateItemsSource(e.NewValue);
}
});
private void UpdateItemsSource(Object sel)
{
_itemsSource = sel;
}
#endregion
}