Latest News

  • Silverlight Online Chat
    Jul 24, 2010

    Today we launch the new Silverlight Live Chat application demonstrating the Liquid RichTextBox and Emoticon replacements.

  • New Super Shoot Em Up 2 Game
    Jun 29, 2010

    Added to the Games section is the new Super Shoot 'Em Up 2 game. Take control of your tank with the aim to defeat the computer controlled opponents. Features all new weapons, levels and Battle Mode!

  • Silverlight 4 Controls V5.3.2 Released
    Jun 28, 2010

    This release contains several fixes raised in the forums.

  • New Sandmania Puzzle Game
    Jun 18, 2010

    Sandmania is the latest game from vectorlight, the aim of this game is to guide sand from the top of the screen to the various colored containers below.

  • New Moon Tower Defense Game
    May 29, 2010

    Added to the Games section is the new Moon Tower Defense game. Defend the Moon from the circling Aliens and Humans.

november9
november9
RichTextBox.SelectionStyle.Family Posted: Mar 11, 2010
 

Hi,


I'm using version 5.2.7.


On the RichTextBox, the property RichTextBox.SelectionStyle.Family seems to always return "Portable User Interface" and not the font family name.  Do you know if I am doing something wrong?


Many thanks,

Adrian

 
 
dan
dan
RE: RichTextBox.SelectionStyle.Family Posted: Mar 11, 2010
 

Hi Adrian,


The RichTextBox.SelectionStyle reflects the current selection style at the cursor.  I have tested this and the font family is updated correctly, both here and in the online demo.  Can you provide the code you are using when you reference this property?  Are you using the SelectionChanged event?


Thanks!

 
 
november9
november9
RE: RichTextBox.SelectionStyle.Family Posted: Mar 12, 2010
 

Hi Dan,


Thanks for the help...


The control in my Xaml is defined as:


<liquid:RichTextBox x:Name="BodyRichTextBox" SelectionChanged="BodyRichTextBox_SelectionChanged"

                                    AutoWrap="True" EnableContextMenu="True"

                                    HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible"

                                    LinkClicked="BodyRichTextBox_LinkClicked"

                                    GotFocus="BodyRichTextBox_GotFocus"

                                    Grid.Row="11" Grid.Column="1" Grid.ColumnSpan="2" />



And my SelectionChanged event handler and the involved methods (fairly similar to your main example) read:


        private void BodyRichTextBox_SelectionChanged(object sender, RichTextBoxEventArgs e)

        {

            BoldButton.IsSelected = false;

            if (BodyRichTextBox.SelectionStyle.Weight == FontWeights.Bold)

            {

                BoldButton.IsSelected = true;

            }


            ItalicButton.IsSelected = false;

            if (BodyRichTextBox.SelectionStyle.Style == FontStyles.Italic)

            {

                ItalicButton.IsSelected = true;

            }


            UnderlineButton.IsSelected = false;

            if (BodyRichTextBox.SelectionStyle.Decorations == TextDecorations.Underline)

            {

                UnderlineButton.IsSelected = true;

            }


            this.supressFontEvents = true;


            this.SetStyleButtons();

            this.SetFontComboBoxes();


            this.supressFontEvents = false;

        }


        private void SetFontComboBoxes()

        {

            this.SetComboBox(FontFamilyComboBox, BodyRichTextBox.SelectionStyle.Family);

            this.SetComboBox(FontSizeComboBox, BodyRichTextBox.SelectionStyle.Size.ToString());


            this.SomeText.Text = BodyRichTextBox.SelectionStyle.Family.ToString();

        }


        private void SetComboBox(ComboBox comboBox, string value)

        {

            if (value != null)

            {

                foreach (ComboBoxItem item in comboBox.Items)

                {

                    if (item.Content.ToString().ToUpper(CultureInfo.InvariantCulture) ==

                        value.ToUpper(CultureInfo.InvariantCulture))

                    {

                        comboBox.SelectedItem = item;

                        break;

                    }

                }

            }

        }


        private void SetStyleButtons()

        {

            this.SetButton(BoldButton);

            this.SetButton(ItalicButton);

            this.SetButton(UnderlineButton);

        }


        private void SetButton(IconButton button)

        {

            if (button.IsSelected)

            {

                button.Background = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));

            }

            else

            {

                button.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));

            }

        }


Many thanks,

Adrian

 
 
november9
november9
RE: RichTextBox.SelectionStyle.Family Posted: Mar 12, 2010
 

Actually, I think I've spotted it now.  It seems to be that 'Portable User Interface' is anything selected that hasn't been created as a particular font.  If I can somehow put the RichTextBox into a default font, it might fix this.

 
 
november9
november9
RE: RichTextBox.SelectionStyle.Family Posted: Mar 15, 2010
 

I just added the properties FontFamily="Arial" FontSize="11" as default properties to my RichTextBox.  After the Load, there is then no text without a valid SelectionStyle.Family property.


Cheers,

Adrian