Not sure, if I should have started a new thread, since this is regarding the editable Tab header. I am facing some problems binding it to a observable collection of user defined controls. All I need to do it bind the "Name" property in my Usercontrol to the header of the tab control and make it editable, as discussed in this forum.
Since, I cant attach the file, I am pasting the code here
MY user Control looks like below
public
partial class TestControl : UserControl, INotifyPropertyChanged
{
private string title;
public TestControl()
{
InitializeComponent();
}
public string Name
{
get
{
return this.title;
}
set
{
this.title = value;
this.OnPropertyChanged("Title");
}
}
#region
INotifyPropertyChanged Members
/// <summary>
/// Called when the value of a property changes.
/// </summary>
/// <param name="propertyName">The name of the property that has changed.</param>
protected virtual void OnPropertyChanged(String propertyName)
{
if (String.IsNullOrEmpty(propertyName))
{
return;
}
if (PropertyChanged != null)
{
PropertyChanged(
this, new PropertyChangedEventArgs(propertyName));
}
}
/// <summary>
/// Raised when the value of one of the properties changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
#endregion
}
My MainPAge XAML looks like as below (I used the same sample that was mentioned in TabControlEditableHeaders
public
partial class Page : UserControl
{
//private ObservableCollection<MyDatum> MyData;
private ObservableCollection<TestControl> myTestControls;
public Page()
{
InitializeComponent();
myTestControls =
new ObservableCollection<TestControl>();
myTestControls.Add(
new TestControl() { Name = "Header Title" });
myTestControls.Add(
new TestControl() { Name = "Header second title" });
tabControl.ItemsSource = myTestControls;
}
private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
RadTabItem radItem = (RadTabItem)this.tabControl.SelectedItem;
RadWindow.Alert((new DialogParameters()
{
Header =
"SI Processing",
Content = radItem.Header.ToString(),
Theme =
new Windows7Theme()
}));
}
/// <summary>
/// Called when the value of a property changes.
/// </summary>
/// <param name="propertyName">The name of the property that has changed.</param>
protected virtual void OnPropertyChanged(String propertyName)
{
if (String.IsNullOrEmpty(propertyName))
{
return;
}
if (PropertyChanged != null)
{
PropertyChanged(
this, new PropertyChangedEventArgs(propertyName));
}
}
/// <summary>
/// Raised when the value of one of the properties changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
}
My XAML is as below<
UserControl x:Class="TabControlEditableHeaders.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TabControlEditableHeaders"
xmlns:nav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Button x:Name="btnSubmit" Click="btnSubmit_Click" Content="HIT ME!"/>
<nav:RadTabControl x:Name="tabControl">
<nav:RadTabControl.ItemTemplate>
<!--The Content Template:-->
<DataTemplate>
<StackPanel Orientation="Vertical" Background="WhiteSmoke">
</StackPanel>
</DataTemplate>
</nav:RadTabControl.ItemTemplate>
<nav:RadTabControl.ItemContainerStyle>
<Style TargetType="nav:RadTabItem">
<Setter Property="HeaderTemplate">
<Setter.Value>
<!--The Header Template:-->
<DataTemplate>
<local:EditableContentControl Style="{StaticResource EditableContentControlStyle}"
Content="{Binding Path=Name, Mode=TwoWay}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</nav:RadTabControl.ItemContainerStyle>
</nav:RadTabControl>
</Grid>
</
UserControl>
But Somehow, I am not able to see the "Name" in the header of the tab Control, Could you please help me out, I have been trying really hard to get this fixed :(
As a note, I am using the EditableContentControl for the