我定义了一个类CLASS,其中包含 5 个成员:int A、   int B、int C、string D、string E。D此外OB,我已经CLASS使用.TextBlockItemTemplate
现在我试图OB在单击 后获取对象,TextBlock以便对等做一些事情。有谁知道如何在 C# 代码中做到这一点?OB.AOB.B
我定义了一个类CLASS,其中包含 5 个成员:int A、   int B、int C、string D、string E。D此外OB,我已经CLASS使用.TextBlockItemTemplate
现在我试图OB在单击 后获取对象,TextBlock以便对等做一些事情。有谁知道如何在 C# 代码中做到这一点?OB.AOB.B
private void myTextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    var myTextBlock = sender as TextBlock;
    if (myTextBlock == null) return;
    BindingExpression binding = myTextBlock.GetBindingExpression(TextBlock.TextProperty);
    CLASS BindedInstance = binding.ResolvedSource as CLASS; // Equals to OB object
    BindedInstance.A = ... /// Do whatever you want with the rest of properties
}