3
我有一个DataGrid,并且在DataGridTemplateColumn中,我有一个togglebutton,当它被选中时,它将在ElementName绑定的帮助下打开一个Popup注释。DataGridTemplateColumn中的ElementName绑定
<WpfToolkit:DataGridTemplateColumn>
<WpfToolkit:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid >
<StackPanel Orientation="Vertical">
<ToggleButton Content="C" Name="toggleButon" VerticalAlignment="Center" Background="Transparent"></ToggleButton>
<Popup Height="Auto" Width="300" IsOpen="{Binding ElementName=toggleButon,Path=IsChecked}" StaysOpen="True" AllowsTransparency="True">
<Border BorderThickness="2" Background="LightGray">
<StackPanel Margin="20" Orientation="Vertical">
<TextBlock Text="Bloomberg Run Text Comment" Foreground="Black"></TextBlock>
<TextBox Text="check"/>
</StackPanel>
</Border>
</Popup>
</StackPanel>
</Grid>
</DataTemplate>
</WpfToolkit:DataGridTemplateColumn.CellTemplate>
</WpfToolkit:DataGridTemplateColumn>
它按预期工作。但我很想知道elementName绑定是如何在rowlevel中工作的,因为按照我的理解,ToggleButton的elementname对于每一行都是相同的。那么切换按钮如何仅在其范围内打开弹出窗口,而不在其他任何行中打开任何其他弹出窗口。