Progressvalue value is 0 but still show full status

3 posts, 1 answers
  1. cde
    cde avatar
    2 posts
    Member since:
    Sep 2007

    Posted 08 Apr 2013 Link to this post

    dear all,
     I  run into problem with progressbar .  some time gave progressbar value 0, but it show full progress status. following is code :

    var wolist = Newtonsoft.Json.JsonConvert.DeserializeObject<List<workorder>>(e2.Result);
                      
                     
                      List<SaWOProcess> list = new List<SaWOProcess>();
                      lbSaProcess.ItemsSource = null;
                      foreach (var item in wolist)
                      {
                          double v = 0.0;
                          double qty = item.Qty ?? 0.0;
     
                          if (item.CompletedQty != null)
                          {
                              v = (double)item.CompletedQty / (double)item.Qty * 100.0;
                          }
                            
     
                          list.Add(new SaWOProcess() { Qty = qty, WOId = item.Id, WOName = item.WOName, CurrentValue = Convert.ToInt32(v)  , TotalInfo = string.Format("{0}/{1}", item.CompletedQty, qty) });
                            
                          
                      }
              
                      lbSaProcess.ItemsSource = list;
     
                      lbSaProcess.UpdateLayout();



    My xaml:

    <UserControl.Resources>
     
        <DataTemplate x:Key="dataTemplate">
     
             
                <Canvas  VerticalAlignment="Center"  Margin="10" Height="50"  >
     
                    <TextBlock  Foreground="#FF393838" x:Name="loadingPercentage" VerticalAlignment="Center"  Canvas.Top="16" Text="{Binding WOName}"
                        FontSize="15" />
                    
                    <telerik:RadProgressBar x:Name="pb" Canvas.Top="16" VerticalAlignment="Center" Canvas.Left="100" Width="500" Height="22" Minimum="0" Value="{Binding CurrentValue}"
                    Maximum="100"   />
                     
                    <TextBlock  Canvas.Left="630"  Canvas.Top="16" VerticalAlignment="Center" Foreground="#FF393838" x:Name="tbTotal" Text="{Binding TotalInfo}"
                        FontSize="15" />
                    <Button x:Name="btnViewDetail"  Canvas.Top="16" VerticalAlignment="Center" Tag="{Binding WOId}" Canvas.Left="685"   HorizontalAlignment="Right" Foreground="Black" Content="ViewDetail" Click="btnViewDetail_Click_1" />
     
                </Canvas>
     
            </DataTemplate>
     
     
     
        </UserControl.Resources>
     
     
     
     
            <ListBox Name="lbSaProcess" Grid.Row="1"  ItemTemplate="{StaticResource dataTemplate}" BorderThickness="0" Width="790" Height="750" >
     
      
            </ListBox>

    public class SaWOProcess
       {
           public int WOId { get; set; }
           public string WOName { get; set; }
           public int  CurrentValue { get; set; }
           public string TotalInfo { get; set; }
     
           public double Qty { get; set; }
       }

    the display result please see attachement.  give the same value some(value= 0 ) progrssbar is ok,others is full progrss status. why?

    please help me ,thanks !
  2. Answer
    Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 08 Apr 2013 Link to this post

    Hi cde,

     Please make sure the CurrentValue is bound two-way:

    Value="{Binding CurrentValue, Mode=TwoWay}"
    and your ViewModel implements INotifyPropertyChanged:
    public int  CurrentValue
     {
             get
             {
                 return this.currVal;
             }
             set
             {
                 if (this.currVal != value)
                 {
                     this.currval = value;
                     this.OnPropertyChanged("CurrentValue");
                 }
             }
    }
    Let us know if this helps you proceed further.

    Greetings,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. cde
    cde avatar
    2 posts
    Member since:
    Sep 2007

    Posted 08 Apr 2013 Link to this post

     hi, Petar , it fixed my issue, thanks.
Back to Top