Is it required to use the Clip
functionality? Or is OpacityMask
an option? The following code comes close to such a clock:
<Grid VerticalAlignment="Center" HorizontalAlignment="Center" TextElement.FontSize="36">
<Grid.Resources>
<Style x:Key="UpperHalfStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="0"/>
<Setter Property="OpacityMask">
<Setter.Value>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0.5" Color="White"/>
<GradientStop Offset="0.5" Color="Transparent"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LowerHalfStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Margin" Value="0,2,0,0"/>
<Setter Property="OpacityMask">
<Setter.Value>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Offset="0.5" Color="Transparent"/>
<GradientStop Offset="0.5" Color="White"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<StackPanel Orientation="Horizontal">
<Grid>
<TextBlock Text="1" Style="{StaticResource UpperHalfStyle}"/>
<TextBlock Text="1" Style="{StaticResource LowerHalfStyle}"/>
</Grid>
<Grid>
<TextBlock Text="0" Style="{StaticResource UpperHalfStyle}"/>
<TextBlock Text="0" Style="{StaticResource LowerHalfStyle}"/>
</Grid>
<TextBlock Text=":"/>
<Grid>
<TextBlock Text="3" Style="{StaticResource UpperHalfStyle}"/>
<TextBlock Text="3" Style="{StaticResource LowerHalfStyle}"/>
</Grid>
<Grid>
<TextBlock Text="7" Style="{StaticResource UpperHalfStyle}"/>
<TextBlock Text="7" Style="{StaticResource LowerHalfStyle}"/>
</Grid>
</StackPanel>
</Grid>
I just overlay two TextBlock
elements. The first one is only opaque in the upper half, while the second one is only opaque in the lower half. I also added a Margin
to the lower half, so that it becomes clear that they are two different elements. I do not know the rest of your design, but I assume you will want to add borders around the numbers. For this, you might have to restrict the height of the elements somehow. Otherwise the borders will surround the whole TextBlock
and not just the visible part.