I am trying to bind several different properties in my Xaml:
<Label Content="{Binding Description}" Visibility="{Binding Path=DescriptionVisibility, ElementName=_UserInputOutput}" FontSize="{Binding Path=FontSizeValue, ElementName=_UserInputOutput}" HorizontalAlignment="Left" VerticalAlignment="Top" Padding="0" />
You noticed that I used two different binding methods here. Those who use the Element Name work, and the other does not. Here is the code behind:
public string Description { get { return (string)GetValue(DescriptionProperty); } set { SetValue(DescriptionProperty, value); } } public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register("Description", typeof(string), typeof(UserControl), new UIPropertyMetadata(""));
Each binding has a different name, but they all look like for the most part. I want my binding to work with:
{Binding Description}
Instead:
{Binding Path=Description, ElementName=_UserInputOutput}
It seems to work only when using ElementName. I need to export / import this XAML, so I cannot have ElementName or import will not work.
I thought this would be best:
{Binding Path=Description, RelativeSource={RelativeSource Self}}
This did not work.
Any ideas? Thank!
wpf binding
B-Rad Aug 16 '12 at 20:57 2012-08-16 20:57
source share