I use a custom control that has a dependencyproperty Title that binds to a label within.
I can set the Title property in xaml with a string but not with a {Binding title}.
If I use a <Button content={Binding title}
that works.
I really dont know where to look on this one as i guess string is string .. ?
WORKS
<Button Content="{Binding title}" Click="Button_Click_2">
WORKS
<PluginInterface:uc_item Title="TEST" OnClick="Button_Click_2"></PluginInterface:uc_item>
DOES NOT WORK
<PluginInterface:uc_item Title="{Binding title}" OnClick="Button_Click_2"></PluginInterface:uc_item>
THE DEPENDENCY PROPERTY
public string Title
{
get { return (string)GetValue(TitleProperty); }
set
{
SetValue(TitleProperty, value);
}
}
public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), typeof(uc_item),
new FrameworkPropertyMetadata(default(string),
FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
THIS IS THE CONTAINER FOR THE CONTROLS
<ItemsControl Name="ic_searchengines" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
IM SETTINGS THE ITEMSSOURCE OF THE ITEMSCONTROL IN ANOTHER CLASS
searchengines = new ObservableCollection<searchengine>();
main.ic_searchengines.ItemsSource = searchengines;
the binding in the first example with the button does show the bound text in the content; in the second example, setting a string on the cusotm user control shows the text on the usercontrol; third example, binding equivalent to the first button does show blank on the usercontrl.
Thanks! Looking forward