Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Wed, 10 Oct 2007 17:32:32 -0500,    group: microsoft.public.windows.developer.winfx.avalon        back       


Hyperlink as button in gridview cell   
Hi,

I've managed to include a hyperlink with a click handler in a databound 
gridview cell like this...

<GridViewColumn Header="Title">
   <GridViewColumn.CellTemplate>
     <DataTemplate>
       <TextBlock>
         <Hyperlink Click="Hyper_OnClick">
           <TextBlock Text="{Binding Path=AttachmentTitle}" />
         </Hyperlink>
       </TextBlock>
     </DataTemplate>
   </GridViewColumn.CellTemplate>
</GridViewColumn>


but can't figure out how to get the text for the link as a string inside 
the hyperlink click handler. How can I do this?
date: Wed, 10 Oct 2007 17:32:32 -0500   author:   Scott Walters

Re: Hyperlink as button in gridview cell   
On Oct 10, 4:32 pm, Scott Walters  wrote:
> Hi,
>
> I've managed to include a hyperlink with a click handler in a databound
> gridview cell like this...
>
> <GridViewColumn Header="Title">
>    <GridViewColumn.CellTemplate>
>      <DataTemplate>
>        <TextBlock>
>          <Hyperlink Click="Hyper_OnClick">
>            <TextBlock Text="{Binding Path=AttachmentTitle}" />
>          </Hyperlink>
>        </TextBlock>
>      </DataTemplate>
>    </GridViewColumn.CellTemplate>
> </GridViewColumn>
>
> but can't figure out how to get the text for the link as a string inside
> the hyperlink click handler. How can I do this?

I used your example -- works great by the way -- for a list of
customers that I had.  When I clicked on the customer I wanted to edit
that record.  Therefore, in the "Tag" of the Hyperlink I placed a
binding to the customer id.  That was the easiest way I found to
recover information I needed about the record that was clicked.  Here
is the snippet...

    <ListView Name="customerList">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Name">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock>
                                <Hyperlink Click="EditCustomer"
Tag="{Binding Path=customerid}">
                                    <TextBlock Text="{Binding
Path=name}"/>
                                </Hyperlink>
                            </TextBlock>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>
            </GridView>
        </ListView.View>
    </ListView>

and here is an example for accessing it...

            MessageBox.Show("Customer: " +
((Hyperlink)sender).Tag.ToString());

... it works great!
date: Sat, 03 Nov 2007 10:11:40 -0000   author:   unknown

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us