Navigate to new Page in Codebehind using NavigationService - xaml

I want to access my page to setup the XAML Page:
Dim Pg As New PageListPickerSelection
Pg.StartCalculating(199,"Z-UU", MyCalculationDataIEnumList, myImageSource)
App.NavigationService.Navigate(New Uri("/uc/ListPicker/PageListPickerSelection.xaml", UriKind.Relative))
But NavigationService.Navigate does not support Objects or referenced pages.
How is the correct procedure to show the own page?
Or asked in another way: How does the "ListPicker in the WP7" solve this when showing his separated page?
Regards

If I understand your question, you are asking how to configure a page before navigating to it, correct?
The navigation service will create your pages as you navigate to them on the fly. It is not possible to give the navigation service the page as an object If you need to pass data into a page you can use the normal method of appending params to a URI as such (using c# as I am not familiar with VB):
NavigationService.Navigate(new Uri("/uc/ListPicker/PageListPickerSelection.xaml?Param1=" + (199).ToString() + "&Parm2=" + "Z-UU", UriKind.Relative));
Later in the PageListPickerSelection's OnNavigatedTo() method you can parse the parameters again as such:
string p1 = this.NavigationContext.QueryString["Param1"];
string p2 = this.NavigationContext.QueryString["Param2"];

You could use a static class in which you have a couple of static values which you write when leaving the first page and read when opening the second page.
If you don't like static classes / variables you could use a singleton.

Related

Clicking through a jquery dropdown menu using VBA / href=javascript:void(0)

I'm trying to make a macro that logs into a website, and starts pulling reports. Problem is, as I'm parsing through the html, I see a button exactly like the one on this page: https://www.exratione.com/2011/12/a-dark-style-for-chosen-selects/
where the href is a java void and the class is a generic "chzn-single" same as that website's button.
Any suggestions?
I'm trying this but no luck:
Set Clickme = IE.document.getElementsByClassName("chzn-single chzn-default")(0)
Clickme.Click
Also, which I don't think makes much sense:
IE.Document.getElementById("typeSelector").Value = "Revenue"
IE.Navigate "javascript:void(0)"
You haven't provided any HTML to go with this. If it is like that which you are showing in the other link then IE.document.getElementsByClassName("chzn-single chzn-default")(0) won't work because the class name is incorrect. It should be just chzn-single.
For the page you have linked, there are two clickable links with class of chzn-single.
I would use a CSS class selector to target them:
For the first:
IE.document.querySelector("a.chzn-single").Click
For the second:
IE.document.querySelectorAll("a.chzn-single").item(1).Click

Can we set the element ID for component created in the code like the ID in application model (e4xmi)?

I created a RCP app with a part. In the part, I created a TreeViewer. Can I set an ID for this viewer so that others plugins can find this viewer by ID? How can we acquire this?
No, you can't do this.
The contents of a part are not in the application model and can't have model ids.
You have to use the findPart method of EPartService to find the part and then call some method that you write in the part object to get the viewer.
MPart part = partService.findPart("part id");
MyPartClass myclass = (MyPartClass)part.getObject();
TreeViewer viewer = myclass.getViewer();

yii efullcalendar widget and external events drag and drop not working

Hi I am trying to use drag and drop external events for fullcalendar and get working with the yii extension full calender - which seems to be just a wrapper.
The part that is not working (no errors just does not work) is dragging the external event onto the calendar and it staying there. It drags over but it just returns home.
Reading the fullcalendar docs - it looks like I need to provide a callback function to 'drop' attribute. I've been using the external-event example which is part of full calendar. I did discover the example was using the object name '#calendar' and that yii is creating name '#yw0' but it still didn't work after I updated.
I cannot find a way to get it work. I tried a simple alert which sort of works, it is called on page load - not after a drag operation.
So I declared a variable with the function in View
//$dropcallback=new CJavaScriptExpression("alert('hi')");
$dropcallback=new CJavaScriptExpression(
"function(date, allDay) {
var originalEventObject = $(this).data('eventObject');
var copiedEventObject = $.extend({}, originalEventObject);
copiedEventObject.start = date;
copiedEventObject.allDay = allDay;
$('#yw0').fullCalendar('renderEvent', copiedEventObject, true);
if ($('#drop-remove').is(':checked')) {
// if so, remove the element from the Draggable Events list
$(this).remove();
}
}
");
Then I create the widgit like this
$this->widget('ext.EFullCalendar.EFullCalendar', array(
'themeCssFile'=>'cupertino/jquery-ui.min.css',
'options'=>array(
'header'=>array(
'left'=>'prev,next',
'center'=>'title',
'right'=>'today'
),
'editable'=>true,
'dropable'=>true,
'drop'=>$dropcallback,
'events'=>Game::model()->gameCalendarData(),
)));
My yii experiance is little and same with JS - so any help appreciated in how to get this working.
I understand that in JS you need to provide a callback to allow the drag op to succeed. But what sort of call back do I need when it is wrapped in a yii widgit? I tried a PHP callback and again it is only called on page load.
The result I wish is that I can build the external events list from the DB - allow users to drag them onto the calendar - and save them in the DB.
I did manage to get data from DB displayed in the calendar.
Thanks
Droppable is spelt with two p's. So
'dropable'=>true,
Should be
'droppable'=>true,

Silverlight localization from database, not resx

I have a Silverlight 4 OOB application which needs localizing. In the past I have used the conventional resx route but I have been asked to follow the architecture of an existing winforms app.
All the strings are currently stored in a database - I use a webservice to pull these down and write them into a local Effiproz Isolated Storage database. On Login I load a Dictionary object with the language strings for the users language. This works fine.
However, I want to automate the UI localization (the WinForms app does it like this):
Loop through all the controls on the page and look for any Textblocks - if there is a text property I replace it with the localized version. If the text is not found, then I WRITE the string to the database for localization.
This works ok on simple forms but as soon as you have expanders/scrollviewers and content controls then the VisualTree parser does not return the children of the controls as they are not necessarily visible (see my code below). This is a known issue and thwarts my automation attempt.
My first question is: Is there a way of automating this on page load by looping through the complex (non-visual) elements and looking up the value in a dictionary?
My second question is: If not, then is the best way of handling this is to load the strings into an app resource dictionary and change all my pages to reference it, or should I look into generating resx files, either on the server (and package it with the app as per normal) or on the client (I have the downloaded strings, can I make and load resx files?)
Thanks for any pointers.
Here is my existing code that does not work on collapsed elements and complex content controls:
public void Translate(DependencyObject dependencyObject)
{
//this uses the VisualTreeHelper which only shows controls that are actually visible (so if they are in a collapsed expander they will not be returned). You need to call it OnLoaded to make sure all controls have been added
foreach (var child in dependencyObject.GetAllChildren(true))
{
TranslateTextBlock(child);
}
}
private void TranslateTextBlock(DependencyObject child)
{
var textBlock = child as TextBlock;
if (textBlock == null) return;
var value = (string)child.GetValue(TextBlock.TextProperty);
if (!string.IsNullOrEmpty(value))
{
var newValue = default(string);
if (!_languageMappings.TryGetValue(value, out newValue))
{
//write the value back to the collection so it can be marked for translation
_languageMappings.Add(value, string.Empty);
newValue = "Not Translated";
}
child.SetValue(TextBlock.TextProperty, newValue);
}
}
Then I have tried 2 different approaches:
1) Store the strings in a normal dictionary object
2) Store the strings in a normal dictionary object and add it to the Application as a Resource, then you can reference it as
TextBlock Text="{Binding Path=[Equipment], Source={StaticResource ResourceHandler}}"
App.GetApp.DictionaryStrings = new AmtDictionaryDAO().GetAmtDictionaryByLanguageID(App.GetApp.CurrentSession.DefaultLanguageId);
Application.Current.Resources.Add("ResourceHandler", App.GetApp.DictionaryStrings);
//http://forums.silverlight.net/forums/p/168712/383052.aspx
Ok, so nobody answered this and I came up with a solution.
Basically it seems that you can load the language dictionary into your global resources using
Application.Current.Resources.Add("ResourceHandler", App.GetApp.DictionaryStrings);
<TextBlock Text="{Binding [Equipment], Source={StaticResource ResourceHandler}}" />
and then access it like a normal StaticResource. We have the requirement of noting all our missing strings into a database for translation - for this reason I chose to use a Converter that calls a Localise extension method (so it can be done on any string in the code behind) which then looks up the string in the Dictionary (not the resource) and can do something with it (write it to a local DB) if it does not exist.
Text="{Binding Source='Logged on User', Converter={StaticResource LocalizationConverter}}"/>
This method works ok for us.

ObservableCollection<someentity> not refreshing

I am using Silverlight 4 and MVVM pattern for my application. I have a listbox that is bound to one page say one.xaml and it's viewmodel is oneviewmodel.cs. This is the page where i load my albums collection. I have a button on that page which popups a page to add a new album. Say that page is two.xaml and it's viewmodel is twoViewModel.cs. On this page i call ria services :-
context.albums.add(somealbum);
and submit the changes.The album gets added and i can see the record in sql server. However when the popup gets closed my listbox still shows the stale data. Do i need to again make a request to server to load the fresh entity just added? Thus, essentially i have to use messaging pattern and request oneviewmodel.cs to load the entities again. Is this correct way of doing?
This is my method of loading album entities :-
var qry = AlbumContext.GetAlbumsQuery(_profile.UserId);
AlbumContext.Load<Album>(qry, new Action<System.ServiceModel.DomainServices.Client.LoadOperation<Album>>(albums => {
if (GetAlbumsComplete != null)
{
if (albums.Error == null)
{
GetAlbumsComplete(this, new EntityResultArgs<Album>(albums.Entities));
}
else
{
GetAlbumsComplete(this,new EntityResultArgs<Album>(albums.Error));
}
}
}), null);
This is using the same pattern and classes as Shawn Wildermuth.
Thanks in advance :)
You do not need to load everything from the server again, but you need to add the new album to your ObservableCollection. So far you only added it to the DomainContext.
You could do one of the following two options:
1) Add the new album directly to the collection with
collection.Add(somealbum);
or
2) I assume that you fill the ObservableCollection in GetAlbumsComplete(). Just execute that part again, so that the ObservableCollection is filled with the content of your DomainContext.Albums.