I have a couple of TextBox on the frame, I changed their style so that their DeleteButton would DeleteButton be visible. However, these boxes do not respond to a click if their IsReadOnly property is true . I have assigned a new click handler, but now I need to determine which TextBox the clear button pressed. So, how to determine the parent of the button in this event?
Update, I did not insert it.
private void DeleteButton_Click(object sender, RoutedEventArgs e) { //var parent = ((Button) sender).Parent;? } A piece of TextBox style:
<Button x:Name="DeleteButton" BorderThickness="{TemplateBinding BorderThickness}" Grid.Column="1" FontSize="{TemplateBinding FontSize}" IsTabStop="False" Margin="{ThemeResource HelperButtonThemePadding}" MinWidth="34" Grid.Row="1" Style="{StaticResource DeleteButtonStyle}" Visibility="Visible" VerticalAlignment="Stretch" Click="DeleteButton_Click"/>