我试图弄清楚如何使用 UpdateSourceTrigger=Explicit。
我有以下表格:
<StackPanel x:Name="LayoutRoot" Margin="10" DataContext="{Binding ElementName=Window, Mode=OneWay}">
<DockPanel>
<TextBlock Text="Proxy address:" VerticalAlignment="Center"/>
<TextBox Text="{Binding User.PageAddress, Mode=TwoWay, UpdateSourceTrigger=Explicit}" Margin="28,0,0,0"/>
</DockPanel>
<DockPanel Margin="0,5,0,0">
<TextBlock Text="User name:" VerticalAlignment="Center"/>
<TextBox Text="{Binding User.UserName, Mode=TwoWay, UpdateSourceTrigger=Explicit}" Margin="46,0,0,0"/>
</DockPanel>
<DockPanel Margin="0,5,0,0">
<TextBlock Text="User password:" VerticalAlignment="Center"/>
<TextBox Text="{Binding User.Password, Mode=TwoWay, UpdateSourceTrigger=Explicit}" Margin="26,0,0,0"/>
</DockPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,5,0,0">
<Button Content="Ok" IsDefault="True" Width="70" Margin="0,0,15,0" Click="Ok_Click"/>
<Button Content="Cancel" IsCancel="True" Width="70"/>
</StackPanel>
</StackPanel>
我应该调用什么方法来更新User
属性?
我不想通过 x:Name 来处理元素来调用绑定。如果我必须通过 x:Name 来处理元素,就我而言,我也可以完全不绑定。