Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on a c# project. I added a mouseleftbuttondown event to a dockpanel item. I created an image in this event, but I want to access this image from a slider_valuechanged event. how can I do it

What I have tried:

:( add a slider and connect value= image.pos (this not code only example)
Posted
Updated 22-Aug-21 10:15am

1 solution

To do that, you need a reference to the Image that is available to all members of the Form.
So create a private class level variable and when you create the Image, put the reference in that variable.

Your other event handlers within the Form can then access it.
 
Share this answer
 
Comments
Muhammed Yeter 23-Aug-21 2:05am    
Sry. But not understand it.
OriginalGriff 23-Aug-21 2:21am    
What part do you not understand?
I'm not trying to be awkward or make your life hard, but we only get exactly what you type to work with - we get no context beyond that.
So typing as little as possible helps no one - we only know exactly what you have told us!
Muhammed Yeter 23-Aug-21 14:22pm    
2d oyun motoru yapıyorum. bir ağaç görünümü ekledi ve
kullanıcı buna tıkladığında bir öğe ekledi , eylem modeli oluştur
kaydırıcı değerinin değiştirilmesini istiyorum olay tetiklendi, konumu değiştir eylem modeli

kodu :
private void TreeViewItem_MouseDoubleClick_1(object sender, MouseButtonEventArgs e)
{
anahat.Items.Add("Action Model 2");
Görüntü actionmodel2 = yeni Görüntü();
BitmapImage kaynağı = yeni BitmapImage();
src.BeginInit();
src.UriSource = new Uri(aksiyon2, UriKind.Absolute);
src.EndInit();
actionmodel2.Source = kaynak;
actionmodel2.Stretch = Stretch.Üniforma;
actionmodel2.Yükseklik = 100;
Tuval.SetTop(eylem modeli2, 350);
Canvas.SetLeft(actionmodel2, 750);
actionmodel2.MouseDown += actionmodel_MouseLeftButtonDown;
actionmodel2.MouseLeftButtonDown += actionmodel_MouseLeftButtonDown;
actionmodel2.PreviewMouseDown += actionmodel_PreviewMouseDown;
gridmain.Children.Add(actionmodel2);
ImageBehavior.SetAnimatedSource(actionmodel2, src);
Diary.Items.Add("Eklenen Model : Eylem/Eylem Modeli 2");
//actionmodel2.Width = asd.Value;
}
Muhammed Yeter 23-Aug-21 2:05am    
Because i new
Muhammed Yeter 23-Aug-21 3:23am    
asd = my slider name

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900