Вы можете получить атрибут связанного свойства с помощью техники отражения.
Ниже приведен пример кода.
SomeEntity.cs
public class SomeEntity
{
[SomeAttribute]
public string SomeValue { get; set; }
}
MainWindow.xaml
<Window x:Class="WpfApplication4.MainWindow" ...>
<StackPanel>
<TextBox Name="textBox" Text="{Binding SomeValue}"/>
<Button Click="Button_Click">Button</Button>
</StackPanel>
</Window>
MainWindow.xaml.cs
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = new SomeEntity();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
// Get bound object from TextBox.DataContext.
object obj = this.textBox.DataContext;
// Get property name from Binding.Path.Path.
Binding binding = BindingOperations.GetBinding(this.textBox, TextBox.TextProperty);
string propertyName = binding.Path.Path;
// Get an attribute of bound property.
PropertyInfo property = obj.GetType().GetProperty(propertyName);
object[] attributes = property.GetCustomAttributes(typeof(SomeAttribute), false);
SomeAttribute attr = (SomeAttribute)attributes[0];
}
}