Tap button to copy text? - c#

How do I implement my app to copy a certain set of text for Windows Phone 8 when I tap a button?
E.g. tap this button to copy a sms template
Something like that
I want to copy text from the app itself

Check this tutorial about copying text to Windows Phone 8 clipboard
Extras from it - assuming selectedText is text to copy:
DataPackage d = new DataPackage();
d.SetText(selectedText);
Clipboard.SetContent(d);

Related

Keyboard shows up after textbbox clicked ,then the mobile view scrolls wrong

The websites are MVC C# with kendo UI. It is no problem with the computer and ios phone(iphone) devices.But on Android, if the user clicked the website's textbox, the keyboard shows up and the websites scrolls, the user can not see the focus of the textbox. On the computer and ios phone, the user clicks the textbox,the view stands still and does not scroll. So I use the following CSS code on javascript of cshtml to fix:
#media screen and (max-width: 580px) and (max-height: 350px)and (min-height: 200px){
html {
display:block!important;
overflow:hidden!important;
}
}
If the textbox has clicked, the keyboard shows up and makes view smaller. While the view is smaller, the view can't scroll and it reveals the same correct view with a computer device and ios phone. But, it is only correct on some Android devices.So how can I use CSS to make the view of the website does not scroll when the keyboard shows up on Android phone device? Thanks!
The following is success case in ios phone device:
1.website
2.select event and open event window
3.Scroll down to the textbox
4.scroll down the textbox and focus the the end part of the text in textbox ,then keyboard shows up.It's no problem on this ios phone case ,but on android phone case,it will scroll up to wrong place.

Windows Store aps - select text and tap

I have a problem with TextBlock text selection (Windows Store apps, C#).
If I set IsTextSelectionEnabled = True, then I can't Tap on the text.
I need to be able to open popup on taping text and select this text, but it seems like I can't do both.
Is there a way to have both - Text Selection and Tap - for one TextBlock?
Edited: I need Text Selection to be able copy text.
Edited: TextSelection and Copy feature works for multiple word text, where not every word is tappable.
Set TextBlock property IsTextSelectionEnabled = True
Set text to TextBlock, using TextBlock.Inlines:
textBlock.Inlines.Add(new Run() { Text = "Click " });
Hyperlink hyperlink = new Hyperlink();
hyperlink.Inlines.Add(new Run() { Text = "here" });
hyperlink.Click += hyperlink_Click;
textBlock.Inlines.Add(hyperlink);
But if whole text is tappable, this solution doesn't help.
If I set text like this:
textBlock.Text = "Click here";
textBlock.Tapped += textBlock_Tapped;
Then I can't tap text. I can only copy this text.
If I set text like this:
Hyperlink hyperlink = new Hyperlink();
hyperlink.Inlines.Add(new Run() { Text = "Click here" });
hyperlink.Click += hyperlink_Click;
textBlock.Inlines.Add(hyperlink);
Then I can't copy text. I can only tap on it.
Using IsTextSelectionEnabled will handle Tap event by itself. So you will not have ability to use both. If you want to show PopUp when text get selected you can use SelectionChanged event.
UPDATE
If you just need user to be able to copy any part of text you don't need to create any PopUp. Just enable IsTextSelectionEnabled and user will be able to select any text part, press right mouse button and copy text using TextBlock's own PopUp. And in case it's touch or pen interaction this PopUp will be shown right after user selects text.

How to adjust screen when keyboard open in windows phone 8?

I am working in Windows phone 8. In One of the pages of my app there is a LongListSelector and under it there is a TextBox. When the TextBox get focused then keyboard is opened. As the keyboard is opened then the LongListSelector is shifted up by keyboard height. If I maintain the margin of the LongListSelector by keyboard's offset then some of the items of LongListSelector go under the keyboard.
All I want to do is when keyboard is shown then margin will be updated and the previous focused item of the LongListSelector should not go under keyboard. Here I don't want to use ScrollTo() function to scroll a specific item of LongListSelector.
Any suggestion or help will be appreciated.
Here is an example of workaround. Though this code is for WP8. You will have to make some changes to make this working for WP8.1 like :
Tap in xaml will be replaced by Tapped.
((App)Application.Current).RootFrame.RenderTransform = new CompositeTransform();
will be replaced by
Window.Current.Content.RenderTransform = new CompositeTransform();
Dispatcher.BeginInvoke(() => {}will be replaced by
CoreDispatcher dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{}
let me know if you face any issue.

Hyperlink or textblock with icon and text in windows phone 8

How can i put '<3 like' in a hyperlink in windows phone 8? <3 will be appbar icon.
I have tried to put image in text block but i could not succesful.
Look at the applicationbar sample that is in every new app you create. There you can see how an image is inserted as the background for a button. When the button is clicked you can use the webclient in windows phone to start the hyperlink.
For doing th hyperlink you have to look into how to create an URL, also. But it is pretty simple.

Message Box yesnoButtons in windows phone 7.5

In window phone 7.5 . I want to use yes no buttons in message box . But there is no option for yes no buttons in message box. How can i use with yes no buttons or other alternate to show caption (OK =yes and cancel =no)
Please help me.
Thanks in advance.
You can use the Coding4Fun MessagePrompt to create Yes/No message with custom buttons in this way:
MessagePrompt messagePrompt = new MessagePrompt();
messagePrompt.Message = "Some Message.";
Button yesButton = new Button() { Content = "Yes" };
yesButton .Click += new RoutedEventHandler(yesButton _Click);
Button noButton = new Button() { Content = "No" };
noButton .Click += new RoutedEventHandler(noButton _Click);
messagePrompt.ActionPopUpButtons.Add(noButton);
messagePrompt.ActionPopUpButtons.Add(yesButton );
messagePrompt.Show();
Another option is to use the Guide class from the XNA framework. There is a BeginShowMessageBox method giving you the option to pass in whatever strings you wish for the buttons.
The other option is to use MessagePrompt from Coding4fun toolkit and customize according to your needs
Yes, the problem with WP MessageBox is that it only supports the OK and OKCancel MessageBoxButton, which means that you’re limited to either an ok button or an ok and a cancel button. The YesNo and YesNoCancel enumeration values are not supported.
Basically you can try to display a semi-transparent blanking layer over the page content, and then display a custom message box on top of that. Here, you can find a complete sample.
Another option is to use a custom library like Windows Phone Assets.

Categories

Resources