固定。必须绑定最大值和值,它才有效。在测试中我将两者绑定到Int32(没有测试绑定到double)。微软我认为这是一个错误。
<ProgressBar Grid.Row="8" Grid.Column="0" HorizontalContentAlignment="Stretch" Height="20" Maximum="{Binding Path=DF.WFBatchFolderStatus.DocCount}" Value="{Binding Path=DF.WFBatchFolderStatus.DocCountComplete}" PresentationTraceSources.TraceLevel="High" />
什么是协议。如果我回答我自己的问题,我应该删除这个问题吗?
当我尝试为进度条绑定Value时出现错误。 XamlParseException'设置属性'System.Windows.Controls.Primitives.RangeBase.Value'引发了一个异常。 Grid.Row 8失败,Grid.Row 9失败。当我输入固定值(Grid.Row 6和Grid.Row 7)时,它可以工作。我可以在TextBlock(Grid.Row 5)中检索我想要绑定的值。我已经尝试绑定到Double和Int 32.根据文档,Minimum,Maximum和Value是double。它失败的计算值是2(并且在其他值上失败)。在此先感谢,我将标记答案。
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" Text="{Binding Path=DF.WFBatchFolderStatus.DocPctComplete, StringFormat='Document Pct Count: {0}'}" PresentationTraceSources.TraceLevel="High" />
<ProgressBar Grid.Row="6" Grid.Column="0" HorizontalContentAlignment="Stretch" Height="20" Minimum="0" Maximum="100" Value="40" />
<ProgressBar Grid.Row="7" Grid.Column="0" HorizontalContentAlignment="Stretch" Height="20" Minimum="0E0" Maximum="100E0" Value="60E0" />
<ProgressBar Grid.Row="8" Grid.Column="0" HorizontalContentAlignment="Stretch" Height="20" Minimum="0" Maximum="100" Value="{Binding Path=DF.WFBatchFolderStatus.DocPctCompleteInt}" PresentationTraceSources.TraceLevel="High" />
<ProgressBar Grid.Row="9" Grid.Column="0" HorizontalContentAlignment="Stretch" Height="20" Minimum="0E0" Maximum="100E0" Value="{Binding Path=DF.WFBatchFolderStatus.DocPctComplete}" PresentationTraceSources.TraceLevel="High" />
public Double DocPctComplete
{
get
{
if (BatchFolderStatus == enumBatchFolderStatus.Waiting) return 0;
if (BatchFolderStatus == enumBatchFolderStatus.WaitQC) return 0;
if (BatchFolderStatus == enumBatchFolderStatus.Complete) return 100;
if (DocCount < 1) return 0;
if (DocCountComplete < 1) return 0;
double docPctComplete = (Convert.ToDouble(DocCountComplete) / Convert.ToDouble(DocCount)) * 100E0;
Debug.WriteLine("docPctComplete " + docPctComplete.ToString());
return docPctComplete;
}
}
public Int32 DocPctCompleteInt
{
get
{
if (BatchFolderStatus == enumBatchFolderStatus.Waiting) return 0;
if (BatchFolderStatus == enumBatchFolderStatus.WaitQC) return 0;
if (BatchFolderStatus == enumBatchFolderStatus.Complete) return 100;
if (DocCount < 1) return 0;
if (DocCountComplete < 1) return 0;
double docPctComplete = (Convert.ToDouble(DocCountComplete) / Convert.ToDouble(DocCount)) * 100E0;
Debug.WriteLine("docPctComplete " + docPctComplete.ToString());
Int32 docPctCompleteInt = Convert.ToInt32(docPctComplete);
Debug.WriteLine("docPctCompleteInt " + docPctCompleteInt.ToString());
return docPctCompleteInt;
}
}
答案 0 :(得分:3)
固定。必须绑定最大值和值,它才有效。在测试中我将两者绑定到Int32(没有测试绑定到double)。微软我认为这是一个错误。如果最大值是XAML但是绑定中的值失败(或者它失败了)。
答案 1 :(得分:0)
是否期望Double从0.0到1.0?
它不应该,但确实可以解决它吗?
另外,我通常在代码中指定Double常量:0.0D,1.0D,100.0D