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
Hi Marin,
That code is really nice.
but when we try to add 2-3 button then its not showing first one button.
foreach (TilePane tile in xamTileView1.Items) { ToggleButton toggleButton = tile.Header as ToggleButton; ToggleButton tBtnDataMapping = 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 { object obj = "Property"; toggleButton = new ToggleButton(); toggleButton.Click += new RoutedEventHandler(toggleButton_Click); toggleButton.Content = obj; toggleButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; tile.Header = toggleButton; TilePaneCommandSource commandSource = new TilePaneCommandSource(); commandSource.EventName = "Click"; // commandSource.CommandType = TilePaneCommand.Maximize; commandSource.Parameter = "Toggle"; Commanding.SetCommand(toggleButton, commandSource); object objDataMapping = "Mapping"; tBtnDataMapping = new ToggleButton(); tBtnDataMapping.Click += new RoutedEventHandler(tBtnDataMapping_Click); tBtnDataMapping.Content = objDataMapping; Thickness _Thickness = new Thickness(); _Thickness.Left = 200; _Thickness.Right = 0; _Thickness.Top = 0; _Thickness.Bottom = 0; tBtnDataMapping.Margin = _Thickness; tBtnDataMapping.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; tile.Header = tBtnDataMapping; TilePaneCommandSource commandSourceDataMapping = new TilePaneCommandSource(); commandSourceDataMapping.EventName = "Click"; // commandSource.CommandType = TilePaneCommand.Maximize; commandSourceDataMapping.Parameter = "Toggle"; Commanding.SetCommand(tBtnDataMapping, commandSourceDataMapping); }
I used that code.
Kindly suggest where its issue.
Marin,
Thanks for the answer. I used your code example and it worked well. Thanks again.
-Don
Sorry for the late response. I just got back from vacation. I will try it out and reply with the results. Thanks again,
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