Mahesh Alle

Mahesh Alle

  • 352
  • 4.9k
  • 12.5m

WPF - Find label control and its values on button click even

Feb 5 2013 7:48 AM
I have list view contain gridview. 
I have bind the list view from code behind. 
Now I want to find the "lblMobile" control and its values on button click event i.e. btnUserId_Click. 
If it is not possible then please suggest any other way to find the the "lblMobile" control and its values from code behind.

Please help me.

<ListView Name="listUsers" SelectionMode="Single" Height="200" SelectionChanged="listUsers_SelectionChanged">

    <ListView.View>

        <GridView AllowsColumnReorder="true" x:Name="grdCustomer">

            <GridViewColumn Header="User Id" >

                <GridViewColumn.CellTemplate>

                    <DataTemplate>

                        <Button Name="btnUserId" Cursor="Hand"  Tag="{Binding Path=UserId }" Click="btnUserId_Click" Content="{Binding Path=UserId }" Style="{StaticResource LinkButton}"></Button>

                    </DataTemplate>

                </GridViewColumn.CellTemplate>

            </GridViewColumn>

            <GridViewColumn Header="Mobile" >

                <GridViewColumn.CellTemplate>

                    <DataTemplate>

                        <Label Foreground="DarkBlue" Name="lblMobile" HorizontalAlignment="Center">

                            <Label.Content>

                                <Binding Path="Mobile"/>

                            </Label.Content>

                        </Label>

                    </DataTemplate>

                </GridViewColumn.CellTemplate>

            </GridViewColumn>

        </GridView>

    </ListView.View>

</ListView>


Answers (2)