This project has moved. For the latest updates, please go here.

Problem with binding on BusyIndicator

Feb 11, 2011 at 2:13 PM

Hi I have problem make simple binding on BusyIndicator controls.

In xaml I have this declaration:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:extToolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit.Extended" 
        Title="MainWindow" Height="350" Width="525">
    
    <StackPanel>
        <extToolkit:BusyIndicator IsBusy="{Binding Path=ShowBusy,Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" >
            <TextBlock>Something</TextBlock>
        </extToolkit:BusyIndicator>

        <StackPanel>
            <Button Width="150" Click="Button_Click_1">I am busy</Button>
        </StackPanel>
    </StackPanel>
</Window>

Code behind:

    public partial class MainWindow : Window, INotifyPropertyChanged
    {

        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        private bool _showBusy;

        public bool ShowBusy
        {
            get { return _showBusy; }
            set
            {
                _showBusy = value;
                NotifyPropertyChanged("ShowBusy");
            }
        }

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            ShowBusy = true;
        }
    }

Scenario is simple I make binding property IsBusy and ShowBusy, after fire click event I set ShowBusy property on true, but BusyIndicator is not showed.  What I do bad?

I test this behavior in simple project, I post all code of app.

Feb 11, 2011 at 2:19 PM

It looks like you forgot to set the DataContext of your Window.  Look in your output window for binding errors.  Try this:

        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
        }

By the way, you can just set the IsBusy="{Binding ShowBusy}".  The rest is not neccessary.
Feb 11, 2011 at 2:42 PM

Yes, you have right...the original problem is in caliburn micro app, I forget set datacontext because in caliburn micro you don’t use datacontext, it use conventions. I test in busy indicator control out of my project, because it is not showed in caliburn app.

And I forget set datacontext, it work, but shame it don’t work with caliburn togther.

Feb 11, 2011 at 2:45 PM

It shouldn't matter what framework you are using.  As long as your bindings are properly setup, it should work.  Like I said, check your output window for binding errors.  That should help you track down the issue.

Feb 11, 2011 at 5:49 PM

Thank Mr. Lagunas for advice, it is problem of caliburn micro framework that is all.  I must create own busy spiner :)