Inherit Font Style and Font Size from StackPanel to TextBlock

codeamateur

New member
Joined
Apr 27, 2017
Messages
2
Programming Experience
3-5
I've got following xaml code:

C#:
<StackPanel Grid.Row="1" Grid.RowSpan="7" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center">
                <TextBlock Margin="15,30,0,0" Style="{StaticResource HeadingStyle}" Text="Access Denied"></TextBlock>
                <Label Margin="15,20,0,0" Content="You do not have permissions to delete the requested file"></Label>
                <Label Margin="15,20,0,0" Content="Exception Message"></Label>
                <TextBlock Margin="15,30,0,0"  TextElement.FontStyle="{Binding TextElement.FontStyle, RelativeSource={RelativeSource FindAncestor, AncestorType=StackPanel}}" Visibility="{Binding Path=HyperlinkVisible, Converter={StaticResource BoolToVis}}">
                    <Run Text="You can manually delete the file:" />
                    <Hyperlink Command="{x:Static controller:ToolPackageCreatorController.HyperlinkAlertMessageClickCommand}" CommandParameter="{Binding Path=HyperlinkText}" >
                        <Run Text="C:\\Workspace\\Main\\Toolpackages\\" />
                    </Hyperlink>
                </TextBlock>
            </StackPanel>

In the attached file Access_Denied.png you can see the resulting view, if the above mentioned xaml code is executed. However, I would like that the text in the TextBlock has the same Font Color, Font Style and Font Size like in the Labels. Additionally, the Horizontal alignment should be the same like in the Labels. How I can arrange this?
 

Attachments

  • Access_Denied_MessageBox_Only.png
    Access_Denied_MessageBox_Only.png
    15.1 KB · Views: 72
Back
Top Bottom