In XAML I’ve created a Button like this:
<Button MouseEnter="Button_MouseEnter">
<Button.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="asd"/>
<Label Grid.Row="1" Content="xxx"/>
<Label Grid.Row="2" Content="yyy"/>
</Grid>
</Button.Content>
</Button>
And now I need to access one of those controls inside of Button’s Content in code-behind. Lets say i need the TextBlock one.
private void Button_MouseEnter(object sender, MouseEventArgs e)
{
Button button = (Button)sender;
// ?
}
How can I do that?
Also I have multiple buttons like this one created automatically with data binding.
The reason I need to access those controls is that I want to animate one of them in certain situation.
Your button.Content should be a Grid, right? you can cast it.