自定义自关闭标签

问题描述

我正在尝试制作一个自动关闭标签,例如

<customTag />

我尝试使用customTag /

文档如何显示操作方法

https://pugjs.org/language/tags.html

但是在代码编译时不是,它会忽略我的“ /”并创建标签

<customTag> </customTag>

解决方法

如果仔细观察,自动关闭标签在element和true之间不能有空格,因此您需要删除空格,如下所示:

<Grid Grid.IsSharedSizeScope="True">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid Grid.Row="0" Margin="5">
        <Grid.ColumnDefinitions>
            <ColumnDefinition SharedSizeGroup="a" Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <DatePicker SelectedDate="{Binding Path=SelectedDate1,Mode=TwoWay}"/>
    </Grid>
    <Grid Grid.Row="1" Margin="5">
        <Grid.ColumnDefinitions>
            <ColumnDefinition SharedSizeGroup="a" Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <DatePicker SelectedDate="{Binding Path=SelectedDate2,Mode=TwoWay}"/>
    </Grid>
</Grid>

示例: SS