RichTextBox中的相对绑定到其段落

时间:2013-04-21 13:08:09

标签: wpf binding richtextbox controltemplate

我想通过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对于Pararaph()。我怎么能这样做?

由于

0 个答案:

没有答案