# .NET and More > WPF, WCF, WF >  [RESOLVED] Multiple object movement control array

## Flashbond

Hi guys. 

I am trying to make a dock menu with WPF but my question is on VB.NET side. Anyway, basically I want some kind of a control array but I don't know how to write it.

I have objects in dock are called _1, _2, _3, etc... from left to right. In WPF they are images. On solution explorer they appear as "_1 As Image".
Mainly, what I need is:



```
Sub ImgCntrl(i As Integer)
    For Each Image in MainWindow
        With Me("_" & i)
            If object control name < i Then 'If the object is at left hadside of the initial object
                Move those objects 100 pixel Left
            End If
            If object control name = i Then 'If the object is the initial object
                Move that object 100 pixel Up
            End If
            If object control name > i Then 'If the object is at right hadside of the initial object
                Move those objects 100 pixel Right
            End If
         End With
     Next
End Sub

Private Sub _1_MouseEnter(sender As Object, e As MouseEventArgs) Handles _1.MouseEnter
   ImgCntrl(1)
End Sub

Private Sub _2_MouseEnter(sender As Object, e As MouseEventArgs) Handles _1.MouseEnter
   ImgCntrl(2)
End Sub

Private Sub _3_MouseEnter(sender As Object, e As MouseEventArgs) Handles _1.MouseEnter
   ImgCntrl(3)
End Sub
```

Now this will rise the moseovered (there is no MouseHover in WPF thus is MouseEnter) object 100 pixel up while pushing the other objects to left and right. It will bring a dock like menu effect.

Who may help me for the right expression?

Thanks a lot!!!

----------


## boops boops

I don't understand enough about what you are trying to do to help you with the "right expression". But this may help you along a bit:

1. Since you want to reposition your images, it's best to put them in a Canvas control instead of directly in the main window. You can add your Image controls to the Canvas in the WPF designer, or insert them at run time with Canvas.AddVisualChild.

2. Then you can use Canvas.GetLeft, Canvas.GetTop, Canvas.SetLeft and Canvas.SetTop to get and change the image X and Y positions. For example, if the canvas is Canvas1, you could move the image _1 100 pixels to the left like this:


```
Dim X As Double = Canvas1.GetLeft(_1)
Canvas1.SetLeft(_1,  X - 100)
```

BB

----------


## Flashbond

This can be ok too, but in your example since you can define a property control for only the initial object (it doesn't matter whether it is a canwas or an image).

What I am looking for is to define all the needed property controls for an "i" integer and put the same sub to all events.

----------


## Evil_Giraffe

Personally, I'd put the items in a horizontally oriented stack panel and accomplish the movement by having a property trigger on the images themselves to set a style with a bottom and left/right margins.

----------


## Flashbond

> Personally, I'd put the items in a horizontally oriented stack panel and accomplish the movement by having a property trigger on the images themselves to set a style with a bottom and left/right margins.


For WPF, it is very slow with event triggers for 52 images. I want to try the same thing with VB.NET.

----------


## gep13

Hello,

Since this is a WPF related question, I am going to move this thread to the WPF Forum.  Please let me know if you have any questions.

Gary

----------


## Flashbond

No, Gary. You are right. You may move. It is mostly WPF related.

----------


## Evil_Giraffe

> For WPF, it is very slow with event triggers for 52 images. I want to try the same thing with VB.NET.


Not sure if you understood my point. If you change the margins only on the image which is being moused over, then that's one event firing at a time, which shouldn't have WPF breaking a sweat. The WPF layout mechanism will move the surrounding images to the left or the right to make room for the additional margins, you don't need to trigger anything on those images.

----------


## Flashbond

?! Really? I have to try...

----------


## Flashbond

> Not sure if you understood my point. If you change the margins only on the image which is being moused over, then that's one event firing at a time, which shouldn't have WPF breaking a sweat. The WPF layout mechanism will move the surrounding images to the left or the right to make room for the additional margins, you don't need to trigger anything on those images.


No, it didn't. Yeah, it expands margin without pushing or moving a thing.

----------


## Flashbond

Here is my project:

http://speedy.sh/BN5bx/Game.rar
rarpass: game

I tried it with the first image as you can see but nothing happened. Please, make it with the same image as an example then I may continue it.

----------


## gep13

Hello Flashbond,

This is a compiled exe that you are sharing, and this is not allowed as per our AUP.

Please change this link for the source code of the application, or remove the link completely.

Thanks

Gary

----------


## Flashbond

> Hello Flashbond,
> 
> This is a compiled exe that you are sharing, and this is not allowed as per our AUP.
> 
> Please change this link for the source code of the application, or remove the link completely.
> 
> Thanks 
> 
> Gary


No, I am quite sure that it contains neither compiled .exe nor another file with .exe extension. The rar contains only project files. You should review it more strictly. I refuse to change or remove the link because of "it contains a compiled .exe". But if you have another rule infringement determination then I will reconsider again.

Regards.

----------


## gep13

Hmmm, apologies.  I was looking at the Gamer.rar.exe which is linked at the bottom of the page.

Gary

----------


## Flashbond

Noprob Gary. You are still my favourite Moderator  :Smilie:

----------


## gep13

> Noprob Gary. You are still my favourite Moderator


Ha ha, thanks!  :Blush:

----------

