how to refresh browser from Silverlight app located inside of a child aspx page - silverlight

I know there are methods to refresh the browser page from silverlight
like HtmlPage.Window.Navigate(HtmlPage.Document.DocumentUri); OR
System.Windows.Browser.HtmlPage.Document.Submit();
And these work fine when the container page use the total space in the page,
but what about when my silverlight app is located on a child page that belong to a some kind of master page? i.e. In the code bellow I have a page called Application.aspx that have three sections (main.aspx is where my silvelight app is located).
<frameset >
<frame id=frameTitle name=frameTitle src="title.aspx" noResize scrolling="no" frameborder="no" height="75" />
<frame name="frameSpacer" id="frameSpacer" src="spacer.aspx" noresize scrolling="no" marginwidth="0" marginheight="0"/>
<frame id="frameMain" name="frameMain" src="main.aspx" noResize scrolling=no frameborder="no" />
</frameset>
How can I refresh Application.aspx and not just Main.aspx (when i use Document.Submit() i got a partial refresh for main.aspx)? using other method?
Thank you in advance.

Solution: from the container aspx page we need to add a js function:
function reload() {
window.parent.location.reload(true);
}
from silverlight: we need to add a call to the js function "reload"
HtmlPage.Window.Invoke("reload");

Related

Prism INavigationAware methods not called with WPF app

We are using Prism 7.2.0.1441-ci in our WPF app. We have a problem that the INavigationAware
methods are not being called when navigating to a view. We use the below code to navigate.
The Login view is registered. The LoginViewModel has implemented INavigationAware
_regionManager.RegisterViewWithRegion(RegionNames.TabRegion, typeof(Login));
_regionManager.RequestNavigate(RegionNames.TabRegion, ViewNames.Login, parameters);
MainWindow.xaml
<DockPanel>
<!-- <Frame x:Name="_mainFrame" NavigationUIVisibility="Hidden" /> -->
<ContentControl prism:RegionManager.RegionName="{x:Static core:RegionNames.TabRegion}" />
</DockPanel>
This mechanism does work in another part of the app, this particular bit is in the startup code and is being called from the MainWindowViewModel constructor.
Any ideas?
Thanks
This mechanism does work in another part of the app, this particular bit is in the startup code and is being called from the MainWindowViewModel constructor.
You cannot navigate from the shell view model's constructor, because the regions aren't there yet.
Instead, do the first navigation from OnInitialized (or let the user click a button).

Adding window resources to a page?

I have created a window and set its resources as:
<Window.Resources>
<ResourceDictionary Source="Styles/StyleDark.xaml"/>
</Window.Resources>
I wanted to add a page to the window. I have added the page through the
<Frame Source="LoginScreen.xaml"/>
The login Screen uses the resources i have added in the window resources.But when i run, the stylesheet is not applied.
I have tried to copy paste the content of page and it works fine. What mistake am I making?

Html page in windows phone8.1

How to call Html page in windows phone8.1 using webview
my xaml code is:
<StackPanel>
<WebView x:Name="myWebView"
Height="550"
VerticalAlignment="Top"
Source="ms-appx:///html/Home.html" />
<TextBox Margin="10,95,124,0"
VerticalAlignment="Top"
Text="ms-appx:///html/Home.html" />
</StackPanel>
I created file name Home.html inside I used .js and .css styles and .cs code:
var html = await Windows.Storage.PathIO.ReadTextAsync("ms-appx:///html/Home.html");
this.myWebView.NavigateToString(html);
But its not working? If someone have idea of this help me.
To access resources from within WebView, you have to use the ms-appx-web:// protocol.
(Only for your .css etc. Files. Not for the direct loading you do before using NavigateToString.)

Hide navigation control for better control on flow

I am using Page classes to its NavigationService.Navigate API to create navigation between few pages. In the page I have provided buttons for navigation but I am getting following control for free.
Is there someway to hide this control so that its not shown?
Is your page rendered inside of a frame? A frame by default supports Navigation. If this is the case you have to set the navigation visibility property of the frame control to hidden.
<Frame Name="Frame1" NavigationUIVisibility="Hidden" >
Yes, Page object has ShowsNavigationUI property that you can use.
<Page ...
ShowsNavigationUI="False">
<Grid Background="LightBlue" />
</Page>

Make silverlight object in the center of page

When I create a Silverlight project in the Visual Studio, then build it, the VS would popup a page with the silverlight that I just made.But that silverlight object always on the left-up corner, is there any way to make it in the horizontal center of the page?
Best Regards,
Ordinarily the positioning of the plugin content within the rest of the HTML page is a problem for the HTML/CSS to solve not the Silverlight. (If you want that look for CSS solutions that center any HTML element in the Viewport and then apply it to the object tag in the .aspx or .htm hosting your control).
However I'm going to guess you don't have any other content in the page, the page exists only to host the silverlight content. In this case it may be better to let the Silverlight content occupy the entire page. The default .aspx and .htm test pages are designed to allow the plugin to do that, you just need to move the Width and Height properties from the UserControl to the inner "LayoutRoot" element and set the "LayoutRoot" to have "Center" HorizontalAlignment and VerticalAlignment.
In other words from this:-
<UserControl xmlns=".... blah...."
Width="600" Height="400">
<Grid x:Name="LayoutRoot">
<!-- Content here --?
</Grid>
</UserControl>
to this:-
<UserControl xmlns=".... blah....">
<Grid x:Name="LayoutRoot" Width="600" Height="400"
HorizontalAlignment="Center" VerticalAlignment="Center">
<!-- Content here --?
</Grid>
</UserControl>

Resources