WPF Toolkit RichTextBox FontSize Binding - PullRequest
0 голосов
/ 15 мая 2019

У меня есть RichTextBox из WPFToolkit в форме с другими элементами управления, включая текстовое поле, и я связываю FontFamily и FontSize с обоими элементами управления. Мой выпадающий список выбирает каждый FontFamily и FontSize, а текстовое поле динамически меняет оба, а RichTextBox - нет.

Я пробовал связывать оба типа Double & String и получал одинаковый результат.

                <ComboBox Name="cmbFontFamily" 
                        ItemsSource="{Binding FontList}" 
                        HorizontalAlignment="Left"
                        SelectedItem="{Binding FontFamilySet, Mode=TwoWay}"  
                        Margin="5,0,0,0"
                        Grid.Row="0" 
                        Grid.Column="4" 
                        Grid.ColumnSpan="1" 
                        Height="30"
                        Width="125"
                        />
                <ComboBox Name="cmbFontFamilySize" 
                        ItemsSource="{Binding FontSizeList}" 
                        HorizontalAlignment="Left"
                        SelectedItem="{Binding FontSizeSet, Mode=TwoWay}"  
                        Margin="145,0,0,0"
                        Grid.Row="0" 
                        Grid.Column="4" 
                        Grid.ColumnSpan="1" 
                        Height="30"
                        Width="75"
                        />


            </Grid>
            <TabControl Name="tabControlCertLetterDesign" Height="750" Width="Auto" BorderBrush="Blue">
                <TabItem Header="Defieciency Letter" Name="DefieciencyTab" BorderBrush="Blue" Foreground="Blue" BorderThickness="3">
                    <ScrollViewer Width="Auto" Height="Auto" VerticalScrollBarVisibility="Auto" >
                        <Grid x:Name="LayOutRoot">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="10" />
                                <ColumnDefinition Width="300" />
                                <ColumnDefinition Width="800" />
                                <ColumnDefinition Width="15" />
                                <ColumnDefinition Width="52*" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="30"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                                <RowDefinition Height="80"/>
                            </Grid.RowDefinitions>

                            <Label  Content="{Binding LabelList, Converter={StaticResource FormLabelConverter}, ConverterParameter='reLabel'}" Grid.Column="1" Grid.Row="1" Height="25" HorizontalAlignment="Right" Margin="0,0,10,0"/>
                            <TextBox Text="{Binding CurrentCertGenLetterTempl.Re, Mode=TwoWay}"  Grid.Column="2" Grid.Row="1" Height="25" HorizontalAlignment="Stretch" FontFamily="{Binding FontFamilySet}" FontSize="{Binding FontSizeSet}"/>

                            <Label  Content="{Binding LabelList, Converter={StaticResource FormLabelConverter}, ConverterParameter='body1Label'}" Grid.Column="1" Grid.Row="3" HorizontalAlignment="Right" Margin="0,0,10,0"/>
                            <toolkit:RichTextBox Text="{Binding CurrentCertGenLetterTempl.Body1, Mode=TwoWay}"  Grid.Column="2" Grid.Row="3" Height="Auto" MinWidth="400" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left" VerticalAlignment="Stretch"  AcceptsTab="True" FontFamily="{Binding FontFamilySet}" FontSize="{Binding FontSizeSet}" />

                            <Label  Content="{Binding LabelList, Converter={StaticResource FormLabelConverter}, ConverterParameter='body2Label'}" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" Margin="0,0,10,0"/>
                            <toolkit:RichTextBox Text="{Binding CurrentCertGenLetterTempl.Body2, Mode=TwoWay}" Grid.Column="2"  Grid.Row="4" Height="Auto" MinWidth="400" ScrollViewer.VerticalScrollBarVisibility="Auto" HorizontalAlignment="Left" VerticalAlignment="Stretch"  AcceptsTab="True" FontFamily="{Binding FontFamilySet}" FontSize="{Binding FontSizeSet}"/>

    private string fontFamilySet;
    public string FontFamilySet
    {
        get
        {
            return fontFamilySet;
        }
        set
        {
            if ((fontFamilySet != value))
            {
                fontFamilySet = value;
                OnPropertyChanged("FontFamilySet");
            }
        }
    }


    private double fontSizeSet;
    public double FontSizeSet
    {
        get
        {
            return fontSizeSet;
        }
        set
        {
            if ((fontSizeSet != value))
            {
                fontSizeSet = value;
                OnPropertyChanged("FontSizeSet");
                OnPropertyChanged("CurrentCertGenLetterTempl");
            }
        }
    }

В этом примере кода Combobpxes динамически управляют только TextBox, но не RichTextBox.

...