pass button click event through several usercontrols to a form and let another usercontrol know the button clicked - events

I know it sounds complex but thats true.
I have a winform(clientFile) which in a project. It uses an usercontrol in another project. This usercontorl is FinancialManager.It is initialized in constructor.
In FinancialManager, there is another child usercontrol(FinancialService) which is initialized in constructor too.
In FinancialService, it has a button and in the button click event, it initialized the last usercontrol(FinancialItem).
I need to use WINFORM and C# to let my usercontrol(timeControl) which is in the ClientFile(initialized in page_load) know the button in FinancialItem is clicked.
is there any good way to do it? If you can give a sample code, that will be perfect.
Thank you.
by the way, those usercontrols are in one project. except my usercontrol(timeControl).

Since you can control the code in your own usercontrols, it seems to me like you want to add a custom event in one of your usercontrols. Then diferent code can subscribe to this event and will know if the event was triggered.
...but it was a bit hard to understand exactly what you wanted...
Look up a basic event tutorial, and you're probably good to go.

Related

WP7 MVVMCross Detect RequestClose or BackKeyPressed inside ViewModels

I have two view. I navigate from one to the other and in the other I call RequestClose or use the back keypress. How can I detect in the first ViewModel these events?
Regards,
Dan
By default the MvvmCross framework doesn't tell you about this event.
You'll need to work out some other way of letting the ViewModel know that it needs to do something.
How you do this depends on what the actual event is that you are looking for.
For example:
if the second ViewModel changed some data in an underlying model, then this might be communicated back to the first ViewModel through an event from the data layer.
if the second ViewModel was somehow changing something more transitory (less model like) then you might implement some sort of messaging mechanism (using something like TinyMessenger) to allow ViewModels to communicate.
Can you say any more about what your event is?
Update... as an example, here's the type of thing I might do for facebook - https://github.com/slodge/facebookExample (WP7 only checked in!)

Event atStart App?

I'm starting writing my little app at WP7. I consider one thing. There is event "AtStart"? I want to use Textbox to display actual data with some text and I thought that event "atstart/atLaunch" will be perfect for it.
Thanks
There is no "AtStart" event - there is an Application.Launching event which is fired when your application starts up. There is also an OnNavigatedTo virtual method you can override on a page level which is invoked when a page is first navigated to. It sounds like OnNavigatedTo might be what you are looking for. At this point you can change the Text property of a TextBlock (which is identified by an x:Name) which is present in your page XAML file.

Unify ViewModel through-out UserControl

I'd like to know how to set a single ViewModel throughout a single UserControl. I'm using an Items container inside a user control (bound to ItemsSource) and it doesn't seem to update with the code-behind replacement of a DataContext (to a code-behind instantiated ViewModel)
What i'm trying to do is change the DataBound foreground color of every text Item in the userControl, and the items inside an Itemscontrol dont seem to change. forcing a datacontext change removed the collection items from display.
I think I'm conceptually Misunderstood here. could anyone help?
I could fix the problem by using Storyboards to change color but the problem was still the same. The eventual solution was to access the resources inside the templates, which is possible by browsing the Visual Tree as shown in this tutorial
http://windowsphonegeek.com/tips/how-to-access-a-control-placed-inside-listbox-itemtemplate-in-wp7
The peculiar thing though, was that I needed to look for my object inside the initial object returned, as it seems to return the System generated one, which you don't see yourself. Looking for the answer inside this one helped. Also, pushing them into a list of items for easy access later could be a general idea, but MS needs to fix the way of doing this pronto.
I would recommend binding the ItemsSource to a property in your ViewModel.

How to add/edit Label name in Panel of GEF

I am using Panel as a Figure in GEF eclipse. Now on double click I want to add a Label as other normal example shows .
How to achieve that.
On the EditPart that manages the figure you should install a DIRECT_EDIT_ROLE policy (implemented by DirectEditPolicy class). This will cause your EditPart to be called when double clicks occur on the figure. The framework will call method performRequest with a RequestConstants.REQ_OPEN or RequestConstants.REQ_DIRECT_EDIT request. Upon receiving the request you can add whatever you want to the figure and refresh visuals.
If you want to edit text inside a Label, you can see how I implemented this here.
Good luck.

How to call an event when the user "finally" selects an item in a list?

When a user clicks once on an item in a Grid or a ListBox, that item is usually selected, hence most UI frameworks have a onSelected event or the like for that.
However, how can we generally call the next step when a user "finally" selects an item by e.g. double clicking an entry? You know when some popup might appear in the context of the selected item and the user can do further stuff.
Strangely enough, I think I have never seen a word for that in any UI framework.
onPicked, onAccepted, onChosen, onFinallySelected, onResult? All kinda awkward or too special. Any other ideas?
I haven't found anything wrong with SelectionChangeCommitted
The wxWidgets framework uses the term activated to describe what you're talking about. So, the method could be called onActivated.

Resources