Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
314
navigaton to URL in Hyperlink column in XamGrid
posted

Hi,

I have used Xamgrid , where i hav hyperlink col for my projectid and i want to  navigate to other webaddres

For Example:  http://mytestsite/pages.aspx?projectid=1111

how can i provide this type of url on the click of my projectid hyperlinkcolumn , the projectid  will differ for every cell , i am listing my projects which shows some data along with projectid , on click of particular projectid , the more details should be opened

Thanks in Advance

Parents
No Data
Reply
  • 6912
    Verified Answer
    posted

    Hi,

    If you just want to create an additional column with a hyperlink based on another column you can use UnboundColumn and converter to create the hyperlink.

    First you need a converter:

    ...
    public class Conv : IValueConverter
    {
    	public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    	{
    		if (value is int && targetType == typeof(Uri))
    		{
    			return new Uri(string.Format("http://mytestsite/pages.aspx?projectid={0}", value));
    		}
    
    		return null;
    	}
    
    	public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    	{
    		throw new NotImplementedException();
    	}
    }

    Then add an UnboundColumn:

    ...
    <UserControl.Resources>
            <local:Conv x:Key="Conv" />
        </UserControl.Resources>
    ...
    <ig:XamGrid.Columns>
    	<ig:TextColumn Key="Id" />
    	<ig:UnboundColumn Key="MyUnboundColumnWithHyperlink">
    		<ig:UnboundColumn.ItemTemplate>
    			<DataTemplate>
    				<HyperlinkButton Content="Navigate to Page" NavigateUri="{Binding RowData.Id, Converter={StaticResource Conv}}" />
    			</DataTemplate>
    		</ig:UnboundColumn.ItemTemplate>
    	</ig:UnboundColumn>
    </ig:XamGrid.Columns>
    ...

    I hope that this will help you.

Children
No Data