我正在尝试按如下方式应用触发器:
using SmartRoutePlanner.Models;
...
Map locationMap = new Map();
locationTextBox.DataContext = locationMap;
Binding locationBinding = new Binding("Location");
locationTextBox.SetBinding(TextBox.TextProperty, locationBinding);
locationBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
我的 XAML 代码是这样的:
...
xmlns:models="clr-namespace:SmartRoutePlanner.Models"
...
<Grid.Resources>
<models:Map x:Key="mapDataSource"/>
</Grid.Resources>
<Grid.DataContext>
<Binding Source="{StaticResource mapDataSource}" />
</Grid.DataContext>
<TextBox x:Name="locationTextBox" />
是什么导致异常?