Cast to Container Control

I’m using the following code to call methods etc. from a View’s Scrollable Area Container Control.

Dim cc2 As CCSetupContainer cc2 =CCSetupContainer(ScrollableAreaSetupView.Content) ' cast to CCSetupContainer

Now to go from the Container Control’s push buttons back to the View, I have to use a timer and True / False properties to change the contents of the View which is continuously monitoring the Container Controls True / False properties. I want to eliminate the timer as it is causing some slow down issues. Anybody have a clue how to go the other way? I can’t make it work without the timer.

Can you use parent or put a property in your container that stores a ref to the view you want?

Hey Kevin,

Thanks for the response. That’s basically what I’m doing. For instance a button push on the container controls content will store “Yes” on the main view’s property SetupButtonPushed like this"

MainView.SetupButtonPushed=“Yes”

The MainView Timer is monitoring the SetupButtonPushed property with a Multiple setting and a period of 200. With the code something like this:

If SetupButionPushed="Yes" Then ScrollableAreaSetupView.Content=New CCSetupPage2 End

This then loads the new container control into the Scrollable Area. I would like to able to accomplish this without the timer by simply coding the button in the Container Control but everything I’ve tried to cast back to the Main View has failed. This works very well but I have noticed a considerable amount of performance degradation with a number of button pushes. I’m assuming this procedure is a huge memory hog.

I think I must be missing something. It seems you can address the MainView because you are setting a property there to yes. If the code to create the new CCSetupPage2 is in the MainView as well, why can’t you just call it as a method the same way you set the property?

Maybe posting a basic sample app would help, but it seems to me like the timer is redundant already. I’m sure I’m missing some aspect of the problem though.

Kevin,

You can set the main view’s shared properties with a button push with no problem from the container control but that’s all. You cannot invoke a method, for instance, or directly change anything. In my container control I have a push button which calls a date picker in the main view and sets the date picker’s property to visible True or Visible False. The only way to accomplish this is to set the main view’s shared property DatePickerVisible to “Yes” or “No” from the button push. The timer then continuously monitors DatePickerVisible and the date picker appears or disappears. I have about 15 or so instances where I need the date picker to appear. If the date picker is in the container control it will of course scroll but it needs to be “frozen” in position hence it must be on the main view. I initially placed all my controls directly on the scrollable view but found that there is a pixel limitation where if you go past about 900 pixels in height, any additional controls will fall on top of each other in the layout view making it difficult but not impossible to place them. By the way, even though they are on top of each other, it runs just fine on the device. There is no limitation on pixel height in the container control so I’ve changed to that method. Clear as mud, right?

Just about. I think I understand what you’re saying, but it doesn’t seem correct.

I went and looked in one of my current web apps. I have a multi-step sign up page that uses containers for each step of the process.

I use the following line to start step two after the user presses the next button in the step one container. All the containers are stacked on top of each other on the same master container, which itself is stacked onto the main page of the site with other containers.

wcSignUpContent(self.Parent).SignUpStep2.init

So I am casting the parent of the step1 container to the master sign up container and then addressing the step two container within it and calling it’s init method. All of this works fine and I can’t recall ever having an issue doing it this way.

Hmmm, I think what you are doing is what I’m trying to accomplish as well. My App has a Menu View that has three scrollable areas with their properties set at Visible=False. Each scrollable area’s content is a different container control depending on the Menu selection. I want a button on the Menu View container control to change the scrollable area’s property to Visible=True or Visible= False . I’ve tried a number of approaches but either the button does nothing or I get:

View2.Change, line 5
Instance methods need an object: call this on an instance of class View2.View2.
ScrollableArea1.Content=ContainerControl2

I’ve also been trying to change text in View2 from View1 with the same results.

(This is from a quick App that I’m using for experiments.)

The timer method I’m using works well but I would like to avoid having the timer running in the background plus it leads to some unintended consequences occasionally that require work arounds. Seems like half the code I’m writing is for work arounds especially since the Open Event doesn’t fire in the container control. Thanks for working with me on this.

If you can post your test app somewhere that would make it a lot easier to see what the difference is. It sounds like you may have an extra level of container to deal with, so might need to cast the parent two times to get where you need to go, but it’s hard to say without actually seeing the code.

Kevin,

I 'll have to set up a Dropbox account first but in the meantime I got it to work using a Delegate and Property in the container control:

ContainerControl1

The Delegate is:
SimpleDelegate

The Property is
PointerCallback As SimpleDelegate

View1 has two controls
Rectangle1
Label1

In the View1 Open event:

dim cc as new ContainerControl1 cc = ContainerControl1(ScrollableArea1.Content) cc.PointerCallback = WeakAddressOf me.GetMethod

In the Container Control I have a button with this code in the Action event:

(“Method” is a shared Text property of View1)

[code]
Select Case Button1.Caption

Case “Change”

View1.Method=“Visible1”
Button1.Caption=“Change Back”

try
if PointerCallback <> nil then
PointerCallback.invoke
End if
catch
End Try

Case “Change Back”

View1.Method=“Visible2”
Button1.Caption=“Change”

try
if PointerCallback <> nil then
PointerCallback.invoke
End if
catch
End Try

End Select[/code]

GetMethod is a Method with the following code:

[code]

If Method=“Visible1” Then

Visible1

end

If Method=“Visible2” Then

Visible2

end[/code]

Method Visible1 Has the following code:

Label1.Text="World" Rectangle1.FillColor=Color.RGBA(0,0,0,0)

and Method Visible2 Has the following code:

Label1.Text="Hello" Rectangle1.FillColor=Color.RGBA(255,255,255,0)

Now I’ll try it in my App. Thanks for all your help.