DataTemplate ichida belgilangan tugmani bosing

Quyidagi kabi shablonni buzishim bor:


   
            
                
                    
                        
                            
                                
                                
                            
                        
                    
                

                

                    
                        
                    

                    
                        
                            
                                
                                    
                                        
                                            
                                                                                                                       
                                            

                                                
                                                    
                                                        
                                                        
                                                    
                                                
                                                
                                                    
                                                        <button Click="lstButton_Click" Content="{Binding Text}" Tag="{Binding}" Padding="4,0" IsEnabled="{Binding Visible}" Visibility="{Binding Visibility}" Height="30" Margin="3,5,3,3"/>
                                                                                                           
                                                
                                            
                                                                            

                                    
                                        
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                            
                                        
                                        
                                        
                                                                                         

                                
                            
                        
                    

                
            
            
                
                    
                
            
        


   
                      

Litsenziya klassi sinflar bilan bog'lanadi. Dastlab, ro'yxat oynasi qisqa ko'rinishga ega bo'ladi, keyin yuqorida tavsiflangan batafsil ko'rinish shablonini olish uchun yuklanadi. men oldida turgan muammo shablon ichidagi tugmani bosish hodisasidir. tugmasini bosib, bir necha marta o'qqa tuting va bir necha marta tadbirni ko'tarish uchun ikki yoki uch marta bosiladi.

Hech kim meni izlab topishga yordam berishi mumkinmi?

1

1 javoblar

Men sizning kodingizni test sinovlariga moslashtirdim va u men uchun mukammal ishlaydi! Barcha voqealarni to'g'ri qabul qilaman. Aslida men har bir tugmani bosish uchun lstButton_Click ni ikki marta olaman ... ( Button va ItemsControl darajasida qaynab turish sababli).

Behind Code ...

/// 
/// Interaction logic for Window6.xaml ///
 
public partial class Window6 : Window
{
    public Window[] JustList
    {
        get
        {
            return new Window[] { this };
        }
    }

    public List persons
    {
        get
        {
            return new List()
                       {
                           new Person()
                               {
                                   Acknowledged = true,
                                   Description = "Person 1",
                                   Text = "Person1",
                                   DisplayText = "I am Person 1"
                               },
                           new Person()
                               {
                                   Acknowledged = true,
                                   Description = "Person 2",
                                   Text = "Person2",
                                   DisplayText = "I am Person 2"
                               }
                       };
        }
    }

    public Window6()
    {
        InitializeComponent();
    }

    void lstButton_Click(object sender, RoutedEventArgs e)
    {
        var i = 0 ;
    }

    void CheckBox_Checked(object sender, RoutedEventArgs e)
    {
        var i = 0;
    }
}

public class Person
{
    public string DisplayText { get; set; }
    public string Text { get; set; }
    public bool Acknowledged { get; set; }
    public string Description { get; set; }
    public Visibility IsVisibility { get; set; }

    public List Children
    {
        get
        {
            return new List()
                       {
                           new Person()
                               {
                                   Acknowledged = true,
                                   Description = "Child 1",
                                   Text = "Child1",
                                   DisplayText = "My Child 1"
                               },
                           new Person()
                               {
                                   Acknowledged = true,
                                   Description = "Child 2",
                                   Text = "Child2",
                                   DisplayText = "My Child 2"
                               }
                       };
        }
    }
}

XAML ...

  
    
        
            
                
                   
                      
                        
                        
                      
                   
                
            

            

                
                    
                

                
                    
                        
                            
                                
                                    
                                        
                                    
                                    
                                        

                                            
                                                
                                                    
                                                    
                                                
                                            
                                            
                                                
                                                    <button Click="lstButton_Click" 
                                                            Content="{Binding Text}"
                                                            Tag="{Binding}"
                                                            Padding="4,0" 
                                                            IsEnabled="{Binding
                                                                Visible}" 
                                                            Visibility="{Binding
                                                                Visibility}" 
                                                            Height="30"
                                                            Margin="3,5,3,3"/>
                                                
                                            
                                        
                                    
                                

                                
                                    
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                    
                                    
                                        
                                  
                            
                        
                    
                
            
        
        
            
                
            
        
    



    
    

0
qo'shib qo'ydi