Reputation: 13
We have an issue with WPF ViewModel and IsEnabled databinding.
It's about a WPF Skype application which should activate buttons when a call is connected. However, this only works if the MainWindow is focused afterwards.
MainWindows loaded:
The buttons are only activated when we bring the main window to the foreground or activate it.
MainWindow.xaml.cs
namespace Skype_CTI.Views
{
/// <summary>
/// </summary>
public partial class MainWindow : MetroWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}
MainWindow.xaml
<Button x:Name="adhoc_profil" Content="Open Ad-hoc profile" ToolTip="" HorizontalAlignment="Left" Margin="338,199,0,0" VerticalAlignment="Top" Width="170" Command="{Binding OpenBrowserWithAdhocProfil_Command}" Grid.Column="1" Height="20" IsEnabled="{Binding IsAdhocProfilEnable}"/>
MainWIndowViewModel.cs
private bool _isAdhocProfilEnable;
public bool IsAdhocProfilEnable
{
get { return _isAdhocProfilEnable; }
set { SetProperty(ref _isAdhocProfilEnable, value); }
}
...
public MainWindowViewModel()
{
_logger.Info("MainWindowViewModel CTOR reached!");
_incomingCall = 0;
_outgoingCall = 0;
_isAdhocProfilEnable = false;
...
if (e.NewState == ModalityState.Connected && _incomingCall == 1)
{
...
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
try
{
....
IsAdhocProfilEnable = true;
....
Can anyone help?
Thanks a lot
Upvotes: 0
Views: 103