I'm writing a WP 8 app and I want to display a tooltip when mouse hovers over a button or switch. I tried the following code:
ToolTip toolTip = new ToolTip();
toolTip.Content = "Flip switch to turn on.";
ToolTipService.SetToolTip(onOffSwitch, toolTip);
Also I tried to define it in XAML:
<Button Content="Msgs"
HorizontalAlignment="Left"
Margin="59,651,0,0"
VerticalAlignment="Top"
Width="108"
ToolTipService.ToolTip="tip"/>
But none of these work. When I point cursor on the control there is no tip. What did I miss?
First there is no mouse hover in windows phone 8. however if you want to add tooltips, you can refer this link
You can not add a tooltip for Windows Phone controllers. There is no way to simulate or detect a mouse/finger hover in Windows Phone.
Related
To edit non client area, I need to create my own title bar in my WPF app setting WindowStyle to none and non resizable. I have created my own caption button but it don't get the feel of Windows 11. When we hover mouse over middle button we can see a window snap option as seen in this image
Is there anyway to achieve this, I mean there should be, I even tried many nuget packages having custom Window, but I didn't got what I wanted.
All I want is to get a Window with System's default Window behavior but can have a Sliding panel from left which is even over title bar, somewhat like this but I dont want to make title bar myself I want systems default.
Even if its custom made I want it perfectly same as System's Default Window
Its already in many Windows apps :- Clock ,Mail, Even Word .
In each of this apps left panel is over title bar and even preserving the system's default window behavior, Please Please Please tell me I have been looking for it from 2 months.
Nuget Package I tried : https://github.com/Kinnara/ModernWpf
code I tried:
<Window '''''default code ''''
''''''''''''''''''''''
''''''''''''''''''''''
''''''''''''''''''''''
WindowStyle="None"
ResizeMode="NoResize">
<!--This created blank window with no title bar-->
<Grid>
<!--creating title bar-->
<Grid ''''' code so grid appear as title bar on top
and we can drag too>
<!--caption buttons-->
<button ''''button with '-' and style as
windows caption button and minizimes window
when clicked'''''''''''/>
<button ''''button with 'square symbol' and style as
windows caption button and maximize or restore window
when clicked'''''''''''/>
<button ''''button with 'close symbol' and style as
windows caption button and close window
when clicked'''''''''''/>
</Grid>
<!---
rest of the code
""""""""""""""""""
"""""""""""""""
""""""""""""""""--->
</Grid>
<Window/>
I have created a Button. When the button is pressed a Popup appears. The Problem is, the popup is on the top left side while the button is on the Right side.
What do I have to do in XAML to make the popup appear under the button?
I even tried to place the popup in the top rightcorner via HorizontalAllignment. The Problem then is that the popup is outside my program (Right next to it. Literally).
just use the new DropDownButton in the new winUi library, it has a build in popup which comes under the button and the button even has an arrow on right side, it is perfect for your scenario. just use the nuget package, docs are here : https://learn.microsoft.com/en-us/uwp/toolkits/winui/
You can use the Flyout which is attached to specific controls including Button, then You can use the Placement property to specify where a flyout appears: Top, Left, Bottom, Right, or Full. So you can use the Placement property to specify the flyout to appear under the button as the following code.
<Button Content="Click me">
<Button.Flyout>
<Flyout Placement="Bottom">
<TextBlock Text="This is a flyout!"/>
</Flyout>
</Button.Flyout>
</Button>
By the way, as we suggestion in the Remark part,
Do not use a Popup if a Flyout, MenuFlyout, ToolTip or ContentDialog (MessageDialog for a Windows 8 app) is more appropriate.
I am building a small UWP app in C#, to scan EAN barcodes and assigning descriptions to it.
The default action when I click on my textboxes is to start speech recognition. And I want the textbox to go into manual editing mode, when I rightclick it (long tap on touch-devices).
Therefore I'd like to remove the default context-menu for my TextBox control.
I know how to do this in Windows Forms applications (just add an empty TextBox.ContextMenu with visibility=Collapsed).
Can somebody here help me please, and tell me how to remove the default "Paste" context menu (or "flyout") entry from my textboxes?
Is this even possible?
Screenshot: UWP default Textbox context menu
You can to disable context menu of TextBox, ContextMenuOpening event will help you. Below is the whole code.
XAML:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<TextBox x:Name="textBox" Text="test" Height="80" Width="100" ContextMenuOpening="TextBox_ContextMenuOpening" />
</Grid>
C#:
private void TextBox_ContextMenuOpening(object sender, ContextMenuEventArgs e)
{
e.Handled = true;
}
I'm currently use WPF and WIN8 table mode design some software.
There is some place need input some number use Textbox.
I use some way to finally show the Keyboard: http://brianlagunas.com/showing-windows-8-touch-keyboard-wpf/
But I found, sometimes the Keyboard will cover some item on the bottom or middle after it show up.
For example: I have 5 Textbox on the screen
<Grid>
<TextBox HorizontalAlignment="Left" Margin="500,95,0,0" Height="23" Width="120"/>
<TextBox HorizontalAlignment="Left" Margin="500,295,0,0" Height="23" Width="120"/>
<TextBox HorizontalAlignment="Left" Margin="500,495,0,0" Height="23" Width="120"/>
<TextBox HorizontalAlignment="Left" Margin="500,695,0,0" Height="23" Width="120"/>
<TextBox HorizontalAlignment="Left" Margin="500,800,0,0" Height="23" Width="120"/>
</Grid>
But now I found if the Keyboard get focus on some Textbox not on the top, Maybe on the middle or maybe on the bottom. The Keyboard will cover it. I even can't see what I am typing in.(Like the Picture)
So Is there any good way to fix it ? Thank you.
PS: I've try to drag the Keyboard, but Looks like it's not a good solution,
because some Textbox on the middle, Keyboard will still cover which Textbox on the middle.
to make this possible you have to do something similar to this.
1) your view must be scrollable (inside a scrollviewer)
2) textbox.BringIntoView() would normally work, but with the current solution you are using.. it won't be possible because the keyboard show is called after textbox.BringIntoView()...
See my post in this thread
Show & hiding the Windows 8 on screen keyboard from WPF
It's a complete implementation of showing/hiding the win 8 keyboard and auto focus when the textbox is focused and you keep all the wpf touch functionality that you lose when you are using inkDisableHelper
The keyboard can be moved used by the user so that it is not covering. Its best to let the user handle the situation this way than try to re-engineer the Windows experience
The virtual keyboard is supposed to automatically move the focused TextBox into view when the keyboard is displayed.Microsoft says this behavior is automatic but can be overridden with EnsuredFocusedElementInView(example here)
I think this can be solved by adjusting the Y transition
_offSet = 0;
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing += (s, args) =>
{
_offSet = (int)args.OccludedRect.Height;
args.EnsuredFocusedElementInView = true;
var trans = new TranslateTransform();
trans.Y = -_offSet;
this.RenderTransform = trans;
};
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding += (s, args) =>
{
var trans = new TranslateTransform();
trans.Y = 0;
this.RenderTransform = trans;
args.EnsuredFocusedElementInView = false;
};
inside the constructor.
Also you can take a look at
1)Tips and Tricks for C# Metro developers: Handling the virtual keyboard
2)Popup stays under virtual keyboard in stead of scrolling up with the bottom appbar
I am trying to disable the scroll functionality in the phone:webbrowser in my windows phone 8 application. The reason i wan't to do this is that I want to place a stackpanel with items underneath the webview, but still show the whole webpage.
To accomplish this I get the total height of the webpage and set the height of the webbrowser to the webpage height. This will be done through adding javascript to the webbrowser. The webview will now have the total webpage and the items underneath it and both of those items are in a ScrollViewer so you can scroll through the page.
The only problem i have right now is that you can scroll the webbrowser so you cant scroll the scrollviewer. anyone got an idea how to fix this?
<ScrollViewer
Grid.Row="1"
Margin="0,0,0,0">
<StackPanel
x:Name="ContentPanel"
Margin="0,0,0,0">
<phone:WebBrowser
x:Name="webView"
Navigating="WebBrowserNavigating"
LoadCompleted="WebBrowserLoadCompleted"
ScriptNotify="browser_ScriptNotify"
IsScriptEnabled="True"/>
<StackPanel
x:Name="CouponHolder"
Margin="0,5,0,0">
</StackPanel>
</StackPanel>
</ScrollViewer>
I also looked at other questions, but they didnt work out for me:
http://www.codeproject.com/Tips/718671/Disable-WebView-scrolling-in-Windows-Store-Apps
And I see allot of people give awnsers like VerticalScrollBarVisibility="Disabled" but this doesnt work, like the suggests it will only hide the visibility...
you can disable all manipulation with WebBrowser control by setting IsHitTestVisible="false". The disadvantage is that you can't press Links, Navigate and so on.
If you want just to disable scrolling than take a look at this blog post:http://www.scottlogic.com/blog/2011/11/17/suppressing-zoom-and-scroll-interactions-in-the-windows-phone-7-browser-control.html
You can Find that the VisualTree of WebBrowser control looks like:
\-WebBrowser
\-Border
\-Border
\WebBrowserInteropCanvas (New in Windows Phone 8, missing in WP7)
\-PanZoomContainer
\-Grid
\-Border (you need access this one)
\-ContentPresenter
\-TileHost
You can get the last Border in VisualTree, and subscribe to ManipulationDelta, ManipulationStarted and ManipulationCompletedEvents. And set e.Handled = true; In event handlers. Be careful with that. For example where is no equialent for this code in Windows 8.1 and Windows Phone 8.1 (Runtime).
This hack will cancel scrolling of webbrowser while user can interract with entire web page, but you won't be able to suppress manipulation to put webbrowser in scrollviewer.
In general I don't think that you could achive ideal user experience if you put WebBrowser inside ScrollViewer
After hours of searching this project finally solved all our webview problems in Windows Phone 8.1 (bounce, touch, auto height etc.):
https://github.com/romshiri/sizeable-webview