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.
Related
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..
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
I am using Caliburn Micro for a Windows Phone app. I have a hyperlink control for which I want to bind the click event to my View Model. Below is the sample code
XAML, MyPage.xaml
<TextBlock>
<Run>Got to</Run>
<Hyperlink micro:Message.Attach="[Event Click] = [Action OpenAnotherPage]">
My Page</Hyperlink><Run Text="."></Run></TextBlock>
ViewModel MyPageViewModel.cs
public void OpenAnotherPage()
{
// some code
}
When I tap on the link, I get an exception
System.Exception: No target found for method
What could be the problem?
Update 1: Tried setting micro:Action.TargetWithoutContext="{Binding ElementName=MyPage, Path=DataContext}" on the Hyperlink control, but it didn't work
Give the TextBlock a name and use that as the ElementName since you have the Hyperlink nested into that control. Then Update1 should work.
Try following XAML (untested):
<Hyperlink>My Page
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<ec:CallMethodAction TargetObject="{Binding}" MethodName="OpenAnotherPage" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Hyperlink>
The namespaces are following (you'll need to reference those 2 assemblies, they're by Microsoft and shipped with MS Expression Blend)
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
Im trying to print visual (or anything related) with pagination from a WPF element. I'm using a MVVM Pattern development.
This is my visual layout. Where the user can scroll to view the pages.
<ScrollViewer>
<StackPanel x:Name="Wrapper">
<StackPanel x:Name="PageOne" />
<StackPanel x:Name="PageTwo" />
</StackPanel>
</ScrollViewer>
The visual is passed via a Command Binding on a button.
<Button Command="{Binding PrintCommand}" CommandParameter="{BindingElementName=Wrapper}"
The visual is passed to the print Method.
PrintDialog newDialog = new PrintDialog();
newDialog.PrintVisual(MyVisualName, "Printing is Fun!");
I would like to paginate the two pages (and more), and also scale the visual to the paper, Whilst holding true to MVVM style.
Thanks.
In the end i used Flow Inline Flowdocument.
<FlowDocumentScrollViewer>
<FlowDocument x:Name="EntirePage">
<Section>
<BlockUIContainer>
</BlockUIContainer>
</Section>
</FlowDocument>
</FlowDocumentScrollViewer>
Every control within the BlockUIContainer is printed. (A Lot of page size and margin fiddling is required to get pagination working perfectly) Section/ BlockUI does pagination somewhat automatically - so for me page one was one BlockUi and Page two was another - Comment/Ask for more info
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<i:InvokeCommandAction Command="{Binding PrintCommand}" CommandParameter="{Binding ElementName=EntirePage}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
I passed the FlowDocument via a command Parameter.
printCommand = new RelayCommand(p => PreparePrint((FlowDocument)p));
(pageVisual being the flow document passed via the command param)
Then between a few of methods i get to;
IDocumentPaginatorSource idocument = pageVisual as IDocumentPaginatorSource;
printDialog.PrintDocument(idocument.DocumentPaginator, "Printing Machine : " + Machine.Serial);
If you are confused and need help (much like i was) then don't hesitate to comment/ask questions.
Please forgive this stupid question. (I'm originally an ASP.NET programmer.)
I'm trying to add a telerik context menu to a textbox control in the code behind.
Adding it in the xaml is very easy (this works)
<TextBox AcceptsReturn="True" Text="{Binding Mode=TwoWay, Path=Description}" TextWrapping="Wrap" x:Name="txtIssues" Width="280" Height="100" VerticalScrollBarVisibility="Auto">
<telerikNavigation:RadContextMenu.ContextMenu>
<telerikNavigation:RadContextMenu x:Name="contextMenu"
ItemClick="ContextMenuClick">
<telerikNavigation:RadMenuItem Header="Set Vista as Background" />
<telerikNavigation:RadMenuItem Header="Set Beach as Background" />
<telerikNavigation:RadMenuItem Header="Set Forest as Background" />
</telerikNavigation:RadContextMenu>
</telerikNavigation:RadContextMenu.ContextMenu>
</TextBox>
However I would like to completely add the the control from c# code and I can't find a why to add a control to a textbox. I've been looking for something like "txtIssues.Children.Add" but there doesn't seem to be an option.
First its best you understand that you are not adding a control to the TextBox. The RadContextMenu.ContextMenu is not a control it is an attached property.
Funnily enough the Telerik documentation describes adding a context menu to a textbox in C#. See Working with the RadContextMenu. Sometimes "RTM" is actually good advice.