Quantcast
Channel: wpftoolkit Discussions Rss Feed
Viewing all articles
Browse latest Browse all 2157

New Post: Magnifier toggle on and off

$
0
0
Hi,

The magnifier cannot access other elements in the XAML. There are 2 options :
A) Use EventTriggers from Checkbox to set the Visibility of the Magnifier :
<StackPanel >
         <CheckBox x:Name="chkZoomOn"  IsChecked="False">
            <CheckBox.Triggers>
               <EventTrigger RoutedEvent="CheckBox.Checked">
                  <EventTrigger.Actions>
                     <BeginStoryboard>
                        <Storyboard>
                           <ObjectAnimationUsingKeyFrames Storyboard.TargetName="_magnifier"
                                                           Storyboard.TargetProperty="Visibility">
                              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                 <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Visible</Visibility>
                                 </DiscreteObjectKeyFrame.Value>
                              </DiscreteObjectKeyFrame>
                           </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                     </BeginStoryboard>
                  </EventTrigger.Actions>
               </EventTrigger>
               <EventTrigger RoutedEvent="CheckBox.Unchecked">
                  <EventTrigger.Actions>
                     <BeginStoryboard>
                        <Storyboard>
                           <ObjectAnimationUsingKeyFrames Storyboard.TargetName="_magnifier"
                                                          Storyboard.TargetProperty="Visibility">
                              <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                 <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                 </DiscreteObjectKeyFrame.Value>
                              </DiscreteObjectKeyFrame>
                           </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                     </BeginStoryboard>
                  </EventTrigger.Actions>
               </EventTrigger>
            </CheckBox.Triggers>
         </CheckBox>
         <TextBox Text=" fkjdsf kjfh hewr aksfjl pqwi fbjf nklsdwq uhfjaksfh kjsaf">
            <xctk:MagnifierManager.Magnifier>
               <xctk:Magnifier x:Name="_magnifier"
                               Background="White"
                               BorderBrush="Green"
                               BorderThickness="2"
                               Width="150"
                               Height="150"
                               Visibility="Collapsed" />
            </xctk:MagnifierManager.Magnifier>
         </TextBox>
      </StackPanel>
B) Use the "Checked" and "Unchecked" callbacks on the Checkbox to set the Visibility of the Magnifier :
<StackPanel >
         <CheckBox x:Name="chkZoomOn"
                   IsChecked="False"
                   Checked="chkZoomOn_Checked"
                   Unchecked="chkZoomOn_Checked">
         </CheckBox>
         <TextBox Text=" fkjdsf kjfh hewr aksfjl pqwi fbjf nklsdwq uhfjaksfh kjsaf">
            <xctk:MagnifierManager.Magnifier>
               <xctk:Magnifier x:Name="_magnifier"
                               Background="White"
                               BorderBrush="Green"
                               BorderThickness="2"
                               Width="150"
                               Height="150"
                               Visibility="Collapsed" />
            </xctk:MagnifierManager.Magnifier>
         </TextBox>
      </StackPanel>

private void chkZoomOn_Checked( object sender, RoutedEventArgs e )
{
      CheckBox checkBox = sender as CheckBox;
      if( checkBox != null )
      {
        _magnifier.Visibility = ( checkBox.IsChecked.Value ) ? Visibility.Visible : Visibility.Collapsed;
      }
}

Viewing all articles
Browse latest Browse all 2157

Trending Articles