UWP SplitView CommandBar content binding - c#

In my app i have a SplitView and set the content as Frame for each page. Each page contains its own CommandBar. This works without issue. Now i am creating VisualStates for a mobile view. In it i want to hide the PlitView in the closed state (inline). But now i need a way to add only the "HamburgerButton" (in my case a RadioButton), on the top, for opening the inline SplitView. I have done it also, but the "HamburgerButton" is overlapping each pages Text on the CommandBar. So what is the best solution, create only one CommandBar on the MainPage (where my SplitView is) and bind the content, or create a CommandBar for each Page?
Best regards

I think creating one CommandBar in the MainPage and binding the content may requires more work. Don't forget that you may need to bind the Primary and Secondary Buttons too.
If you want to use a CommandBar in each page and one HamburgerMenu in MainPage, you can try this method.
Create a separate top Row in the Grid for the CommandBar to occupy.
Horizontally stack a transparent Rectangle of width equal to your "HamburgerButton" along with the CommandBar and place it in the above created row.
Create VisualStates to trigger on Phone and set the visibility of the Rectangle accordingly to shift the CommandBar to the right.
Check out Template10 PageHeader Control (Search for "VisualStateNarrow" and "Spacer" in particular). If you are not particular about developing these boilerplate code yourselves, check out Template10. It has many helpful controls developed by the community. Please pardon me if you already knew about this.

You can creat the Page TOP bar and in MainPage use the splitview.

Related

C# WebBrowser anchoring

So I am working on a browser using Visual Studio 2013 C# Windows Forms Application. I want to have 2 WebBrowser Object opened in the same time, in the same application, however if I try to anchor them they look like so:
The first one is anchored to left top bottom and the second one is right top bottom, if I anchor them on the other side too to cover the rest of the screen one WebBrowser goes above the other one so only one is visible now and fullscreen however I would like to have them together each one covering the other half of the screen.
Thanks for your time!
The most simple approach would be using a TableLayoutPanel control having two columns which width of them set to 50%. Then it's enough to put each WebBrowser control in a cell and set Dock property of browsers to Fill. This way each browser will occupy half of the form in any size. Also the Dock property of table layout panel should be set to fill the form.
For more information about TableLayoutPanel:
TableLayoutPanel Control Overview

AxWindowsMediaPlayer size in WPF applications

I am using an AxWindowsMediaPlayer in a WindowsFormsHost in a WPF application.
I'm having problems with sizing the control.
I need to hide the video part, and keep only the part with buttons and seek bar. (since I run audio)
I need to adjust the WindowsFormsHost to only display this part.
I tried to resize the WindowsFormsHost manually so that it only shows the required part, but when I tested the program on different pc's it wasn't displayed properly. Some parts from the control were cropped.
I know you want to hide the video with the uiMOde
awWindowsMediaPlayer.uiMode= "invisible";
But, this hide controls too...
For me, you have two solutions:
the first, you create your axWindowsPlayer form with 45pixel of height for display just the controls button.
the seconds, you hide all the form, and create all your button...
you've acces at the controls button with : (play button for sample)
axWindowsMediaPlayer.Ctlcontrols.play();
And you've acces to the settings with : (volume for sample)
axWindowsMediaPlayer.settings.volume = 25;
I also saw that it was possible to define a custom uiMode, but I did not find any information about that...
You have two options.
Set uiMode to invisible and define your own buttons (functions are accesable like: axWindowsMediaPlayer.Ctlcontrols.stop();).
Set uiMode to mini or full and set height 40. It leaves control without video visible (link: http://msdn.microsoft.com/en-us/library/windows/desktop/dd562469%28v=vs.85%29.aspx)
You can also hide status, bar and controls
axWindowsMediaPlayer.uiMode= "None";

How do I disable user input on a WebView?

I'm having tons of issues trying to integrate Microsoft's WebView in my WinRT application and one of them is the following. I want to display the WebView and its content (which comes from a local offline server but that works like a charm) and I don't want the user to be able to click around ; basically completely disable user input on this WebView.
There is no IsEnabled property on this control so I tried:
Catching the many Pressed-like events and setting the Handled property of the event object to false in each one of the handlers
Catching the GotFocus event of the WebView to set the focus on another control immediately
Putting the WebView in a ContentControl, then set the IsEnabled property of the ContentControl to false
Obviously, none of these workarounds did work so I'm facing a brickwall here. Maybe some of you can help find a solution?
More details if that can help: the web page that is loaded contains an HTML5 canvas where the user can draw things (like in Microsoft Paint). There are also links (ahref). I dont want the user to be able to draw on this canvas, and I don't want them to be able to click on these links as well!
Thanks
Hi you can use a if the content is not animated then you can use a Rectangle instead of the WebView and in the rectangle you use a WebViewBrush, this actually take the webview and render it's content as an image on the rectangle. since it is an image no interaction is available on the rectangle, but if you have animation then you will lose them.
Generally this trick is used to show content onto the webview.

Advantages of popup over panels in Windows Phone

I'm curious about Popup control in Windows Phone. For me, it's some kind of panel, that has IsOpen property. And I should used it, when i want to present some only in some defined context (e.g. button pressed).
But why not use just normal stack, or grid panel, and when use Visiblity when you want to hide, or show it? It's seems to behave the same.
You can change the Horizontal and Vertical position of the popup using the HorizontalOffset /VerticalOffset properties in the Popup control. We don't have that option in the Grid and to other panels.
It is an overlay. It doesn't break page layout as it shows above the main content.
While StackPanel or Grid should be added to main content and when they are shown they'll move other controls down.

Resizing componenets on a c# form

typically in java if you have a layout manager of somesort, when you resize the page then the components in that panel will resize accordingly. I think my app is missing some sort of layout manager to control resizing as at the moment everything is just static
Is there a way to make it resize on the changing of the form size? say the user makes the page bigger, then the componenets adjust and so on.
Thanks
.NET has layout managers as well.
Personally, I prefer the TableLayoutPanel for my WinForms apps.
Once you layout the Table (using a combination of static/dynamic sized rows/columns) you add your child controls to the table cells. Once you add your controls, you can dock or anchor the controls to the cell so that they are automatically adjusted when the window is re-sized.
Two main options:
Anchoring. Set your control to "anchor" to the sides of your form. This means that if the form resizes, the control will stay a constant distance from that side. So, if you anchor Top, Left and Right, then your control will stay in the same position, but resize horizontally with the width of the form. Play with it. It'll be obvious.
Docking. Set your control to "dock" to a side of the form, or the center. This is usually done with containers, and it will make the widget take up that entire portion of the form no matter how large it gets.
In Windows Forms you make use of the Control.Anchor property, which will cause the control to adjust accordingly when the window resizes.
To do this with windows forms you use the Anchor and Dock properties of the control
See this for a guide on how to use them

Categories