Binding RectangleGeometry.Rect does not show a rectangle

I have a problem with binding to the RectangleGeometry Rect property. The main idea here is that I'm trying to link a clip mask to control the rendered height of a pseudographics object. Here is the XAML:

  <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>

Note the quoted RectangleGeometry. This works great when I uncomment it and comment on the associated RectangleGeometry. Of course, it will not change size when the indicator changes.

Now, if I put a breakpoint in the ChartBarScoreConverter, I get the correct value and return a new RectangleGeometry object of the same specifications as the one commented out there. Here is the converter short code:

  ...
  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;
  }
  ...

, . , , , ... .

?

,

+3
1

RectangleGeometry, Rect Rect RectangleGeometry. "" Rect.

+2

Source: https://habr.com/ru/post/1755889/


All Articles