I have a grid with SAVE button. Then I have a dockmanager which has 2 tabgrouppanes. The first tabgrouppane has a content pane which has a title textbox and few other fields.
Binding for title seems to happen only when we TAB out of the text box. Hitting SAVE without leaving the textbox does not do the binding. How do I get the textbox to receive a "lost focus" when I click on the SAVE button. Attaching sample code.
Thanks.
<Grid> <Grid x:Name="Grid_MenuBar"> <Button x:Name="Save" Grid.Column="1" Grid.Row="0" Margin="5" </Grid>
<igDock:XamDockManager Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <igDock:XamDockManager.Panes> <igDock:SplitPane igDock:XamDockManager.InitialLocation="DockedTop" SplitterOrientation="Horizontal"> <igDock:TabGroupPane> <igDock:ContentPane Header="Primary"> <Grid x:Name="Song"> <TextBlock x:Name="SongTitle_txt" Text="Title" Grid.Row="1" Grid.Column="2" Margin="0,0,5,0" /> <TextBox x:Name="SongTitle_box" BorderThickness="0.5,0.5,0.5,0.5" Grid.Row="1" Grid.Column="3" Text="{Binding Path=Title, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/> </igDock:ContentPane> </igDock:TabGroupPane> </igDock:SplitPane> </igDock:XamDockManager.Panes></Grid>
In WPF, LostFocus is not the act of losing keyboard focus but the act of losing logical focus. In the case of the XamDockManager, the ContentPane is a FocusScope and as such each pane has its own logically focused element. So you would need to change the FocusManager.FocusedElement of the ContentPane to another element within the pane. Note, this is the same type issue that you would have if you had a TextBox on the Window and clicked on a Save button within a Toolbar or a Save button within a Menu or XamRibbon as all of those are focus scopes so that interacting within focus within those elements does not interfere with or manipulate the item that is focused in the other area. Alternatively you could change the Binding such that the UpdateSourceTrigger is PropertyChanged so that the value in the underlying source is updated as you type.
Thanks. That worked.