1

我想通过ItemsControl旁边的显示一行文本RichTextBox。因此我创建了这个ControlTemplate

<RichTextBox Margin="5,0,5,0">
        <RichTextBox.Resources>
            <Style TargetType="{x:Type Paragraph}">
                <Setter Property="Margin" Value="5,0,5,0"/>
                <Setter Property="LineHeight" Value="30"/>
                <Setter Property="LineStackingStrategy" Value="BlockLineHeight"/>                    
            </Style>
        </RichTextBox.Resources>
        <RichTextBox.Template>
        <ControlTemplate>
            <StackPanel Orientation="Horizontal">
                    <ItemsControl ItemsSource="{Binding Lines}" Margin="5,0,5,0">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel />
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                        <DataTemplate>
                                <ToggleButton Content="{Binding}" Height="{Binding BIND_ME_TO_LineHeigh_OF_PARAGRAPH" />
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>                       
                    <Border Name="Border" CornerRadius="2" Padding="2" Background="White" BorderBrush="Black" BorderThickness="0" >
                    <ScrollViewer Margin="0" x:Name="PART_ContentHost"/>
                </Border>
            </StackPanel>
            </ControlTemplate>
        </RichTextBox.Template>

为了使项目ItemsControl与段落的行大小相同,我想将ToggleButton' 高度绑定到我在Style段落 ( ) 中定义的段落的 LineHeight 。我怎样才能做到这一点?

谢谢

4

0 回答 0