Set value of hyperlink with WPF by code

I'm using WPF and an Hyperlink control with

<TextBlock Margin="98,190,116,133.418" FontSize="14"> <Hyperlink Name="hyperlink" RequestNavigate="Hyperlink_RequestNavigate"> Click here </Hyperlink> </TextBlock>

this is working, but I would like to set the "click here" value by code, but I'm unable to find the correct property.

hyperlink.Value ? hyperlink.Text ?

Thanks in advance for your help

-------------Problems Reply------------

Content: Hyperlink Inlines

Url: Hyperlink.NavigateUri

Hyperlink Properties

An alternative answer, which I consider more straightforward than working with the InLines is to put a TextBlock (with x:Name) inside the Hyperlink and then call its Text property in code behind:

<TextBlock Margin="98,190,116,133.418" FontSize="14">
<Hyperlink Name="hyperlink" RequestNavigate="Hyperlink_RequestNavigate">
<TextBlock x:Name="hyperlinkText"/>
</Hyperlink>
</TextBlock>

Then in code behind you can set the hyperlink's text by calling hyperlinkText.Text, like this:

private void Button_Click(object sender, RoutedEventArgs e)
{
this.hyperlinkText.Text = "some custom text";
}

Category:wpf Views:0 Time:2010-01-08
Tags: wpf hyperlink

Related post

  • How can I add a parameter to a HyperLink in WPF? 2011-05-31

    I have a column in a gridview that has a hyperlink defined in each row. <TextBlock> <Hyperlink Click="btn_Authorise"> <TextBlock Text="{Binding LinkText}"/> </Hyperlink> </TextBlock> I would like the hyperlink to execute

  • Example using Hyperlink in WPF 2012-04-20

    I've seen several suggestions, that you can add hyperlink to WPF application through Hyperlink control. Here's how I'm trying to use it in my code: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.m

  • Where should I put WPF specific code when using MVVM? 2010-04-16

    I'm just getting up to speed on MVVM, but all the examples I've seen so far are binding View controls to simple non-WPF specific data types such as strings and ints. However in our app I want to be able to set a button's border brush based on a numbe

  • Setting a GridView's colour in WPF via code 2011-03-30

    I've been searching for quite a long time how to do this. I don't know how to set the colour of a row item in the GridView (WPF) using code I don't want an example in XAML My data comes from me loading & pulling apart an XML file. I then put it i

  • Is there a setting to eliminate the constant need to change hyperlinks with "select hyperlink" or "toggle field codes"? 2013-10-22

    Whenever I forward or reply to a message, any and all of the hyperlinks are converted, and if I want them to display, I have to manually adjust each one by right clicking and then either "select hyperlink" or "toggle field codes" (for pictures). Is t

  • Relative hyperlink "text to display" code/format? 2012-11-26

    Hello, I would like to know what the hyperlink format for OneNote 2010 is? I tried to use wiki syntax [[url|name of link]], which doesn't work how I want it to--> (name of link) I can however use [[url]] to generate the relative link "url". Using

  • How can I determine coordinates of a Hyperlink in WPF 2010-09-05

    I have WPF window with a FlowDocument with several hyperlinks in it: <FlowDocumentScrollViewer> <FlowDocument TextAlignment="Left" > <Paragraph>Some text here <Hyperlink Click="Hyperlink_Click">open form</Hyperlink> <

  • How do I create a menu separator bar in WPF using code 2008-11-11

    I am creating menus in WPF programatically using vb.net. Can someone show me how I can add separator bar to a menu in code? No xaml please. --------------Solutions------------- WPF has a Separator control for just that purpose and it also separates y

  • How to wait for a background thread/operation to complete in WPF UI code? 2009-01-13

    e.g. in Winforms I'd write... // on UI Thread BackgroundWorker workerThread = new BackgroundWorker(); workerThread.DoWork += new DoWorkEventHandler(LoadChildren); workerThread.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnLoadChildrenCom

  • Animating a MatrixTransform in WPF from code 2009-05-27

    I have a Canvas which I would need to animate the RenderTransform property of. The start and end matrices will be abitrary, so I can't pre write the storyboard in XAML, so I'm trying to do it in code, I can't find any example of how to do this, below

  • g.i.cs file not found with WPF and code contracts 2009-09-30

    I have a WPF project which compiles just fine. However, when I enable code contracts, I get a lot of errors like the following: file 'C:\MyProject\obj\Debug\MyFile.g.i.cs' could not be found Is there workaround? --------------Solutions------------- J

  • Wpf: Inherit code-behind Code 2009-10-22

    I have several similar user controls which display listviews of respectively different data entities. In the code-behind files of these controls there is quite a bit of common business logic. How can these common methods be combined in a single "supe

  • WPF: Minimizing code-behind on the user interface 2010-01-03

    I've been playing with WPF/XAML again and have noticed that there doesn't seem to be an easy way to code UI-only keygestures/mousegestures and the like. For example, how to add a "Maximize without windowframe" command to a window. Currently this invo

  • WPF/XAML code generators 2010-03-22

    Do you use a code generator for WPF/XAML? If so, in what capacity? Is it 3rd party/in-house? --------------Solutions------------- i know that XAML power toys got some code generation but i don't know what it does. I've used the xaml export in InkScap

  • construct hyperlink in wpf C# 2010-04-15

    how can i insert a TextBlock control in a Hyperlink in c# coding. similar to <TextBlock> <Hyperlink>a</Hyperlink></textblock in C#. i'm unable to find content property in Hyperlink. Thanks in advance. --------------Solutions-----

  • WPF XAML code-behind management 2010-10-04

    I have wandered into a WPF application project and have made some good progress, but one thing I am finding is that the code-behind page is now getting longer and longer... since there is only one XAML page to the whole application, the code-behind p

  • Canvas zooming in WPF using code behind 2010-10-17

    Here the scenario is: I have a canvas with different diagrams drawn on it. Now the requirement is to zoom into the canvas using the code behind either using C# or VB. Moreover I need to place the zoom code in some dll so that i can reuse the same set

  • WPF trigger code behind button to display second form 2010-12-10

    I am a WPF novice. I have created a form containing a combo box with which to choose a multi-field key value(populated from an XML data file). I have also created a second WPF form which is available to display all field values from the record associ

  • how to use hyperlink in wpf to get a file in network drive? 2011-03-07

    I have a web application...where I can get an excel file from network drive...using ..So I am not using any impersonation. Do we have something similar to that in WPF ? EDIT: I want to open excel file in network location...when user click a link or b

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.213 (s). 11 q(s)