I am currently developing an application in windows phone 8.1 And I am having problems with the soft system navigation bar.
I can hide the bar, but I can't seem to find if it is visible or not.
To hide it, I could use:
ApplicationView.GetForCurrentView().SuppressSystemOverlays = true;
The problem is that some phones have it, some don't. I need to find if it is active so that I can bind the height of my VirtualizingStackPanel correctly.
Thank you,
As far as i know there is no perfect way to work with the none-hardware nav bar, and i think that your best option here is to subscribe to the ApplicationView.VisibleBoundsChanged event,
so basically what you need to do is :
set the ApplicationViewBoundsMode to UseCoreWindow so that the content will be laid out in the region occupied by the core phone window :
ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);
subscribe to the VisibleBoundsChanged event and handle you UI changes inside the handler:
ApplicationView.GetForCurrentView().VisibleBoundsChanged += handler;
//...
private void handler(ApplicationView sender, object args)
{
//handle ui changes
}
Related
I have a WPF .NET 4.6 application running on a Windows 8.1 tablet and for the last few days I've been struggling to make my app touch friendly to make it work as expected. My main problems are focus related, these affect several controls in my app. for example:
Textboxes: sometimes requires a double or triple touch in order to get input focus, they do enter a mouse over state but the caret isn't there;
ComboBoxes: takes a couple of touches in order to open it, and once touching an item in order to select it the combo stays open with the newly selected item highlighted;
Buttons: takes a couple of clicks to run the connected command and stay in mouse over state;
Keyboard support
There are a couple of approaches I tried while searching for a solution that each has it's own downsides:
Removing the tablet support for the entire application (taken from here). this one solves most of the focus problems mentioned above but makes scrolling (and I guess some other Tablet related functionality that I haven't found yet) unusable.
Explicitly activating the keyboard when required (Example here). Focus problem remains, scrolling works as expected
I also tried to remove all styles and tested everything on 2 different tablets from different manufacturers but without success
Recently Microsoft announced that "Touch is better" But I couldn't find any official documentation about the best way to approach this subject.
Any suggestion on how to make my application work better with touch would be a big help.
I was able to remove mouse over state by using following behavior:
public class TouchDeviceMouseOverUIElementFixBehavior : Behavior<UIElement>
{
protected override void OnAttached()
{
AssociatedObject.StylusUp += AssociatedObject_StylusUp;
}
protected override void OnDetaching()
{
AssociatedObject.StylusUp -= AssociatedObject_StylusUp;
}
private void AssociatedObject_StylusUp(object sender, StylusEventArgs e)
{
var control = sender as FrameworkElement;
if (control != null)
{
if (!VisualStateManager.GoToElementState(control, "Normal", true))
{
VisualStateManager.GoToState(control, "Normal", true);
}
}
}
}
I'm new into WPF and have a problem I can't seem to find a solution for.
I'm writing a G19 (Keyboard) applet. This Keyboard has a 320x240 display attached, which you can access with C#.
I'm using WPF for this, because I don't need to do any GDI drawing anymore and use the normal controls instead.
So. It works as I wish. Everything draws properly except one UserControl. I have downloaded this control -> http://marqueedriproll.codeplex.com/
In the designer, the control works, the Loaded event get's fired and the animation is good.
When I run my application, I just see the label and the text. The animation does not work, and the Loaded event does not fire anymore.
Any help is appreciated.
The main function is my wrapper. The wrapper is already a Usercontrol and displays plugins which are switchable. This wrapper has the Frame Control(Wrapper1). I replace the content of this frame every time I switch the plugin.
public void SetPlugin(IPlugin plugin)
{
if (this.MainPlugin != null)
{
this.MainPlugin.OnHide();
((UserControl)this.MainPlugin).Visibility = System.Windows.Visibility.Hidden;
}
this.MainPlugin = plugin;
((UserControl)this.MainPlugin).Visibility = System.Windows.Visibility.Visible;
this.MainPlugin.OnShow();
this.Wrapper1.Content = this.MainPlugin;
}
I think it's the right approach to handle a plugin system that way. The plugin get's drawed on my keyboard.
What I don't understand is why the usercontrol only works in the designer view and not in the running application.
The basic code of the scrolling label is so:
public MarqueeText()
{
this.Loaded += new RoutedEventHandler(MarqueeText_Loaded);
InitializeComponent();
canMain.Height = this.Height;
canMain.Width = this.Width;
}
void MarqueeText_Loaded(object sender, RoutedEventArgs e)
{
StartMarqueeing(_marqueeType);
}
I don't see a reason why it doesn't work. Actually Ive always found a way to fix a problem but this time I see nothing.
Thanks in advance. Your help is really required today.
Have a great saturday! :)
I am guessing you are rendering to a bitmap target, rather than onscreen. If you are using RenderTargetBitmap, you have a couple of responsibilities. You need to set both a presentation source, and make sure you run events on the dispatcher.
Normally, App.xaml or Application.Run does this for you, but if you are not using a Window, you are on your own.
See this related question for details.
I am working on an alternative browser for Internet Explorer Mobile on Windows Phone. My problem is that I also want a progress bar displaying how far a page has loaded just like Internet Explorer mobile has but I cannot find any property or event on the WebBrowser control that tells me how far a page has loaded. Is there something that I can do?
PS. This project is mainly for Windows Phone 8 so some WP 8 exclusive apis can be used but WP7 support would also be nice.
A loading bar is as simple as determining the total number of kb's to be downloaded at the start of the request and then updating the progress bar with the current downloaded kb's (as a percentage).
Luckily, you can just add a progressbar like this:
<ProgressBar Foreground="Green" x:Name="ProgBar" Visibility="Collapsed" IsIndeterminate="True" Height="10" HorizontalAlignment="Left" Margin="10,66,0,0" VerticalAlignment="Bottom" Width="460" />
You then need to modify your main page.cs to incorporate the event:
void Browser_Navigating(object sender, NavigatingEventArgs e)
{
ProgBar.Visibility = Visibility.Visible;
}
void Browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
ProgBar.Visibility = Visibility.Collapsed;
}
You can read how this all works ON THIS LINK. (This link shows a tutorial which will exactly explain to you how to accomplish this progress bar)
What you could also do is make use of the Windows phone 8 Progress Indicator as they do in this example.
Mind you that in general, in C#, (or any programming language) you can ask for the total number of kb's (e.g. with WebClient) like this. Then you could write a timer that checks the current amount of downloaded kb's and update the progress bar every 0.x seconds.
I hope that helps you out. Good luck!
Update
If you search for page loading bar c# you get multiple useful links that show you how to build a loading bar for a webbrowser.
For example:
http://code.msdn.microsoft.com/wpapps/Custom-Indeterminate-833d783d
http://github.hubspot.com/pace/docs/welcome/
How to make progress bar works while web browser navigating?
How to show progressbar until WP8 WebBrowser control loaded the URL?
But especially this one could be very useful:
http://tekkieblog.com/develop-simple-web-browser-with-progress-bar-using-csharp/
It states that you can use the built-in Status Strip control to get the required loading bar. The step to windows phone shouldn't be all that big from this C# snippet.
The proposed method is:
This simple Tutorial will help in adding up a Progress Bar to your Web browser using C#. In the design view, drag and drop the Status Strip control from the Tool box. The Status Strip control will be displayed at the bottom of your Form. Select the Status Strip control on the form. Click the Drop Down list and select Progress Bar. The progress bar control will be displayed in your Form.
Right click the Web Browser Control in the design mode and select Properties and then select events in the Properties window and move to Progress Changed event and double click it. Add the following code snippet:
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
ProgressBar.Maximum = Convert.ToInt32(e.MaximumProgress);
ProgressBar.Value = Convert.ToInt32(e.CurrentProgress);
}
So what they basically do is convert the current progress to a number such that you get control over the percentage.
You can also do it differently:
I HIGHLY RECOMMEND you watch this link: http://www.youtube.com/watch?v=KHQCtunR2QI
That video must definitely answer your question!
void Browser_Navigating(object sender, NavigatingEventArgs e)
{
ProgBar.Visibility = Visibility.Visible;
}
void Browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
ProgBar.Visibility = Visibility.Collapsed;
}
you have to collapse visiblity of progressbar for more events
navigation_failed event
browser loaded event not navigated event
Would be really helpful if someone could tell me which event handler I need to use when a webpage is/has loaded using Windows 8.1, as well as the C# code for making the web page progress show up in the progress bar.
EDIT: Apologies if this isn't clear. This is for windows store apps rather than windows forms. I'm coding with C#, and i'm wondering how to implement the progressbar to the webbrowser(webview) so that it is updated dependent on the progress of the loading page.
Thanks.
See these answers:
WPF WebBrowser: How I do access progress and new window events
Determine if WPF WebBrowser is loading a page
If you are with no time, you can simply put a Indeterminate Progress bar, until you code a refinated Progress code.
<ProgressBar Name="pb1" IsIndeterminate="True" Visibility="True" />
void theBrowser_Navigated(object sender, NavigationEventArgs e)
{
//Console.WriteLine("Webpage Loaded !!");
pb1.Visibility = Visibility.Collapsed;
}
I have a full screen WPF application built for a touch monitor, and I have some Listboxs on the main screen.
When I flick the 'Listbox' it scrolls fine, but when it gets to the end of the list, the entire application gets pulled down from the top of the screen, can I stop this behavior somehow?
Has anyone else seen this?
Yes, that default behaviour of the ListBox (or rather, the ScrollViewer inside the default ListBox template) is weird - when I first came across it, I thought it must be a practical joke. In fact, it's really hard to find any documentation about it - but it is briefly mentioned here:
The ManipulationBoundaryFeedback event enables applications or components to provide visual feedback when an object hits a boundary. For example, the Window class handles the ManipulationBoundaryFeedback event to cause the window to slightly move when its edge is encountered.
So, a way around it is to handle ManipulationBoundaryFeedback on the ListBox, and set Handled to true:
<ListBox ManipulationBoundaryFeedback="OnManipulationBoundaryFeedback">
// ...
</ListBox>
Code-behind:
private void OnManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
{
e.Handled = true;
}