Well setting that only leaves the textedit cursor blinking in the text box even after lost focus. I have already tried via default selection property settings e.g selectionlength or selectionstart, all results in setting the cursor blinking in the text box even if the next control get focus. Just tab through the text box and see the behviour of the cursor on txtFirst and txtSecond < textbox x:name="txtTest" lostfocus="txtFirst_LostFocus" xmlns:x="#unknown" / > < textbox x:name="txtFirst" lostfocus="txtFirst_LostFocus" xmlns:x="#unknown" / > < textbox x:name="txtSecond" lostfocus="txtSecond_LostFocus" xmlns:x="#unknown" / > < textbox x:name="txtFourth" xmlns:x="#unknown" / > Private Sub txtFirst_LostFocus(ByVal sender As Object, ByVal e As RoutedEventArgs) e.Handled = True End Sub Private Sub txtSecond_LostFocus(ByVal sender As Object, ByVal e As RoutedEventArgs) e.Handled = True End Sub
pc rajesh singh
Posts
-
Unselect text in textbox on textbox lostfocus event. -
Problem with WPF ComboboxI took your scenario and binded by creating the dependency property, for me everything works. Once the mouse is over the combo box and combobox has the focus , scrolling works fine with the mouse. you can only post a sample so that actual issue can be observed <ComboBox x:Name="cboDistrict" IsSynchronizedWithCurrentItem="True" Grid.Column="1" Grid.Row="0" Style="{DynamicResource BaseComboBox}" ItemsSource="{Binding Path=AllDistricts, Mode=Default}" SelectedItem="{Binding Path=BodyTextDistrict, Mode=TwoWay}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding }"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Private Property AllDistricts() As ObservableCollection(Of String) Get Return DirectCast(GetValue(AllDistrictsProperty), ObservableCollection(Of String)) End Get Set(ByVal value As ObservableCollection(Of String)) SetValue(AllDistrictsProperty, value) End Set End Property Public Shared AllDistrictsProperty As DependencyProperty = _ DependencyProperty.Register("AllDistricts", GetType(ObservableCollection(Of String)), _ GetType(NameView), New UIPropertyMetadata(New ObservableCollection(Of String))) Public Property BodyTextDistrict() As String Get Return Convert.ToString(GetValue(BodyTextDistrictProperty)) End Get Set(ByVal value As String) SetValue(BodyTextDistrictProperty, value) End Set End Property Public Shared BodyTextDistrictProperty As DependencyProperty = _ DependencyProperty.Register("BodyTextDistrict", GetType(String), _ GetType(NameView), New UIPropertyMetadata(String.Empty))
-
Treeview in expanderLast selected Item of treeview control will display the gray color, on expand of expander for the reason it represent disabled selection. Select an item in treeviewcontrol, and then click outside the preview of treeviewcontrol to trigger lost focus of treeviewcontrol, the selected item will be gray. <Style x:Key="TreeViewItemItemTemplateStyle" TargetType="{x:Type TreeViewItem}"> <Style.Resources> <!-- Background of selected item when focussed --> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Blue" /> <!-- Background of selected item when not focussed --> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="LightGray" /> </Style.Resources> </Style> you can override the gray color by applying the color you want for not focussed style.
-
Unselect text in textbox on textbox lostfocus event.I am working in WPF. Normally on lost focus of textbox , text are unselected. But if I set the value e.handled = true on lostfocus event handler, unselection doesn't happen. I need to set e.handled = true to prevent the event from bubbling up. Note: I am not stopping from lostfocus being triggered. LostFocus takes place, its just that, automatic unselection doesn't happen and I want the unselection to take place. Private Sub MyTextBox_LostFocus(ByVal sender As Object, ByVal e As RoutedEventArgs) e.Handled = True End Sub