Judah Gabriel Himango
Judah Gabriel Himango

Reputation: 60021

How to set child item properties in Silverlight using XAML?

I've got a Grid in my XAML page. The grid is simply a holder for XAML loaded from the database:

<Grid x:Name="dynamicXamlHolder" />

I want all <TextBlock> objects that get inserted into that grid to have .TextWrapping = Wrap.

How can I do this? I'm sensing styles might be the answer, but it's unclear to me how to create a grid style that affects <TextBlock> elements in the grid.

Upvotes: 2

Views: 490

Answers (1)

Ozan
Ozan

Reputation: 4415

  <Grid.Resources>
    <Style TargetType="TextBlock">
       <Setter Property="TextWrapping" Value="Wrap" />
    </Style>
  </Grid.Resources>

Upvotes: 6

Related Questions