locked
Create and Move Eclipse as value change in TextBlock

    Question

  • Hi

    I am working on app in which I have to change the position of Eclipse  as value in text-block change. For this I create eclipse in Programmatically but it not appearing on design when I run the application 

       

    private void Ellispse() { Ellipse nn = new Ellipse(); nn.Height = 145; nn.Width = 145; //nn.Margin.Left = 164; //nn.Margin.Top = 44; CompositeTransform ct = new CompositeTransform(); ct.CenterX = 100; ct.TranslateX = 66; nn.RenderTransform = ct; nn.Margin = new Thickness(164, 44, 0, 0); MoonGrid.Children.Add(nn); }

    Calling this method on page load event


    Sunday, January 11, 2015 8:39 PM

All replies

  • Its simple mate.

    You didn't give the Fill Color of ellipse., so even though ellipse is added, due to no fill color, it appears that ellipse is not created. Add this line :-

     nn.Fill = new SolidColorBrush(Colors.Red);

    Also, your codes ct.TranslateX = 66 and nn.RenderTransform = ct will not give you the desired result because ellipse will appear on the screen with translated value. 

    Sunday, January 11, 2015 9:28 PM
  • Thanks for your guidance but its not now appearing after modifying code as shown below 

      private  void Ellispse()
            {
                Ellipse nn = new Ellipse();
    
                nn.Height = 145;
    
                nn.Width = 145;
    
                nn.Fill = new SolidColorBrush(Colors.Red);
                CompositeTransform ct = new CompositeTransform();
    
                ct.CenterX = 100;
                
                ct.TranslateX = 66;
                //nn.RenderTransform = ct;
    
                
    
                nn.Margin = new Thickness(164, 44, 0, 0);
    
                
                MoonGrid.Children.Add(nn);
            }


    Monday, January 12, 2015 8:45 AM
  • Hi Faizan Amjad,

    Can you tell me why you put the code in private method and how do you call it? I moved your code out of that private method and put them in Button click event, it worked and displayed in XAML.

    private void Button_Click(object sender, RoutedEventArgs e)
    
            {
    
                Ellipse nn = new Ellipse();
    
                nn.Height = 145;
    
                nn.Width = 145;
    
                nn.Fill = new SolidColorBrush(Colors.Red);
    
                CompositeTransform ct = new CompositeTransform();
    
                ct.CenterX = 100;
    
                ct.TranslateX = 66;
    
                //nn.RenderTransform = ct;
    
                nn.Margin = new Thickness(164, 44, 0, 0);
    
                MoonGrid.Children.Add(nn);
    
            }
    

    Please check this. I think it’s not the problem of code. If I misunderstand, please post more information about your scenario.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, January 13, 2015 7:19 AM
    Moderator
  • Hi Heero , 

    Actually I have to  Bind Ellipse  position with Text Block value and value change in Text Block It position should change.For checking its  I create this method and call in Page load  event but its not appearing there.

    On XAML page I have one Main Grid Called "layout " which contain other three grids and moongrid is one of them in which i want  this Ellipse appears 

     

    Tuesday, January 13, 2015 8:01 AM
  • I assume you need to implement INotifyPropertyChanged interface in somewhere when you are using binding. Can you post a repro project to show more information?

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, January 13, 2015 8:46 AM
    Moderator
  • Thanks for guidance I have fixed the issue now Ellipse is showing when i click the button but it disappear after sometimes automatically why it happens ?? 
    Saturday, January 17, 2015 8:43 PM
  • Hi Faizan,

    Does you drag that Ellipse out of the app visual range? Please check.

    I cannot provide anything more if there is nothing in detail about your new scenario.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Wednesday, January 21, 2015 8:31 AM
    Moderator