ContextMenu Hyperlink in RadRichTextBox WPF - c#

When i add a Physical path in a Hyperlink from ContextMenu of RadRichTextBox i see http:// getting added extra but in only in one scenario.
I tried adding the link like below(The folder name has no spaces at the last),
the above gives me correct URL.
When i add the link with a folder which as spaces at the last like,
I get the output like below when i edit the Hyperlink and see,
//XAML
<telerik:RadRichTextBox x:Name="ss" Grid.Column="0" Grid.Row="1" telerik:StyleManager.Theme="Windows8" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" FontWeight="Normal" AcceptsTab="True" telerik:HtmlDataProvider.Source="{Binding Notes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsSpellCheckingEnabled="True" HyperlinkClicked="ritFnBNotes_HyperlinkClicked" DocumentInheritsDefaultStyleSettings="True" Height="150" CommandExecuting="ritNotes_CommandExecuting" IsReadOnly="{Binding EnableForEdit, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource InverseBool}}" DocumentContentChanged="Notes_DocumentContentChanged">
<telerik:RadRichTextBox.SelectionMiniToolBar > <telerik:SelectionMiniToolBar telerik:StyleManager.Theme="Windows8" />
</telerik:RadRichTextBox.SelectionMiniToolBar> <telerik:RadRichTextBox.Document>
<telerik:RadDocument>
<telerik:Section>
<telerik:Paragraph FontSize="8" LineSpacing="0" LineSpacingType="Exact"></telerik:Paragraph>
</telerik:Section>
</telerik:RadDocument>
</telerik:RadRichTextBox.Document>
<i:Interaction.Triggers>
<i:EventTrigger EventName="DocumentContentChanged">
<i:InvokeCommandAction Command="{Binding FnBNoteChangeCommand, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</telerik:RadRichTextBox>
I'm not sure how does the http:// append into the URL where i upload a physical path. Now i need to get rid of the http://.
Someone help me with this.

I am afraid this is a known issue with RadInsertHyperlinkDialog. When the URL doesn't match a regular expression, an "http://" is added to the string.
As suggested by the official Telerik support, you could create a custom dialog to work around this behaviour. Please refer to the following link for more information: http://www.telerik.com/forums/radrichtextbox-hyperlink-dialog-issue

Related

How to use a font unicode that is stored in c#

I have a list of objects called SidebarItems, this list may change according to what Module the user is in. I have downloaded and got Font Awesome Pro working in my application, However I must use the Unacode to access the correct icon inside the font.
The SidebarNavItem
public record SidebarNavItem(string Title, string ViewName, string IconUnicode);
public class SidebarItems:IReadOnlyCollection<SidebarNavItem>
{
//Left this out for brevity
}
The Xaml That its being used
<Button Style="{StaticResource LabeledIconButton}"
Content="{Binding IconUnicode}" Grid.Row="0"
behaviors:ButtonBehavior.Label="{Binding Title}"
Command="{Binding NavigateCommand}"
CommandParameter="{Binding ViewName}"/>
This is what I'm getting but when I type it into the button, I get this:
<Button Style="{StaticResource LabeledIconButton}"
Content="" Grid.Row="0"
behaviors:ButtonBehavior.Label="{Binding Title}"
Command="{Binding NavigateCommand}"
CommandParameter="{Binding ViewName}"/>
How can I store these codes in SidebarItems?
Replace &#x with \u and remove the trailing ; from the string value returned from the property.
So  becomes:
public string IconUnicode => "\uf319";

On clicking Gridview row update another control

I have data coming from the service that has 7 columns. I can show them all in the grid view but I like to know how to show 2 of those columns in another control may be textblock.
So when someone clicks on the row, the second control will be updated with information in the other two columns.
I tried to use this in my MVVM
</ListView.View>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding OnRowClickCommand}" CommandParameter="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListView>
Has anyone tried to do this before ? Any examples would be great help.
Turns out it was very simple.. Here it is if anyone else wants to know. Did not need event handler etc.
<TextBlock Text="{Binding ElementName=ListViewName,Path=SelectedItem.Column}"/>
However I am not sure currently how I can conditionally show a label for this information..

Use converter without path

How can I use a converter without a binding path? I've got some radio buttons and would like to have a converter that is passed a string and that then returns whether or not a checkbox is checked:
<RadioButton IsChecked="{Binding Converter={StaticResource LanguageToBoolConverter}, ConverterParameter='de_DE'}" Command="{Binding ChangeLanguageCommand, ElementName=LangSelector}" CommandParameter="de-DE">
However, I get the error message Two-way binding requires Path or XPath.
In such case you need to specify path to current DataContext
IsChecked="{Binding Path=., Converter={StaticResource LanguageToBoolConverter}, ..."
From MSDN:
Optionally, a period (.) path can be used to bind to the current source. For example, Text="{Binding}" is equivalent to Text="{Binding Path=.}".

Binding in page navigation

I have another question with windows phone 7 dev. I'm creating listbox with items and one textblock, which is something like link to another page. Each link will have another "page" variable value.
<TextBlock Tap="TextBlock_Tap" Foreground="#FF40AA2F" Text="View details">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<ec:NavigateToPageAction TargetPage="/details.xaml?page={Binding Index}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
But it doesn't work with current value in targetpage, because Visual Studio taking it like normal string. How can I embed this binding in page variable? Thank you
Try using StringFormat:
<ec:NavigateToPageAction TargetPage="{Binding Path=Index, StringFormat='/details.xaml?page={0}'}" />
Do the navigation, not on a trigger but in the code behind of the MouseLeftButtonDown event of the Text Block and extract the target page from the current selection of the listbox.

Editing child objects of a combo box using c# and Wpf

Backgorund
I am currently writing a program that allows a user to select a manufacture from a combo box. The combo box is created in wpf using the following wpf code segment:
<ComboBox Height="23" Margin="40.422,128.423,229.908,0" Name="itemProductManufacture" ToolTip="Click to open drop down menu" VerticalAlignment="Top" Text="Select A Manufacture" SelectionChanged="itemProductManufacture_SelectionChanged" DropDownOpened="itemProductManufacture_DropDownOpened">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ManufactureId}" Width="0"/>
<Image Name="itemManufactureImage" Source="{Binding ManufactureImage}" Height="15" Width="70" Stretch="Uniform"/>
<TextBlock Text="{Binding ManufactureName}"/>
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
The data is provided form a database and each entry has a Image, a name and an Id (intentionally not shown)
Problem
I am trying to code the behaviour of the combo box so when it is open the image height is 50 and when it is closed it is 15 this is so the image is larger when it is first displayed and then smaller once selected so it doesn't take up too much space on the form.
I have tried editing the image propities using code but am unable to accsess it using its name or any other children of the combo box.
Thanks
Jonathan
As you are using data template you won't be able to access the directly by its name.
Try something like this -
Image image = this.itemProductManufacture.ItemTemplate.FindName("itemManufactureImage", this) as Image;
One thing I am not clear is whether you want to change image size for all the items or the selected one? If you need to access the image for a particulat item in combobox you may have to use the ItemContainerGenerator.ContainerFromItem, as explained in following posts -
WPF - ItemsControl - How do I get find my "CheckBox" item that is in the ItemTemplate?
http://www.sitechno.com/Blog/HowToUseAttachedPropertiesAsAnExtensionMechanismForACheckedListbox.aspx
look at this, To know the various ways of finding controls - How can I find WPF controls by name or type?
You can edit image properties from code using binding. Or you can use triggers in Datatemplate. When comboboxitems checked properties change, you can change height property of corresponding image
Try this:
<Image Height = "{Binding Path=IsDropDownOpen,
RelativeSource={RelativeSource FindAncestor,
AncestorType={x:Type ComboBox}},
Converter={StaticResource myBoolToHeightConverter}}" />
An example for Converter here

Categories

Resources