Hello,
I want to show the panzoombar when the user zoom the chart, and hide the panzoombar if there is no zoom. So I implement this:
I add tiggers in the a style for panzoombar:
<
Style.Triggers
><
br
> <
Trigger
Property
=
"Orientation"
Value
=
"Horizontal"
><
br
> <
Setter
Property
=
"Visibility"
Value
=
"{Binding HorizontalPanZoomBarVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
/><
br
> </
Trigger
><
br
> <
Trigger
Property
=
"Orientation"
Value
=
"Vertical"
><
br
> <
Setter
Property
=
"Visibility"
Value
=
"{Binding VerticalPanZoomBarVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
/><
br
> </
Trigger
><
br
> </
Style.Triggers
>
In the view model:
private
Size _zoom =
new
Size(1, 1);<br>
public
Size Zoom<br> {<br>
get
{
return
_zoom; }<br>
set
<br> {<br> _zoom = value;<br>
if
(Math.Abs(_zoom.Width - 1) < 0.00001f)<br> {<br> HorizontalPanZoomBarVisible =
false
;<br> }<br>
else
<br> {<br> HorizontalPanZoomBarVisible =
true
;<br> }<br><br>
if
(Math.Abs(_zoom.Height - 1) < 0.00001f)<br> {<br> VerticalPanZoomBarVisible =
false
;<br> }<br>
else
<br> {<br> VerticalPanZoomBarVisible =
true
;<br> }<br> }<br> }<br><br>
public
bool
VerticalPanZoomBarVisible<br> {<br>
get
<br> {<br>
return
_verticalPanZoomBarVisible;<br> }<br>
set
<br> {<br> _verticalPanZoomBarVisible = value;<br> RaisePropertyChanged(() => VerticalPanZoomBarVisible);<br> }<br> }<br><br>
private
bool
_horizontalPanZoomBarVisible;<br>
private
bool
_verticalPanZoomBarVisible;<br><br>
public
bool
HorizontalPanZoomBarVisible<br> {<br>
get
{
return
_horizontalPanZoomBarVisible; }<br>
set
<br> {<br> _horizontalPanZoomBarVisible = value;<br> RaisePropertyChanged(() => HorizontalPanZoomBarVisible);<br> }<br> }
The chart:
<telerik:RadCartesianChart Grid.Row="2" x:Name="Chart" Margin="20" Zoom="{Binding Zoom, Mode=TwoWay}">
The problem is, it work only for the first time, at the beginning, there is no zoom, so the panzoombar hides correctly, after I zoom, the panzoombar appear correctly, but if I reset zoom to (1,1), and zoom again, the panzoombar never appear, I don't know why? I use snoop to check and find out the visibility of the panzoombar is changed correctly, but I still can not see it.
Do you have any ideas?
Thanks,
Jie