WPF C# Binding绑定不上的解决情况
Binding绑定不上的一般解决情况:
1.添加上下文
DataContext
d:DataContext="{d:DesignInstance Type=local:CommSettingView}"
2.添加相对位置
RelativeSource
Command="{Binding SaveCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
3.通知模式
Mode
<TextBox Text="{Binding PortNumber,Mode=TwoWay,RelativeSource={RelativeSource AncestorType=UserControl}}"/>