I have resolved this issue with a different way.
ComboBox SelectedItem is not what it displays but is what you select. When you select an Item comboBox takes the ComboBox displays it in SelectionBox's Template not in SelectedItem,s Template. If you will go into VisualTree of ComboBox, you will see that it has a ContentPresenter that contains a TextBlock and this TextBlock is assigned with the text of selected item.
So what i did, in SelectionChanged event handler i looked for the TextBlock inside that ContentPresenter using VisualTreeHelper
and then i Binded the Text property of this TextBlock to the Content property of my ContentControl(SelectedItem).
Edit:
In the SelectionChanged evetn handler of ComboBox I wrote:
ModifyCombox(cmbAnimationBlocks, myComboBox.SelectedItem.As<ContentControl>());
and this method is:
private static void ModifyCombox(DependencyObject comboBox, ContentControl obj)
{
if (VisualTreeHelper.GetChildrenCount(comboBox) > 0)
{
WalkThroughElement(comboBox, obj);
}
}
private static void WalkThroughElement(DependencyObject element, ContentControl contentControl)
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++)
{
if (element.GetType() == typeof(ContentPresenter))
{
ContentPresenter contentPresenter = element.As<ContentPresenter>();
TextBlock textBlock = VisualTreeHelper.GetChild(contentPresenter, 0).As<TextBlock>();
textBlock.SetBinding(TextBlock.TextProperty, new Binding("Content")
{
Source = contentControl
});
contentPresenter.Content = textBlock;
}
else
{
DependencyObject child = VisualTreeHelper.GetChild(element, i).As<FrameworkElement>();
WalkThroughElement(child, contentControl);
}
}
if (VisualTreeHelper.GetChildrenCount(element) == 0 && element.GetType() == typeof(ContentPresenter))
{
ContentPresenter contentPresenter = element.As<ContentPresenter>();
TextBlock textBlock = new TextBlock();
textBlock.SetBinding(TextBlock.TextProperty, new Binding("Content")
{
Source = contentControl
});
contentPresenter.Content = textBlock;
}
}