我需要通过以下方式将 TextBlock.Text 与 TimeSpan 类型的 SumOfPeriods 属性绑定:
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:D1} h {1:D1} min ({2:D1} min)">
<Binding Path="SumOfPeriods.Hours" />
<Binding Path="SumOfPeriods.Minutes" />
<Binding Path="SumOfPeriods.TotalMinutes" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
...但它不起作用。内容不显示。当我删除对 TotalMinutes 的绑定时,它可以工作并显示内容:
<TextBlock>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:D1} h {1:D1} min">
<Binding Path="SumOfPeriods.Hours" />
<Binding Path="SumOfPeriods.Minutes" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
任何人都可以帮助我吗?