Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style definition in xaml #45

Closed
LauraKami opened this issue Nov 16, 2022 · 2 comments
Closed

Style definition in xaml #45

LauraKami opened this issue Nov 16, 2022 · 2 comments

Comments

@LauraKami
Copy link

Hi, I have this error message as soon I try to add style code in xaml.
I use MS Visual studio 22, with WPF application .NET 6

I have this error, with the demo code for Style

Severity	Code	Description	Project	File	Line	Suppression State
Error	XLS0508	Text not allowed as content in a dictionary or an array property.	WpfAppMdDemo2	MainWindow.xaml	45	
Error	MC3088	Property elements cannot be in the middle of an element's content.  They must be before or after the content. 

        <mdxam:MarkdownScrollViewer
            Grid.Column="1" Grid.Row="0"
            xml:space="preserve"
            x:Name="MSV"
            >
            # Heading 1
           
            ## Heading 2
            
            content
    <mdxam:MarkdownScrollViewer.MarkdownStyle>
        <Style TargetType="FlowDocument">
            <Style.Resources>  (<======= here is ligne 45)
                <Style TargetType="Paragraph">
                    <Style.Triggers>
                        <Trigger Property="Tag" Value="Heading1">
                            <Setter Property="FontSize"   Value="42" />
                            <Setter Property="Foreground" Value="Red" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>

                        <Trigger Property="Tag" Value="Heading2">
                            <Setter Property="FontSize"   Value="20" />
                            <Setter Property="Foreground" Value="Blue" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Style.Resources>
        </Style>
    </mdxam:MarkdownScrollViewer.MarkdownStyle>        </mdxam:MarkdownScrollViewer>
    </Grid>
@whistyun
Copy link
Owner

Sorry, I did not take into consideration the use of content and the property element together.
Coulds you please change the xaml to the following?

<!-- xmlns:mdxam="clr-namespace:MdXaml;assembly=MdXaml" -->
<!-- <Grid> -->
<Grid.Resources>
    <Style x:Key="MdStyle" TargetType="FlowDocument">
        <Style.Resources>
            <Style TargetType="Paragraph">
                <Style.Triggers>
                    <Trigger Property="Tag" Value="Heading1">
                        <Setter Property="FontSize"   Value="42" />
                        <Setter Property="Foreground" Value="Red" />
                        <Setter Property="FontWeight" Value="Light" />
                    </Trigger>
                    <Trigger Property="Tag" Value="Heading2">
                        <Setter Property="FontSize"   Value="20" />
                        <Setter Property="Foreground" Value="Blue" />
                        <Setter Property="FontWeight" Value="Light" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Style.Resources>
    </Style>

</Grid.Resources>


<mdxam:MarkdownScrollViewer 
    x:Name="MSV"
    Grid.Column="1" Grid.Row="0"
    MarkdownStyle="{StaticResource ResourceKey=MdStyle}"
    xml:space="preserve">
    # Heading 1

    ## Heading 2

    content
</mdxam:MarkdownScrollViewer>
<!-- </Grid> -->

@LauraKami
Copy link
Author

Here is the example for newbie like me ;o)
`

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="50*"/>
        <RowDefinition Height="50*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="50*"/>
        <ColumnDefinition Width="50*"/>
    </Grid.ColumnDefinitions>
    <Grid.Resources>
        <Style x:Key="MdStyle" TargetType="FlowDocument">
            <Style.Resources>
                <Style TargetType="Paragraph">
                    <Style.Triggers>
                        <Trigger Property="Tag" Value="Heading1">
                            <Setter Property="FontSize"   Value="42" />
                            <Setter Property="Foreground" Value="Red" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>
                        <Trigger Property="Tag" Value="Heading2">
                            <Setter Property="FontSize"   Value="20" />
                            <Setter Property="Foreground" Value="Blue" />
                            <Setter Property="FontWeight" Value="Light" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Style.Resources>
        </Style>

    </Grid.Resources>
    <mdxam:MarkdownScrollViewer 
        x:Name="MSV_R0C0"
        Grid.Row="0" Grid.Column="0"
        MarkdownStyle="{StaticResource ResourceKey=MdStyle}"
        xml:space="preserve">
            # Heading R0C0

            ## Heading 2

            content
    </mdxam:MarkdownScrollViewer>

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants