WPF Toolkit RichTextBox FontSize Binding

212 Views Asked by At

I have a RichTextBox from the WPFToolkit in a form with other controls including a textbox and I'm binding FontFamily and FontSize to both controls. My combobox selects each FontFamily and FontSize and the Textbox dynamically changes both but the RichTextBox does not.

I've tried both binding to type of Double & String and get the same result.

                <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");
            }
        }
    }

In this code example only the TextBox is dynamically controlled by the Combobpxes but not the RichTextBox.

0

There are 0 best solutions below