我想从 MainWindow.xaml.cs 文件中更改运行时的源属性。我当前的代码显示在此处。
<controls:StartVideoCallButton Name="accountString" Source="sip:stj@starck.onmicrosoft.com" Height="75" Width="314" Background="#FFC7C7C7"></controls:StartVideoCallButton>
这对我有用:
accountString.Source = "sip:new.sip@company.com";
或者您可以使用MVVM模式绑定源属性以将您的 UI 与业务逻辑分开 - 这是 WPF 应用程序的首选方法