this is the XAML code for an editable combox box for entering/selecting IP.
<ComboBox Name="ComboBoxServerIp"
Grid.Row="2" Grid.Column="1"
ItemsSource="{Binding ServerList}"
Text="{Binding SelectedServer, UpdateSourceTrigger=LostFocus, Mode=TwoWay}"
IsEditable="True" IsReadOnly="False">
<ComboBox.InputBindings>
<KeyBinding Command="{Binding UpdateServerIpCommand}" Key="Enter"
CommandParameter="{Binding ElementName=ComboBoxServerIp ,Path=Text}"/>
</ComboBox.InputBindings>
</ComboBox>
once the user is done entering the IP it triggers a flow that takes about 10 seconds. so i used a combination of lostfocus and enter key pressed to trigger an update.
this works fine with the exception of the use case when a user presses a button without first losing focus or pressing enter. in that case the SelecterServer updat is not triggerd BEFORE THE BUTTON's COMMAND IS EXECUTED. the command reads old the SelectedServer value. not the one in the UI
tl;dr - lostfocus event not triggerd in textbox when pressing a button in the UI. how can i force an update from the UI side ?
found a post of the exact opposite problem, WPF Lost-Focus issue in same control.
surprisingly the opposite of that fix worked perfectly for me add this property to the button:
Focusable="False"
the lostFocus event is triggered before the button clicked event. everything works as expected.