Is it possible to set the text as a link and when a user clicks on link I can run a routine?
The reason I am using XamTextEditor rather than TextBlock is for the theme capabilities.
But when I set the Style on the XamTextEditor it does not theme. All other XamTextEditors do (no style applied to them).
Rick
Rick,
From your description everything looks fine with the theme. This code should work:
<igEditors:XamTextEditor x:Name="xamTextEditor1" Theme="[current]" Style="{DynamicResource someStyle/>
public Window1(){ InitializeComponent(); ThemeManager.CurrentTheme = "LunaOlive";}
For more details about common issues with the themes you can find this article helpfull.
Regarding the Hyperlink there are couple of things you shoud be aware - the default navigation will work when the control is placed in a Page. For a Window you can handle RequestNavigate event e.g.
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e){ System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(e.Uri.AbsoluteUri)); e.Handled = true;}
You can also use the same method with some of the default mouse events of the editor like PreviewMouseLeft ButtonDown.
Is there any particular reason to use the XamTextEditor rather then the standard TextBlock?
Also, I set theme properity to [current] when I use style and change theme the control stays the same theme. Is there a way to add hyperlink and keep the ability to change theme?
Should I create a class and inherit XamTextEditor and set hyperlink in the custom class and will that retain theme features?
Thanks
I copied style from EditorsGeneric_Express.xamlto my app.xaml
Added Hyperlink to the content of the textblock:
<Hyperlink> <TextBlock Text="{TemplateBinding DisplayText}"/> </Hyperlink>
It shows correctly:
<igEditors:XamTextEditor Style="{DynamicResource Hyperlink}" Grid.Row="0" Grid.Column="1" Name="XamTextEditorPayAddrName" Value="{Binding Path=PaymentOfficeAddr.Name, Mode=OneWay}" IsReadOnly="True" Theme="[current]" Width="300" />
When I try to click on hyperlink it disappears and just shows text. It's going into edit mode I believe.
How do you disable edit mode? How do I set an event handler for the click event on the hyperlink?
can I do something like this <igEditors:XamTextEditor Style="{DynamicResource Hyperlink}" ... Click="clickHandler"/> or do I have to assign event handler in code?
Hmm, seems my question are rather more towards WPF concepts rather than your controls. Excuse my ignorance I appreciate greatly your help.
Thank you
Yes, this is possible with a custom template for the editor. You can find the default style for the XamTextEditor in the DefaultStyles\Editors\EditorsGeneric_Express.xaml and add Hyperlink as a content of the TextBlock that is used in the Template. Probably you will have to use some of the events on the hyperlink or disable edit mode of the grid because when you click the editor will enter edit mode by default.
Let me know if you have any questions or concerns.