public void InitialValues()
 {
     Legend legend = new Legend();
     TestAsync(
         legend,
         () => Assert.IsNotNull(legend.Items),
         () => Assert.IsNull(legend.Header),
         () => Assert.IsNotNull(legend.TitleStyle));
 }
 public void AutomaticVisibilitySwitching()
 {
     Button button0 = new Button();
     Button button1 = new Button();
     Legend legend = new Legend();
     TestAsync(
         legend,
         // Initial Visible state helps designers
         () => Assert.AreEqual(Visibility.Visible, legend.Visibility),
         () => legend.Header = "Title",
         () => Assert.AreEqual(Visibility.Visible, legend.Visibility),
         () => legend.Header = null,
         () => Assert.AreEqual(Visibility.Collapsed, legend.Visibility),
         () => legend.Items.Clear(),
         () => Assert.AreEqual(Visibility.Collapsed, legend.Visibility),
         () => legend.Items.Add(button0),
         () => Assert.AreEqual(Visibility.Visible, legend.Visibility),
         () => legend.Items.Add(button1),
         () => Assert.AreEqual(Visibility.Visible, legend.Visibility),
         () => legend.Items.RemoveAt(0),
         () => Assert.AreEqual(Visibility.Visible, legend.Visibility),
         () => legend.Items.RemoveAt(0),
         () => Assert.AreEqual(Visibility.Collapsed, legend.Visibility),
         () => legend.Items.Add(button0),
         () => Assert.AreEqual(Visibility.Visible, legend.Visibility),
         () => legend.Items.Clear(),
         () => Assert.AreEqual(Visibility.Collapsed, legend.Visibility),
         () => legend.Items.Add(button0),
         () => Assert.AreEqual(Visibility.Visible, legend.Visibility));
 }
 public void NewInstance()
 {
     Legend legend = new Legend();
     Assert.IsNotNull(legend);
 }
 public void TitleStyleChange()
 {
     Legend legend = new Legend();
     // Change Legend's Template because Silverlight only allows setting Style properties once.
     legend.Template = new ControlTemplate();
     Style style = new Style(typeof(Title));
     TestAsync(
         legend,
         () => legend.TitleStyle = style,
         () => Assert.AreSame(style, legend.TitleStyle));
 }
 public void TitleChangeButton()
 {
     Legend legend = new Legend();
     Button title = new Button { Content = "Button Title" };
     legend.Header = title;
     Assert.AreSame(title, legend.Header);
 }
 public void TitleChangeObject()
 {
     Legend legend = new Legend();
     object title = new object();
     legend.Header = title;
     Assert.AreSame(title, legend.Header);
 }
 public void TitleChangeString()
 {
     Legend legend = new Legend();
     string title = "String Title";
     legend.Header = title;
     Assert.AreSame(title, legend.Header);
 }
 public void AutomaticVisibilitySwitching()
 {
     Legend legend = new Legend();
     // Initial Visible state helps designers
     Assert.AreEqual(Visibility.Visible, legend.Visibility);
     legend.Visibility = Visibility.Collapsed;
     legend.Header = "Title";
     Assert.AreEqual(Visibility.Visible, legend.Visibility);
     legend.Header = null;
     Assert.AreEqual(Visibility.Collapsed, legend.Visibility);
     legend.Items.Clear();
     Assert.AreEqual(Visibility.Collapsed, legend.Visibility);
     Button button0 = new Button();
     legend.Items.Add(button0);
     Assert.AreEqual(Visibility.Visible, legend.Visibility);
     Button button1 = new Button();
     legend.Items.Add(button1);
     Assert.AreEqual(Visibility.Visible, legend.Visibility);
     legend.Items.RemoveAt(0);
     Assert.AreEqual(Visibility.Visible, legend.Visibility);
     legend.Items.RemoveAt(0);
     Assert.AreEqual(Visibility.Collapsed, legend.Visibility);
     legend.Items.Add(button0);
     Assert.AreEqual(Visibility.Visible, legend.Visibility);
     legend.Items.Clear();
     Assert.AreEqual(Visibility.Collapsed, legend.Visibility);
     legend.Items.Add(button0);
     Assert.AreEqual(Visibility.Visible, legend.Visibility);
 }