1

I have a global TextBlock style defined, but it doesn't work properly in my xaml. In this example, in the first TextBlock the style works, but the others TextBlock (inside ItemsControl block) don't work. Why does the global style work in the first TextBlock and not the rest?

Thanks for the help.

<UserControl x:Class="CalculMUResults.CalculMUResultsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:CalculMUResults"
             mc:Ignorable="d" 
             d:DesignWidth="800">

    <UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="FontFamily" Value="Comic Sans MS"/>
            <Setter Property="FontSize" Value="12"/>
        </Style>  
    </UserControl.Resources>
    
    <Grid Background="Gray">        
        <Grid.RowDefinitions>
            <RowDefinition Height="2*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--CalculMU Results-->
        <Grid Grid.Row="0"> 
            <!--....--> 
        </Grid>

        <!--Ref Points no valids-->
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <TextBlock Grid.Row="0" Text="Errors"/>
            <ItemsControl Grid.Row="1" Grid.ColumnSpan="4" ItemsSource="{Binding BeamPointNotValid}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="2*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Text="{Binding Item1}" />
                            <TextBlock Grid.Column="1" Text="{Binding Item2}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Grid>

        <!--Segments-->
        <Grid Grid.Row="2">
            <!--....-->
        </Grid>
    </Grid>
</UserControl>
Rubi
  • 13
  • 2

0 Answers0