Fixed. Had to Bind both the Maximum and Value and it worked. In the test I bound both to Int32 (did not test binding both to double). Microsoft I think this is a bug.
<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" />
What is protocol. If I answer my own question should I delete the question?
I get an error when I try to bind Value for a Progress Bar. XamlParseException 'Set property 'System.Windows.Controls.Primitives.RangeBase.Value' threw an exception.' Grid.Row 8 fails and Grid.Row 9 Fails. When I put in fixed values (Grid.Row 6 and Grid.Row 7) it works. I can retrieve the value I want to bind to in a TextBlock (Grid.Row 5). I have tried binding to Double and Int 32. According to the documentation Minimum, Maximum, and Value are double. The calculated value it is failing on is 2 (and it fails on other values). Thanks in advance and I will mark the answer.
<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;
}
}
Is it expecting a Double from 0.0 to 1.0?
It shouldn't, but does that fix it?
Also, I usually specify Double constants in code like this: 0.0D, 1.0D, 100.0D
Fixed. Had to Bind both the Maximum and Value and it worked. In the test I bound both to Int32 (did not test binding both to double). Microsoft I think this is a bug. If the Maximum is XAML but the Value in Bind it fails (or it failed for me).