我为 LibraryContainer 定义了以下 DataTemplate:
<DataTemplate x:Key="ContainerItemTemplate">
<Grid>
<Border BorderThickness="1" BorderBrush="White" Margin="3">
<s:SurfaceTextBox IsReadOnly="True" Width="120" Text="{Binding Path=name}" Padding="3"/>
</Border>
<s:SurfaceButton Content="Expand" Click="SourceFilePressed"></s:SurfaceButton>
</Grid>
</DataTemplate>
SourceFilePressed 如下:
private void SourceFilePressed(object sender, RoutedEventArgs e)
{
Logging.Logger.getInstance().log(sender.ToString());
e.Handled = true;
}
在 SourceFilePressed 方法中,我可以获得绑定到 SurfaceTextBox 的对象,该对象与按下的按钮位于同一网格中?我可以在 DataTemplate 中以某种方式将此对象附加到 Click-Event 吗?