Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: BusyIndicator Text value not updating

$
0
0
Hi,

In v2.0, it is working fine. Here's my complete code :
<StackPanel>
         <xctk:BusyIndicator x:Name="_busyIndicator" 
                             BusyContent="{Binding}"
                             IsBusy="True">
            <xctk:BusyIndicator.BusyContentTemplate>
               <DataTemplate>
                  <StackPanel>
                     <TextBlock Text="{Binding BusyText}"
                                HorizontalAlignment="Center" />
                     <ProgressBar Value="{Binding Value}"
                                  Maximum="{Binding Maximum}"
                                  Height="15" />
                  </StackPanel>
               </DataTemplate>
            </xctk:BusyIndicator.BusyContentTemplate>

            <!-- Remove unnecessary default ProgressBar -->
            <xctk:BusyIndicator.ProgressBarStyle>
               <Style TargetType="ProgressBar">
                  <Setter Property="Visibility"
                          Value="Collapsed" />
               </Style>
            </xctk:BusyIndicator.ProgressBarStyle>

            <Grid Name="grdPage">
               <TextBlock Text="Please wait..." />
            </Grid>
         </xctk:BusyIndicator>

         <Button Content="Add Value"
                 Click="Button_Click_1" />
         <Button Content="Add Maximum"
                 Click="Button_Click_2" />
         <Button Content="Change BusyText"
                 Click="Button_Click_3" />
      </StackPanel>
and the code-behind :
public partial class MainWindow : Window, INotifyPropertyChanged
  {
    public MainWindow()
    {
      InitializeComponent();

      _busyIndicator.DataContext = this;
      this.Value = 15;
      this.Maximum = 20;
      this.BusyText = "You need to wait...";
    }

    public double Value
    {
      get
      {
        return _value;
      }
      set
      {
        _value = value;
        this.OnPropertyChanged( "Value" );
      }
    }

    private double _value;

    public double Maximum
    {
      get
      {
        return _maximum;
      }
      set
      {
        _maximum = value;
        this.OnPropertyChanged( "Maximum" );
      }
    }

    private double _maximum;

    public string BusyText
    {
      get
      {
        return _busyText;
      }
      set
      {
        _busyText = value;
        this.OnPropertyChanged( "BusyText" );
      }
    }

    private string _busyText;

    public event PropertyChangedEventHandler PropertyChanged;
    protected void OnPropertyChanged( string propertyName )
    {
      if( PropertyChanged != null )
      {
        PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );
      }
    }

    private void Button_Click_1( object sender, RoutedEventArgs e )
    {
      this.Value = 5;
    }

    private void Button_Click_2( object sender, RoutedEventArgs e )
    {
      this.Maximum = 30;
    }

    private void Button_Click_3( object sender, RoutedEventArgs e )
    {
      this.BusyText = "Wait again...";
    }
  }

Viewing all articles
Browse latest Browse all 2157

Latest Images

Trending Articles



Latest Images