locked
rlated to wpf---its very urgent could anyone help? RRS feed

  • Question

  • hi please copy and paste the below code and it has xml file also that file data i listed below the link , and please have a look at also.

    <Window x:Class="WpfApplication4.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="List_View Example" Height="301" Width="361" WindowStartupLocation="Manual"
             xmlns:sys="clr-namespace:System;assembly=mscorlib" >
           
        <Window.Resources>
            <XmlDataProvider x:Key="employee_DS" Source="data.xml"
                         x:Name="empdata" />
            <Style x:Key="{x:Type Button }" TargetType="{x:Type Button}">
                <Setter Property="FontFamily" Value="Tahoma" />
                <Setter Property="FontSize" Value="10" />
                <Setter Property="Height" Value="65" />
                <Setter Property="Margin" Value="20,20,20,0" />
            </Style>
         
        </Window.Resources>
        <Window.Background>
            <!-- background gradient -->
            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                <LinearGradientBrush.GradientStops>
                    <GradientStop Color="Aqua" Offset="0" />
                    <GradientStop Color="BlanchedAlmond" Offset="0.5" />
                    <GradientStop Color="Chocolate" Offset="0.9" />
                    <GradientStop Color="DarkOrange" Offset="1" />
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </Window.Background>


        <StackPanel >
         
            <Grid>
              
                <ListView Name="lstvwEmployees" Margin="25,0,21,-156" ItemTemplate="{DynamicResource EmployeeTemplate}"
                      ItemsSource="{Binding Source={StaticResource employee_DS},
                XPath=/wipro_employee/employee}" SelectionChanged="ListView_SelectionChanged" Cursor="Hand" MouseEnter ="lstvwEmployees_MouseEnter"  Height="99" VerticalAlignment="Bottom">
                <!-- for mouse enter event ,it triggers the scaletransform-->
                    <ListView.ItemContainerStyle>

                        <Style TargetType="ListViewItem">

                            <Style.Triggers>

                                <Trigger Property="IsMouseOver" Value="True">

                                    <Setter Property="Panel.ZIndex" Value="{x:Static sys:Int32.MaxValue}"/>

                                    <Setter Property="RenderTransform">

                                        <Setter.Value>

                                            <ScaleTransform ScaleX="1" ScaleY="1"/>

                                        </Setter.Value>

                                    </Setter>

                                    <Trigger.EnterActions>

                                        <BeginStoryboard>

                                            <Storyboard>

                                                <ParallelTimeline BeginTime="0:0:0">

                                                    <DoubleAnimation Duration="00:00:00.3000000" To="1.5" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)"/>

                                                    <DoubleAnimation Duration="00:00:00.3000000" To="1.5" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)"/>

                                                </ParallelTimeline>

                                            </Storyboard>

                                        </BeginStoryboard>

                                    </Trigger.EnterActions>

                                    <Trigger.ExitActions>

                                        <BeginStoryboard>

                                            <Storyboard>

                                                <ParallelTimeline BeginTime="0:0:0">

                                                    <DoubleAnimation Duration="00:00:00.3000000" To="2" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)"/>

                                                    <DoubleAnimation Duration="00:00:00.3000000" To="2" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)"/>

                                                </ParallelTimeline>

                                            </Storyboard>

                                        </BeginStoryboard>

                                    </Trigger.ExitActions>

                                </Trigger>

                            </Style.Triggers>

                        </Style>

                    </ListView.ItemContainerStyle>

                    <!-- for listview to show animation as outer glow effect-->
                    <ListView.BitmapEffect>
                        <BitmapEffectGroup>
                            <OuterGlowBitmapEffect GlowColor="CornflowerBlue"  GlowSize="15"/>
                            <DropShadowBitmapEffect ShadowDepth="10" Softness="5"/>
                            <BevelBitmapEffect BevelWidth="15"/>
                        </BitmapEffectGroup>
                    </ListView.BitmapEffect>
                   
                        <ListView.View>
                        <GridView >
                        <GridViewColumn Header="Code" Width="50" DisplayMemberBinding="{Binding XPath=Code}" />
                        <GridViewColumn Header="Name" Width="100" DisplayMemberBinding="{Binding XPath=Name}"/>
                        <GridViewColumn Header="Country" DisplayMemberBinding="{Binding XPath=Country}"/>
                    </GridView>
                   </ListView.View>
                   
            </ListView>
                <Button Height="34" Name="button1" Width="77" HorizontalAlignment="Right" Margin="0,0,21,-201" VerticalAlignment="Bottom" Click="button1_Click">Close Window</Button>
            </Grid>
            <!-- button to show animation as outer glow effect-->


            <Popup Placement="Mouse" Name="popup"  DataContext="{StaticResource employee_DS}" AllowsTransparency="True">



                <Grid Name="grid1" Background="Gray"  DataContext="{Binding}">
                    <TextBlock Margin="20,27,10,22" >Details of the Employee</TextBlock>
                    <Label Margin="20,48,172,0" Content="Code" Height="24" VerticalAlignment="Top"></Label>
                    <Label Content="Name" Margin="20,86,0,132" HorizontalAlignment="Left" Width="43"></Label>
                    <Label Content="Country" Margin="20,124,0,106" HorizontalAlignment="Left" Width=" 50"></Label>
                    <Button Background="ForestGreen" Margin="0,0,10,0" Name="ex" Content="Exit" Click="Button_Click_1" HorizontalAlignment="Right" Width="69" Height="26" VerticalAlignment="Bottom"></Button>
                    <TextBox Text="{Binding XPath=Code}" Height="26" Margin="108,54,32,0" Name="textBox1" VerticalAlignment="Top"/>
                    <TextBox Text="{Binding XPath=Name}" Height="26" Margin="108,89,32,0" Name="textBox2" VerticalAlignment="Top"/>
                    <TextBox Text="{Binding XPath=Country}" Height="27" Margin="107,124,32,0" Name="textBox3" VerticalAlignment="Top"/>
                    <Label HorizontalAlignment="Left" Margin="20,158,0,142" Name="Label1" Width="83">Age</Label>
                    <TextBox Text="{Binding XPath=age}" Margin="107,164,32,139" Name="textBox4" />
                    <Label Height="32" HorizontalAlignment="Left" Margin="21,0,0,90" Name="label2" VerticalAlignment="Bottom" Width="94">Job Status</Label>
                    <TextBox Text="{Binding XPath=job}" Height="25" Margin="107,0,30,95" Name="textBox5" VerticalAlignment="Bottom" />
                    <Label Height="32" HorizontalAlignment="Left" Margin="21,0,0,30" Name="label3" VerticalAlignment="Bottom" Width="83">Details</Label>
                    <Label Content="{Binding XPath=details}" Height="63" Margin="93,0,18,22" Name="label4" VerticalAlignment="Bottom"></Label>
                </Grid>
            </Popup>

            <Grid>
                <Grid.Triggers>
    <!-- story board for mouse enter animation-->
         <EventTrigger RoutedEvent='Rectangle.MouseEnter' Storyboard.TargetName="popup" Storyboard.TargetProperty="(Popup.IsOpen)">
                        <EventTrigger.Actions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                    Storyboard.TargetName="lstvwEmployees"
                    Storyboard.TargetProperty="Opacity"
                    To="1.0" Duration="0:0:1"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger.Actions>
                    </EventTrigger>

                    <EventTrigger RoutedEvent='Rectangle.MouseLeave'>
                        <EventTrigger.Actions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                    Storyboard.TargetName="lstvwEmployees"
                    Storyboard.TargetProperty="Opacity"
                    To="0.3" Duration="0:0:2"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger.Actions>
                    </EventTrigger>

                </Grid.Triggers>

            </Grid>
           
          
        </StackPanel>
        <!--
                    <Style TargetType="ListViewItem">

                        <Style.Triggers>

                            <Trigger Property="IsMouseOver" Value="True">

                                <Setter Property="Panel.ZIndex" Value="{x:Static sys:Int32.MaxValue}"/>

                                <Setter Property="RenderTransform">

                                    <Setter.Value>

                                        <ScaleTransform ScaleX="1" ScaleY=
        "1"/>

                                    </Setter.Value>

                                </Setter>

                                <Trigger.EnterActions>

                                    <BeginStoryboard>

                                        <Storyboard>

                                            <ParallelTimeline BeginTime="0:0:0">

                                                <DoubleAnimation Duration="00:00:00.2000000" To="1.5" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)"/>

                                                <DoubleAnimation Duration="00:00:00.2000000" To="1.5" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)"/>

                                            </ParallelTimeline>

                                        </Storyboard>

                                    </BeginStoryboard>

                                </Trigger.EnterActions>

                                <Trigger.ExitActions>

                                    <BeginStoryboard>

                                        <Storyboard>

                                            <ParallelTimeline BeginTime="0:0:0">

                                                <DoubleAnimation Duration="00:00:00.2000000" To="1" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleY)"/>

                                                <DoubleAnimation Duration="00:00:00.2000000" To="1" Storyboard.TargetProperty="RenderTransform.(ScaleTransform.ScaleX)"/>

                                            </ParallelTimeline>

                                        </Storyboard>

                                    </BeginStoryboard>

                                </Trigger.ExitActions>

                            </Trigger>

                        </Style.Triggers>

                    </Style>
       
        -->
        </Window>
      

    and my data.xml file is ;

    <?xml version="1.0" encoding="utf-8"?>
    <wipro_employee>
      <employee emp_id="0">
        <Code>c1</Code>
        <Name>vinoth</Name>
        <Country>india</Country>
        <age>20</age>
        <job>working</job>
        <details>
         This is with respect to the details of
         Employee vinoth,code no 1 and his residence in India</details>
      </employee>
      <employee emp_id="1">
        <Code>c2</Code>
        <Name>kumar</Name>
        <Country>United Kingdom</Country>
        <age>28</age>
        <job>working</job>
        <details>
          This is with respect to the details of
          Employee kumar,code no 2 and his residence in United Kingdom
        </details>
      </employee>
      <employee emp_id="2">
        <Code>c3</Code>
        <Name>vinothkumar</Name>
        <Country>Spain</Country>
        <age>27</age>
        <job>working</job>
        <details>
          This is with respect to the details of
          Employee vinothkumar,code no 3 and his residence in Spain
        </details>
      </employee>
      <employee emp_id="3">
        <Code>c4</Code>
        <Name>veluswamy</Name>
        <Country>england</Country>
        <age>23</age>
        <job>working</job>
        <details>
          This is with respect to the details of
          Employee veluswamy,code no 4 and his residence in England
        </details>
      </employee>

    </wipro_employee>


    please bind this xml file with the listview and run this code.

    on clicking the listviewitem ,the selected item is not showing any color on single click, but double click the listviewitem, now the selected item can be seen by the default blue color, please help me , i need to fix this issue,, on jus clicking the listviewitem, i need to set the selected item to some color so that the user will come to know which item does he selected.

    thanks in advance to all and help me to fix this problem,, am i left any code in that?

    its very urgent please reply for my post,,,

    regards
    vinoth
    • Edited by vinothkumarv Saturday, February 21, 2009 2:12 PM very urgent to finishup
    Thursday, February 19, 2009 2:37 PM