Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi
i am working with the wpf xaml now, i had understood how to write the style somewhat but ,here iam able to write the style for mousehour, but right now i need to right now i need to write the Triggers for mouseispressed, so please help

i had tried alot , but some thing is wrong in it , to wrte the Triggers for the ispressed ,
i had tried

1.<trigger property="UIElement.IsPressed" value="true"></trigger><pre>

<pre>2.<trigger property="IsPressed" value="true"></trigger>



but it was showing the error and my sample listview code is

XML
<ListView Canvas.Left="483" Canvas.Top="276" FontSize="14" Height="174" ItemsSource="{Binding}" Name="listView1" TabIndex="5" Width="492" SelectionChanged="listView1_SelectionChanged" >
              <ListView.ItemContainerStyle>
               <Style TargetType="{x:Type ListViewItem}">
                            <Style.Triggers>
                              <Trigger Property="UIElement.IsMouseOver" Value="true">
                              <Setter Property="Control.Height" Value="37"/>
                              <Setter Property="Cursor" Value="Hand"/>
                              <Setter Property="Control.Foreground" Value="Black"/>
                              <Setter Property="Control.Background">
                                  <Setter.Value>
                                      <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                          <LinearGradientBrush.GradientStops>
                                              <GradientStopCollection>
                                                  <GradientStop Color="#FF97d3f3" Offset="0"/>
                                                  <GradientStop Color="#FF4385BE" Offset="1"/>
                                              </GradientStopCollection>
                                          </LinearGradientBrush.GradientStops>
                                      </LinearGradientBrush>
                                  </Setter.Value>
                              </Setter>
                          </Trigger>

                      </Style.Triggers>
                      <Setter Property="FrameworkElement.Height" Value="24" />
                      <Setter Property="Control.Background" Value="#FFFFFF"/>
                      <Setter Property="Control.Foreground" Value="#6B3D10">

                      </Setter>
                  </Style>
              </ListView.ItemContainerStyle>
              <ListView.View>
                  <GridView>
                      <!--<GridViewColumn Header="ID" DisplayMemberBinding="{Binding Path=id}" Width="2"></GridViewColumn>-->
                      <GridViewColumn Header="Reference No" DisplayMemberBinding="{Binding Path=filerefno1}" Width="110"></GridViewColumn>
                      <GridViewColumn Header="Status" DisplayMemberBinding="{Binding Path=status1}" Width="100"></GridViewColumn>
                      <GridViewColumn Header="Next Date" DisplayMemberBinding="{Binding Path=nextdatea}" Width="100"></GridViewColumn>
                      <GridViewColumn Header="Description" DisplayMemberBinding="{Binding Path=desca}" Width="170"></GridViewColumn>
                      <GridViewColumn Header="Doc No" DisplayMemberBinding="{Binding Path=id}" Width="0"></GridViewColumn>

                  </GridView>
              </ListView.View>
          </ListView>
Posted
Comments
Sergey Alexandrovich Kryukov 28-Sep-11 15:46pm    
Do you really need to write it all in XAML? Code is way easier...
--SA
hzawary 3-Oct-11 12:11pm    
May you input the error?

1 solution

Are you have this like error?

Error: does not contain a definition for listView1_SelectionChanged; and no extension method;listView1_SelectionChanged; accepting a first argument of type; could be found (are you missing a using directive or an assembly reference?)

If your answer is positive, there are two way

C#
<listview canvas.left="483" canvas.top="276" fontsize="14" height="174" itemssource="{Binding}" name="listView1" tabindex="5" width="492">SelectionChanged="listView1_SelectionChanged" >
              <listview.itemcontainerstyle>
</listview.itemcontainerstyle></listview>


delete the SelectionChanged="listView1_SelectionChanged"
or
right click on "listView1_SelectionChanged" and choose "Navigate to Event Handler" option for go on code behind!
 
Share this answer
 
Comments
hzawary 4-Oct-11 4:13am    
With before thanks;
Please tell me, who gives score to my answers?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900