How to refer to the element Label?

<Button x:Name="but" HorizontalAlignment="Left" Margin="256,126,0,0" VerticalAlignment="Top" Width="237" Height="183"> <Button.Template> <ControlTemplate TargetType="Button"> <Grid> <Label x:Name="txt" Height="100" Width="100"/> </Grid> </ControlTemplate> </Button.Template> </Button> 
  • And what problem do you solve? In styles, they usually alter the look of the element itself, but do not put another in there in order to then turn to it. - EvgeniyZ
  • @EvgeniyZ Well then I didn’t do it right, I’m just starting to get acquainted with wpf. If so, is it possible and is it right to put one element into another? - MrBorman
  • @EvgeniyZ I remembered ... the essence is, I made the appearance and added elements, but if you add elements outside of this design, only the appearance will be visible, and these elements will be invisible. - MrBorman pm
  • Do not add items manually, use ItemsControl and templates - Andrey NOP
  • @ AndreyNOP you can write an example so that it is clear how to do it - MrBorman

0