This is a migrated thread and some comments may be shown as answers.
Progressvalue value is 0 but still show full status
2 Answers 15 Views
This is a migrated thread and some comments may be shown as answers.
cde
Top achievements
Rank 1
cde asked on 08 Apr 2013, 06:45 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Petar Mladenov
Telerik team
answered on 08 Apr 2013, 07:23 AM
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.

0
cde
Top achievements
Rank 1
answered on 08 Apr 2013, 11:30 AM
 hi, Petar , it fixed my issue, thanks.
Asked by
cde
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
cde
Top achievements
Rank 1
Share this question
or