Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
How to add use Toggle Button for TilePane Header
posted

Using VB.NET, I want to use a Toggle Button control in place of the standard TilePane Header button. This would allow my users to easily transition between tile panes without having to use the indistinguishable header button.

I reviewed the included 9.2 XAML Samples on this but I couldn't figure out how to translate/implement it to VB.NET/C# code. I cannot use the XAML-only approach since this code is maintained by developers that don't have strong web development/Silverlight skills.

If possible, can someone provide a clear example on how to do this using VB.NET/C# code.

Thanks in advance.

Don

 

Parents
No Data
Reply
  • 3071
    Verified Answer
    posted

    Hi Don,
    The XAML is better approach but this sample will work:
    private void tv3_LayoutUpdated(object sender, EventArgs e)
    {
      foreach (TilePane tile in tv3.Items)
      {
        ToggleButton toggleButton = tile.Header as ToggleButton;
        if (toggleButton != null)
        {
          if (toggleButton.Tag != "ready")
          {
            FrameworkElement parent = VisualTreeHelper.GetParent(toggleButton) as FrameworkElement;
            if (parent != null)
            {
              Grid.SetColumnSpan(parent, 2);
              Canvas.SetZIndex(parent, 100);
              toggleButton.Tag =
    "ready";
            }
          }
        }
        else
        {
          toggleButton =
    new ToggleButton();
          toggleButton.Content = tile.Header;
          tile.Header = toggleButton;
          TilePaneCommandSource commandSource = new TilePaneCommandSource();
          commandSource.EventName =
    "Click";
          commandSource.CommandType =
    TilePaneCommand.Maximize;
          commandSource.Parameter =
    "Toggle";
          Commanding.SetCommand(toggleButton, commandSource);
        }
      }
    }
    Regards,
    Marin

Children