3
我遇到了试图绑定到RectangleGeometry的Rect属性的问题。这里的基本思想是,我试图绑定剪辑蒙板来控制虚拟图表对象的可视化高度。这里是XAML:绑定RectangleGeometry.Rect不显示矩形
<Path x:Name="_value" Fill="{DynamicResource PositiveColorBrush}" Data="F1 M10,55 C10,57.75 7.75,60 5,60 2.25,60 0,57.75 0,55 L0,5 C0,2.25 2.25,0 5,0 7.75,0 10,2.25 10,5 L10,55 z">
<Path.Clip>
<!-- SECOND NUMBER CONTROLS THE HEIGHT : SCALE OF 0-60 REVERSED -->
<!--<RectangleGeometry Rect="0,22.82,10,60"/>-->
<RectangleGeometry
Rect="{Binding Score, Converter={StaticResource ChartBarScoreConverter}}" />
</Path.Clip>
</Path>
请注意评论RectangleGeometry那里。当我取消注释并注释掉绑定的RectangleGeometry时,这非常有效。当然,当Score改变时它不会改变大小。
现在,如果我在ChartBarScoreConverter中放置一个断点,我会得到正确的值并返回一个新的RectangleGeometry对象,它的注释与那个注释完全相同。这里是转换器的短代码:
...
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
RectangleGeometry output = new RectangleGeometry();
double score = 60; //0
if (Common.IsNumeric(value))
{
score = System.Convert.ToDouble(value) * .60;//scale is 0-60
score = 60 - score;//reversed (=
}
output.Rect = new Rect(0, score, 10, 60);
return output;
}
...
当应用程序运行时,它根本不显示剪辑。正如我所说的,我在转换器中放置了一个断点,并且已经确认它已被调用,并且返回了正确大小的对象......但它并未出现在视图中。
任何想法?
感谢, 保罗
谢谢,约翰。发现。 – 2010-07-22 03:08:28