2010-05-13 8 views
0

Я использую WPF UserControl, и у меня есть сетка, поэтому я хочу создать событие click, но теперь это не сработает, что я могу сделать. спасибо ..wpf usercontrol

  <Border x:Name="frontWrapperWealthBudget" Width="260" Height="150" VerticalAlignment="Top" HorizontalAlignment="Center"> 
       <Border x:Name="frontHostWealthBudget" Width="260" Height="150" HorizontalAlignment="Center" VerticalAlignment="Top" CornerRadius="10" BorderThickness="2"> 
        <Border.BitmapEffect> 
        <BevelBitmapEffect BevelWidth="2" Relief="0.07" Smoothness="5"/> 
         </Border.BitmapEffect> 

        <Border.Background> 
         <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
          <GradientStop Color="#FF029CF0" Offset="0"/> 
          <GradientStop Color="#FFD3EAF8" Offset="1"/> 
         </LinearGradientBrush>  
        </Border.Background> 
        <Border.Triggers> 
         <EventTrigger RoutedEvent="Grid.Loaded"> 
          <BeginStoryboard> 
           <Storyboard Name="FrontWealthBudgetStoryBoard"> 
            <!-- Make the Viewport3D visible only for the duration of the rotation. --> 
            <ObjectAnimationUsingKeyFrames 
         Storyboard.TargetName="vp3DWealthBudget" 
         Storyboard.TargetProperty="Visibility"> 
             <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" /> 
             <DiscreteObjectKeyFrame KeyTime="0:0:1.1" Value="{x:Static Visibility.Hidden}" /> 
            </ObjectAnimationUsingKeyFrames> 

            <!-- Make the background element visible. (It won't actually appear until it is 
      faded in right at the end of the animation.) --> 
            <ObjectAnimationUsingKeyFrames 
         Storyboard.TargetName="backWrapperWealthBudget" 
         Storyboard.TargetProperty="Visibility"> 
             <DiscreteObjectKeyFrame KeyTime="0:0:1" Value="{x:Static Visibility.Visible}"/> 
            </ObjectAnimationUsingKeyFrames> 


            <!-- Hide the foreground element. It will already be invisible by this time 
      because we fade it out right at the start of the animation. However, until 
      we set its Visibility to Hidden, it will still be visible to the mouse... --> 
            <ObjectAnimationUsingKeyFrames 
         Storyboard.TargetName="frontWrapperWealthBudget" 
         Storyboard.TargetProperty="Visibility"> 
             <DiscreteObjectKeyFrame KeyTime="0:0:0.05" Value="{x:Static Visibility.Hidden}" /> 
            </ObjectAnimationUsingKeyFrames> 


            <!-- Fade the front wrapper out. The Viewport3D is behind us, so it'll fade into 
      view at this point. The reason for fading is to avoid a visible step as we 
      switch from the real UI to the copy projected onto the 3D model. --> 
            <DoubleAnimation To="0" Duration="0:0:0.05" 
         Storyboard.TargetName="frontWrapperWealthBudget" 
         Storyboard.TargetProperty="Opacity" /> 

            <!-- Fade the back wrapper in. Once the spin completes, we fade the real back UI 
      in over the Viewport3D - using a fade to avoid a sudden jolt between the 
      slightly fuzzy 3D look and the real UI. --> 
            <DoubleAnimation BeginTime="0:0:1.05" Duration="0:0:0.05" To="1" 
         Storyboard.TargetName="backWrapperWealthBudget" 
         Storyboard.TargetProperty="Opacity" /> 

            <!-- 3D animation. Move the camera out slightly as we spin, so the model fits entirely 
      within the field of view. Rotate the model 180 degrees. --> 
            <Point3DAnimation To="0,0,1.1" From="0,0,0.5" 
         BeginTime="0:0:0.05" Duration="0:0:0.5" AutoReverse="True" DecelerationRatio="0.3" 
         Storyboard.TargetName="cameraWealthBudget" 
         Storyboard.TargetProperty="(PerspectiveCamera.Position)" /> 
            <DoubleAnimation From="0" To="180" AccelerationRatio="0.3" DecelerationRatio="0.3" 
         BeginTime="0:0:0.05" Duration="0:0:1" 
         Storyboard.TargetName="rotateWealthBudget" 
         Storyboard.TargetProperty="Angle" /> 
           </Storyboard> 
          </BeginStoryboard> 
         </EventTrigger> 
        </Border.Triggers> 
        <GroupBox FontFamily="Bold" FontSize="16" Foreground="White" BorderBrush="{x:Null}" Style="{DynamicResource GroupBoxStyle2}" Width="260" Height="150"> 
         <GroupBox.Header> 
          <StackPanel Name="back1" Orientation="Horizontal" Margin="-50,0,0,-20" HorizontalAlignment="Left" Width="186.697"> 
           <Image Margin="10,3,0,0" Width="35" Height="35" Source="images/home 1.png" Stretch="Fill" HorizontalAlignment="Left" d:LayoutOverrides="HorizontalAlignment" VerticalAlignment="Top"/> 
           <Label Content="Wealth Manager" Margin="5,3,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Height="30" /> 
          </StackPanel> 
         </GroupBox.Header> 

         <StackPanel Orientation="Vertical"> 
          <TextBlock Text="{Binding Label1}" TextWrapping="WrapWithOverflow" Foreground="Black" FontFamily="Bold" FontSize="14" x:Name="lbl1WealthBudget" DataContext="{Binding Source={StaticResource AlertsSrc}}" Margin="0,25,0,0"/> 
          <TextBlock Margin="0,25,0,0" Text="{Binding Label2}" Foreground="Black" FontFamily="Bold" FontSize="14" TextWrapping="WrapWithOverflow" x:Name="lbl2WealthBudget" DataContext="{Binding Source={StaticResource AlertsSrc}}"/> 
         </StackPanel> 
        </GroupBox> 
       </Border> 
      </Border> 
+0

Вы можете разместить код/​​XAML для хорошего старта. – wpfwannabe

+0

Здесь вы должны быть немного понятнее. «есть сетка и __thus__ хотите событие щелчка» ?? –

+0

Посмотрите код –

ответ

0

«Я хочу, чтобы генерировать событие щелчка, но он не будет работать»

что было это значит?

Вы хотите что-то сделать, если щелкнуть по сетке или так встретить другое в окне (объекте), на котором находится ваш элемент управления?