hello,
the richtextbox's SelectionChanged is getting fired twice .
basically the issue is , i am getting the font of the current selection inside this event , here is the code .
private void rta_SelectionChanged(object sender, RoutedEventArgs e)
{
if (rta.Selection.GetPropertyValue(TextElement.FontSizeProperty) is double) { fontSize = (double)rta.Selection.GetPropertyValue(TextElement.FontSizeProperty); } }
i have setted the default fontsize to 12 , now , first time , fontsize value is 12 ( which is as expected ) , but second time , value is 11 .
here is the value of the XAML property of 1st and 2nd time .
1st
<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="12" FontFamily="Arial" Text="l" /></Paragraph></Section>
2nd
<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left"><Run FontSize="12" FontFamily="Arial" Text="l" /></Paragraph></Section>
now , why is it firing twice , because its a rounted event ?
thanks
Jamal.
P.S
if you see the XAML closely , the fontsize of 11 is set for the paragraph .