Reputation: 1265
I have a ToolBar with a Button and a DataGrid and a separate Button.
When I edit a cell (EditMode) and then click the "separate" Button, the cell leaves EditMode and commit the changes.
But when I click the Button on the within the ToolBar, the cell doesn't leave EditMode and doesn't commit its changes.
How can I force the cell to commit its changes when I click the ToolBar Button?
XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="DataContextSample" Height="543.538" Width="733.463"
xmlns:self="clr-namespace:WpfApplication1">
<DockPanel Margin="15">
<ToolBar DockPanel.Dock="Top" Height="40">
<Button Width="150" Height="20">ToolBarBUtton</Button>
</ToolBar>
<Button DockPanel.Dock="Top" Height="20" Width="150">Button</Button>
<DataGrid DockPanel.Dock="Top" Name="DataGridJobConfigurations" ItemsSource="{Binding}" VerticalScrollBarVisibility="Auto">
</DataGrid>
</DockPanel>
</Window>
C#:
namespace WpfApplication1
{
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
List<Data> dataList = new List<Data>();
dataList.Add(new Data(1));
dataList.Add(new Data(2));
dataList.Add(new Data(3));
dataList.Add(new Data(4));
this.DataContext = dataList;
}
}
class Data {
public Data(int i) {
Number = i;
}
public int Number { get; set; }
}
}
Upvotes: 0
Views: 226
Reputation: 169320
You could set the attached FocusManager.IsFocusScope
property of the Toolbar
to false
:
<ToolBar DockPanel.Dock="Top" Height="40" FocusManager.IsFocusScope="False">
<Button Width="150" Height="20">ToolBarBUtton</Button>
</ToolBar>
Upvotes: 1