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
Did the 'Put a link into a cell?' (http://forums.infragistics.com/forums/p/2784/25540.aspx#25540) thread answer your question?
It will provided you can tell me how to update the cell value sytle to look like a hyperlink. I have the following and I don't see any change in the color of the value.
Setter str = new Setter(CellValuePresenter.ForegroundProperty, Brushes.Blue);
fld.Settings.CellValuePresenterStyle = linkStyle;
fld.Label = "Model ID";
fl.Fields.Add(fld);
Also how is this going to work if I have this set...
theDataGrid.FieldSettings.CellClickAction = CellClickAction.SelectRecord;
I still want the record to be selected but I also what to navigate if they click on the it.
Thanks,
Rod
I can't help you with the style, but as far as the CellClickAction is concerned you should do your processing asynchronously so the grid can do its SelectRecord processing first.
delegate void MyDelegate();
void xamDataGrid1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new MyDelegate(ProcessMouseAsync));
}
private static void ProcessMouseAsync()
MessageBox.Show("Do Whatever");
Joe
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);
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());
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?