I would like to add a hyperlink to a column's value so that I can navigate to another function in my app. Is this possible?
Thanks,Rod
You can use the CellValuePresenter to easily add a hyperlink to a cell
http://help.infragistics.com/Help/NetAdvantage/WPF/2007.1/CLR3.X/HTML/Infragistics3.Windows.DataPresenter.v7.1~Infragistics.Windows.DataPresenter.FieldSettings~CellValuePresenterStyle.html
<!-- hyperlink cell --> <!-- Note - you'll need to handle the routed Hyperlink.RequestNavigate to process the clicking on a link --> <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="hyperlinkCell"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock Margin="{TemplateBinding Padding}"> <Hyperlink NavigateUri="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}"> <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}"/> </Hyperlink> </TextBlock> </ControlTemplate> </Setter.Value> </Setter> </Style>
Ok really dumb question. I am trying to replicate the above method but I am receiving a conversion error:
Cannot convert type 'System.Windows.DependencyObject' to 'Infragistics.Windows.DataPresenter.CellValuePresenter' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion
I am assuming that I am missing something here but I'm not sure where to go now. Ideas?
You could pass it as a parameter to the delegate like so:
delegate void MyDelegate(object cellValue);
void xamDataGrid1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
DependencyObject source = e.OriginalSource as DependencyObject; if (source == null) return; CellValuePresenter cvp = Infragistics.Windows.Utilities.GetAncestorFromType(source, typeof(CellValuePresenter), true) as CellValuePresenter; if (cvp != null) this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new MyDelegate(ProcessMouseAsync), cvp.Value);
DependencyObject source = e.OriginalSource as DependencyObject;
if (source == null)
return;
CellValuePresenter cvp = Infragistics.Windows.Utilities.GetAncestorFromType(source, typeof(CellValuePresenter), true) as CellValuePresenter;
if (cvp != null)
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new MyDelegate(ProcessMouseAsync), cvp.Value);
}
private static void ProcessMouseAsync(object cellValue)
MessageBox.Show("Cell value is: " + cellValue.ToString());
Joe
Can you at least tell me if the style I need to change it the CellValuePresenterStyle?
Cool. How do you get the cell value then?
Rod