I'm developing wp8 application for reading Twitter. I read, that RichTextBox can detect links, it's good. But, I want to make next functionality: if in tweet text exist symbol "#" - make a hyperlink with world after "#", which will open a new page like /DetailsPage.xaml?name=#name and show additional info about user. The same thing with #, but open page with tweets which has this hashtag. Is there any way to make it?
Very simple, use the following XAML:
<RichTextBox>
<Paragraph>
<Hyperlink NavigateUri="/Page1.xaml">click me!</Hyperlink>
</Paragraph>
</RichTextBox>
This will display text click me! which looks like a hyperlink and can be clicked. When clicked, it will take you to Page1.xaml in your project.
You will obviously need to create content dynamically for RichTextBox, but I will leave it as an exercise.
Related
Quick question,
In Xamarin Forms, when using a Tabbed Page, is there any way for there to be content that remains static between the tabs (other than the tabbar itself)?
For example, if I have a TabbedPage with 3 children (say Page1, Page2 and Page3), can I add other children to TabbedPage that are not a part of the tab itself, but elsewhere, and stay there between tabs?
My use for this is I have 3 tabs in my TabbedPage, which is are at the bottom of the page. I would like a settings button in the top-right of each page, without having to create the same content multiple times in each page that is a child of the TabbedPage.
<TabbedPage xlmns="...>
[Content Here that remains between all tabs, but not a part of the tabbar itself]
<local:Page1>
<local:Page2>
<local:Page3>
</TabbedPage>
Is there some way of doing this easily? Or is there some other method?
Thanks for any help.
You need to check this and create your own control template
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/templates/control-templates/
I would like a settings button in the top-right of each page, without having to create the same content multiple times in each page that is a child of the TabbedPage.
An easy way is using custom control as model. Add the custom control, the button would show in every tabbed pages(page1, page2, page3). If you want to more change on the button, change the custom model, all the changes would show in pages.
Custom Control: ButtonModel
<Button x:Name="btnModel" Text="Button" HorizontalOptions="EndAndExpand" Margin="4,0,8,0"></Button>
Add this in Page1, Page2, Page3
<local:ButtonModel ></local:ButtonModel>
There are a few methods of fixing this. One of these is outlined in another comment very well, however I found that the Xamarin Forms 'Pure' tabs fitted my needs better.
https://www.sharpnado.com/pure-xamarin-forms-tabs/
It was relatively intuitive once I got my head round it and handles integration with mvvm rather well. The tabs need nod span the entire page (other than the tabbar) which is exactly what I wanted.
I have a panel that gets a hyperlink added dynamiclly through C# with values from an sql database.
However some of the URLs are really long and quite uneccessary to display.
I have not found any good ways to hide/disable the url showing and replace it with text. I can not use normal <a href> as it handled server side.
EDIT added some of the code.
<asp:HyperLink ID="moduleHyperlink" runat="server"></asp:HyperLink>
now in C#
HyperLink hyp = createHyperlink(btn.link);
moduleHyperlink.Controls.Add(hyp);
This will display for the user the entire btn.link (url string) which might be really long and it looks messy on the webpage. I would rather have a text saying "External Link", which when clicked redirects the user to the url.
You can add Text property to show some valid link title instead of showing the URL.
HyperLink hyp = createHyperlink(btn.link);
hyp.Text = "YourTextForTheLink";
moduleHyperlink.Controls.Add(hyp);`
I am trying to make an alternative browser for Windows Phone 8 and would like to have the same keyboard open for my textbox as the one used by the native browser. The one with the .com button as well as the arrow where the enter button is. I am guessing this is probably some simple setting but I have no idea what it is.
Use InputScope property in the TextBox, take a look to this samples in msdn.
For example:
<TextBox Name="txtPhoneNumber" Height="71" Width="460" >
<TextBox.InputScope>
<InputScope>
<InputScopeName NameValue="Number" />
</InputScope>
</TextBox.InputScope>
</TextBox>
You're looking for the URL input scope. See more here: InputScopeNameValue
I have a textbox as follows:
<asp:TextBox runat="server" ID="txtOtherApps" Height="400" Width="400"
TextMode="MultiLine" ontextchanged="txtOtherApps_TextChanged" ></asp:TextBox>
How to display link in this textbox?
The TextBox allows you to display text which the user can edit. It does not allow you to display anything but plain text. To display a URL in the TextBox, simply set its Text property:
txtOtherApps.Text = "http://www.example.com/";
It wont, however, be a "link". Clicking the URL will cause a text cursor to be placed, allowing for the user to edit the URL.
It is possible if you use JavaScript
Use JavaScript on your text element - such that:
<input type="text" name="t1" id="t1" value="http://www.google.com" onmouseover="this.style.cursor='pointer' ;" onClick="window.open(this.value);"/>
Only Java script can do what you are asking for.
You won't be able to click on the link, but you can just set the Text property of the TextBox to the URL.
ASP.NET will render TextBoxes as textareas (in your case, because it's multiline) or inputs. These are standard HTML fragments which are just plain text containers. You can style them, but you can't really linkify the contents of them.
If you really just want to put the text of a link into a box, do this:
// either from the server:
txtOtherApps.Text = YourLinkString;
// or from the client:
<script>
document.getElementById('<%=txtOtherApps.ClientID%>').value = YourJsLinkValue;
</script>
If you want something to happen with the user clicks on the text area, you can add an onclick handler to it...but this would be weird.
You will need a RichTextBox. The .NET one is not available for web applications, but there are a few third party solutions available.
http://www.richtextbox.com/ is one of them, you will have to see for yourself if there is any available that suits your needs better.
I have an asp.net web page written in C#.
Using some javascript I popup another .aspx page which has a few controls that are filled in and from which I create a small snippet of text.
When the user clicks OK on that dialog box I want to insert that piece of text into a textbox on the page that initial "popped up" the dialog/popup page.
I'm guessing that this will involve javascript which is not a strong point of mine.
How do I do this?
You will have to do something like:
parent.opener.document.getElemenyById('ParentTextBox').value = "New Text";
What you could do is create an ajax modal pop-up instead of a new window. The semantic and aesthetic value is greater not to mention the data-passing is much easier.
http://www.asp.net/ajax/ajaxcontroltoolkit/samples/modalpopup/modalpopup.aspx