2010-06-21 7 views

Répondre

0
public partial class FancyControl : Canvas 
{ 
    CheckBox myCheckBox; 
    Label myLabel; 

    public FancyControl() { } 
    public FancyControl(CheckBox cb, Label l) 
    { 
     myCheckBox = cb; 
     myLabel = l; 
     Children.Add(myCheckBox); 
     Children.Add(myLabel); 
     //Formatting goes here 
    } 

    public string GetText() 
    { 
     return myLabel.Content.ToString(); 
    } 

    public bool IsChecked() 
    { 
     return myCheckBox.IsChecked.Value; 
    } 
} 

Vous devrez faire la mise en forme sur votre propre, mais essentiellement avec cela, vous allez créer 4 « FancyControl » s puis avec chacun, vous pouvez appeler la méthode IsChecked() et si vrai appel gettext () méthode.

Pour créer un FancyControl il ressemblerait

FancyControl fC = new FancyControl(checkBox1, label1); 

Vous pouvez ensuite ajouter à votre fenêtre fC ou partout où il est censé aller.

Questions connexes