Hi,
I am using xamSpellChecker in the following scenario:
"I have a popup with a multi-line text box. Once the user is done with his/her input in the textbox and clicks on OK button of the popup, the spell checker should come into action."
If there are any spelling errors detected, then the spell check dialog box is displayed and everything works fine as expected.
The problem comes when there are no spelling errors in the user's input. If there are no spelling errors, the spellcheckcompleted method is called with the (spell checker) dialog state as "InActive" FOR THE FIRST TIME. The user has to click on the "OK" button of the popup again and this time the spellcheckcompleted method is called with the dialog state as "Active" and it works as expected. Could you please indicate why is this happening?
PS: In the spellcheckcompleted method, I am putting the spell checker dialog window state as hidden because I dont want the user to see the spell check dialog with "OK" button incase there are no spelling errors. But right now the user will have to click "OK" of the popup twice to close it in case of no spelling errors.
Any suggestions/help please?
I tested your scenario and wasn't able to reproduce the issue as you describe it. I used the following code:
<sdk:ChildWindow> <Grid x:Name="LayoutRoot"> <Grid.RowDefinitions> <RowDefinition Height="300"/> <RowDefinition/> </Grid.RowDefinitions> <TextBox x:Name="SpellCheckTextBox"/> <Button Grid.Row="2" Content="Check Spelling"> <ig:Commanding.Command> <ig:XamSpellCheckerCommandSource CommandType="SpellCheck" EventName="Click" TargetName="TestSpellChecker" /> </ig:Commanding.Command> </Button> <ig:XamSpellChecker x:Name="TestSpellChecker" SpellCheckCompleted="igSpellChecker_SpellCheckCompleted" UserDictionaryUri="http://localhost:2000/English.txt"> <ig:XamSpellChecker.SpellCheckTargets> <Binding ElementName="SpellCheckTextBox" Path="Text" Mode="TwoWay" /> </ig:XamSpellChecker.SpellCheckTargets> </ig:XamSpellChecker> </Grid> </sdk:ChildWindow>
The 'SpellCheckCompleted' event is fired only once.
I also tested with the following logicin the event handler:
private void igSpellChecker_SpellCheckCompleted(object sender, Infragistics.Controls.Interactions.SpellCheckCompletedEventArgs e) { var dlg = this.TestSpellChecker.SpellCheckDialog; if (e.Error == null) { dlg.Close(); } }
and it worked as expected.
Could you please clarify what your issue is and provide some code snippets so that I know what to look for?
Also, which Volume Release are you using and have you applied any Service Release?
Thanks,
Hi Stoimen,
Thank you for the reply :)
I had applied the latest (of that time) service release in April. The version of libraries I use is "Silverlight.Nightly_10.3.20103.2159". In your sample code, you tried reproducing the issue in a child window. Whereas, I am making a call to the spell checker from a popup. There is no issue seen when we launch it in a child window. Whereas in my case, where I am launching the spell checker dialog from a popup.
Thanks
Sujeevan.
I am working on the same project. The issue is that the spell checker dialog appears behind the popup. Any suggestions how can I make this spell checker dialog to appear on front of the popup.
Also, I noticed that for the first time after the screen loads, the spell checker dialog appears correctly on the popup when we click on OK button of the popup. But after we close the spell checker dialog box and again clicks on OK button, it gets displayed behind the popup. Can anyone help with some suggestions?
Yeah! This fixed my problem. thank you very much Stoimen :) However, now the spell checker dialog always appears BEHIND the popup :(!
Seems like there is some race condition issue, please try replacing some of the logic in your event handler with the following:
private void igSpellChecker_SpellCheckCompleted(object sender, SpellCheckCompletedEventArgs e) { var spellChecker = (XamSpellChecker)sender; spellChecker.SpellCheckDialog.Close(); this.Dispatcher.BeginInvoke(() => this.TestPopup.IsOpen = false); }
HTH,
Here is how I am trying to use XamSpellChecker control:
I am using it as a part of a user control which is displayed as a popup. The control is bound to "displayValue". The popup also has another text box which is bound to "displayValue".
Partial Sample of xaml:
<StackPanel> <ItemsControl ItemsSource="{Binding Data}" Visibility="{Binding ReaderControl}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid Height="Auto" Width="Auto" Margin="{StaticResource Thk_4_All}" VerticalAlignment="Top" HorizontalAlignment="Left"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding keyValue}" HorizontalAlignment="Right" TextAlignment="Right" Width="100" VerticalAlignment="Top" FontFamily="{StaticResource BaseFont_Family}" FontSize="{StaticResource BaseFont_Size}" FontWeight="Bold" Margin="0,0,3,0" > <TextBlock.Foreground> <SolidColorBrush Color="{StaticResource Gray_Titles}"/> </TextBlock.Foreground> </TextBlock> <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding displayValue}" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300" FontFamily="{StaticResource BaseFont_Family}" FontSize="{StaticResource BaseFont_Size}" > <TextBlock.Foreground> <SolidColorBrush Color="{StaticResource Black}"/> </TextBlock.Foreground> </TextBlock> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> <ItemsControl ItemsSource="{Binding Data}" Visibility="{Binding InputControl}"> <ItemsControl.ItemTemplate> <DataTemplate> <Grid Height="Auto" Width="Auto" Margin="{StaticResource Thk_4_All}" VerticalAlignment="Top" HorizontalAlignment="Left"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <ig:XamSpellChecker x:Name="igSpellChecker" Grid.Column="0" MaxWidth="10" MaxHeight="20" DictionaryUri="Dictionaries\us-english-v2-whole.dict"> <ig:XamSpellChecker.SpellCheckTargets> <Binding Path="displayValue" Mode="TwoWay"/> </ig:XamSpellChecker.SpellCheckTargets> </ig:XamSpellChecker> <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding keyValue}" HorizontalAlignment="Right" TextAlignment="Right" TextWrapping="Wrap" Width="100" VerticalAlignment="Top" FontFamily="{StaticResource BaseFont_Family}" FontSize="{StaticResource BaseFont_Size}" FontWeight="Bold" Margin="0,0,3,0"> <TextBlock.Foreground> <SolidColorBrush Color="{StaticResource Gray_Titles}"/> </TextBlock.Foreground> </TextBlock> <TextBox x:Name="NarrativeTextBox" Grid.Row="0" Grid.Column="2" Text="{Binding displayValue,Mode=TwoWay}" TextWrapping="Wrap" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300" AcceptsReturn="True" FontFamily="{StaticResource BaseFont_Family}" FontSize="{StaticResource BaseFont_Size}"> <TextBox.Foreground> <SolidColorBrush Color="{StaticResource Black}"/> </TextBox.Foreground> </TextBox> </Grid> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </StackPanel>
And in the code behind:
void spellChecker_SpellCheckCompleted(object sender, SpellCheckCompletedEventArgs e) { XamSpellChecker sc = (XamSpellChecker)sender; XamDialogWindow xd = sc.SpellCheckDialog; xd.WindowState = Infragistics.Controls.Interactions.WindowState.Hidden; // After Some processing //
if (xd.IsActive) { TreeHelper objTreeHelper = new TreeHelper(); Popup objPopup = objTreeHelper.FindAncestor((DependencyObject)this.View, d => d is Popup) as Popup; if (objPopup != null) { objPopup.IsOpen = false; } } else { xd.Close(); } }
With this code sample, when the user clicks on the Ok button of the popup, if there are any spell errors in the textbox contents, then a suggestion box is displayed and everything works fine. But if the textbox content doesnt have spell errors, then the popup doesnt close :(.
However, when we click on the OK button for the SECOND TIME, then the popup gets closed.
Please let me know if this kind of usage is correct or not.
Thanks and regards,
OK, I understand what I did is close to your implementation.
Could you provide the specific code which you use for launching the spell checker?