Supposing we're having this case of a RichTextBlock :
<RichTextBlock IsTextSelectionEnabled="True">
<Paragraph>
<Run Text="{Binding Description}" />
</Paragraph>
</RichTextBlock>
Is it possible to detect possible hyperlinks in the content so that when the user clicks them, the web browser app will open up?
For example, let's suppose the Description property would consist of the following string:
"Welcome to Stackoverflow. You can find a quick guide at http://www.stackoverflow.com/guide. To track your questions, please visit http://www.stackoverflow.com/questions. Happy coding!"
Currently this exact string is bound on the UI, but I would like somehow to be able to detect possible links and be able to navigate to them when tapping them, just as you can using a web browser.
The text selection set to disabled is one of the requirements I have to meet, altough that could help in some way to copy-paste the link, at least.
Any suggestions are highly appreciated!
You need to parse whole HTML and hell no - don't do it with Regex like someone suggested (regular expression can't parse html) - install HtmlAgilityPack from Nuget manager (doesn't matter that is not well formatted html document, HtmlAgilityPack will do it's work).
Feel free to pick and tweak my XamlHtmlParser (not everything is all right at the moment - it's really eeearly dev stage but you can use few classes from it to parse hyperlinks, linebreaks etc..) from my open-source polish reddit-like service app implementation: https://github.com/thefex/Wykop/tree/dev_windows81_api/Wykop.ApiProvider/XamlParser.
If you want to your hyperlinks "navigate" add proper "NavigateUri" in HyperLinkNodeParser class.
Usage:
XamlHtmlParser htmlParser = new XamlHtmlParser(new DefaultHtmlNodeParserProvider());
RichTextBlock richTextBlock = ..;
var parsedHtmlBlocks = htmlParser.GetBlocksFromHtmlString(htmlLikeString);
richTextBlock.Blocks.Clear();
foreach (var parsedBlock in parsedHtmlBlocks)
richTextBlock.Blocks.Add(parsedBlock);
Btw. it seems like binding is not possible - code-behind is must be.
Related
I removed the following fields from the "s4-titletext" cell using the Manage Content Regions in SPD:
PlaceHolderSiteName
PlaceHolderPageTitleInTitleArea
PlaceHolderPageDescription
And I added "SharePoint:SPLinkButton... Visible="False"
I have published this template and have set it as the Default Master. It displays fine but when I add a web part (not in SPD), I get the error "You must specify a value for this required field" and it will not let me add/remove the web part or change any list. What did I do wrong in my customization? I followed the instructions on this post. I used Option 2 to hide the words. The reason I removed the fields is because I want to stretch our banner across the whole page and I didn't want to leave the space where the bread crumb would have been. My "s4-titletext" area looks like the pictures on the top of the page, only banner is stretched all across the top of page. I can not add a link to my page due to it being on a private server. I have asked other SharePoint experts and they are stumped as well. Thank you for your help on this.
Instead of setting visible="false", getting hiding the control using a CSS class. Set the control's class to something like 'hiddenClass' and then define your class style.
.hiddenClass{display: none;}
Customizing SharePoint masterpages is a pain since they're so sensitive. You have to use this method when hiding a lot of the out of the box controls.
Some placeholders need to be on the master page, if you remove it it will cause errors in some of the scrips.
What I recommend to you is create a hidden div and inside of it put all the placeholder you want to hide, like the example bellow.
<div style="display:none">
<asp:ContentPlaceHolder ID="TitleZone" runat="server"></asp:ContentPlaceHolder>
<div>
I have my own stack/navigation model, but I would like to have the standard Back button appear beside the header of my page.
What code do I need to make it appear?
The examples just do something like this:
void Header_Click(object sender, RoutedEventArgs e)
{
// Determine what group the Button instance represents
var group = (sender as FrameworkElement).DataContext;
// Navigate to the appropriate destination page, configuring the new page
// by passing required information as a navigation parameter
this.Frame.Navigate(typeof(GroupDetailPage),
((SampleDataGroup)group).UniqueId);
}
and it automatically shows up.
I've looked through various msdn pages but they mostly talk about the design pattern.
Thanks
In the Visual Studio project templates (aside from Blank App), you'll see the following XAML in the page
<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
so the visibility of the button is driven by whether or not there's a backstack for the application, and pageRoot here is the x:Name associated with the given Page.
Note, that the GoBack method is part of the LayoutAwarePage that you get for all of the templates other than the blank one. It sounds like you have your own version of "LayoutAwarePage" in which case you'll have to wire up whatever code makes sense to execute on a back button for your navigation model.
Keep in mind that LayoutAwarePage will the basis for a LOT of Windows Store applications, so if you deviate too much from that de facto default navigation scheme, you might confuse your users that are used to behavior in other applications. Would it make sense to extend from LayoutAwarePage perhaps, in which case you'll get the default behavior (including the Back button) and then you can add your own special sauce on top?
I wasted few hours for looking the answer and I'm very sad cause I didn't find anything usefull. I have a CMS in cloud and it provides content for diffrent devices like www site and my new windows store application.
I want to use html formating. I've already created app in c# and xaml and I'm wondering how can I display html
I was happy cause I found http://nuget.org/packages/RichTextBlock.Html2Xaml but I can't make it work. I get blank page. No text, no error, no nothing.
Can someone pls tell me how can I display html in my app ?
Use a WebView/WebViewBrush or use HTML Agility Pack and implement the styles/rendering yourself.
In WinRt app you can display html code by some ways:
Using WebView with it's NavigateToString("html content")
Using WebViewBrush and displaying it in rectangle
If you had your .html file local - you can open it with myWebview.Navigate(new Uri("ms-appx-web:///" + myPath));
You can make a screenshot of webpage by the method wich I describe here and open it as a picture.
For more info, see the WebView control sample
Does anyone know how to dynamically change the page title in Sitefinity from a regular user control?
Our scenario is simple. We have a real estate website with a search feature. On the search results page we have a control showing the search results, but we need to be able to change the Page title, description and keywords based on the search performed.
We posted on Telerik, but they gave vague answers and pointed us to incorrect objects or objects that didn't actually work.
?
Regards,
Jacques
The way I've usually done this in the past is by using an external widget template.
By mapping your widget template to an external file, you can use a full User Control (.ascx file) which means you can also run code behind.
From there it's just a matter of running something like
Page.Title = "whatever";
For more info on using an external template for Sitefinity Widgets, check out this post: http://www.sitefinity.com/blogs/joshmorales/posts/11-05-10/mapping_external_templates_for_sitefinity_4_widgets.aspx
Hope this is helpful!
I'm working on an entirely flash-based site for a client who has already been using Blogspot for his News/Homepage updates. He wants to continue updating through Blogspot, but wants the blog to automatically fill in the text box on the flash site Homepage. I'm not sure if this is possible, or how I would go about doing it.
Here is the blogspot page:
http://atmarsamps.blogspot.com/
Here is an example of what the scrolling SWF text box will be like:
http://eloquentcreative.com/
Is this possible? Any help would be absolutely amazing!
You can use URLLoader to load the page as text. I'm not sure of the best way to parse it though.
Maybe you can try looking for the CSS tag that is being used for the text in question and then grabbing the text in between those tags? There might be better ways to do this though.
Note, you can update values to the htmlText property of a text box, which will allow Flex to maintain some of the styles specified from the loaded page.