我有一个WPF列表框,其项目由数据模板定义,该数据模板由一个水平对齐的网格组成,该网格包含标签和按钮。单击按钮时,我想将标签文本作为参数传递。对于CommandParameter,是否有可以指定的Binding来获取标签的文本值?
<ListBox.ItemTemplate>
<DataTemplate >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="114*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1000"/>
<ColumnDefinition Width="100*"/>
<ColumnDefinition Width="200*"/>
</Grid.ColumnDefinitions>
<Label x:Name="JobFileNameLabel" Grid.Column="0" Content="{Binding JobFileName}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="36" FontWeight="Bold" Padding="0"/>
<Button Command="{Binding DataContext.PrintJobBtnClickedCommand,RelativeSource={RelativeSource AncestorType=ListBox}}" Grid.Column="1" Content="Print" HorizontalAlignment="Center" Margin="25,19,23,25" VerticalAlignment="Center" Width="150" Height="70" RenderTransformOrigin="0.203,-0.173" FontSize="36" FontWeight="Bold" Padding="0"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>