Posted 16 years ago
by Michael
Version: 4.0.0457
Platform: .NET 3.5
Environment: Windows Vista (32-bit)
I created two tabs(tool windows) in a ToolWindowContainer. I painted something in one toolwindow when the window is loaded in the C# code.
Here is the problem: I click the tab of the other window then click back to the window that I painted, the content dispears. But if I drag the window around, rearrange the windows layout, sometime the content can randomly reappear.
Here is the test codeAnd the corresponding c# code
[Modified at 09/20/2008 04:45 AM]
Here is the problem: I click the tab of the other window then click back to the window that I painted, the content dispears. But if I drag the window around, rearrange the windows layout, sometime the content can randomly reappear.
Here is the test code
<Window x:Class="TestBug.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:docking="http://schemas.actiprosoftware.com/winfx/xaml/docking"
Title="Window1" Height="300" Width="300">
<docking:DockSite x:Name="dockSite">
<docking:ToolWindowContainer>
<docking:ToolWindow Name="folderWindow" Title="Tool Window 1" Loaded="folderWindow_Loaded">
<TreeView x:Name="folderTree" Background="AliceBlue" HorizontalContentAlignment="Stretch" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling">
<TreeView.Resources>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}" Margin="5,0" />
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</TreeView.Resources>
</TreeView>
</docking:ToolWindow>
<docking:ToolWindow Title="Tool Window 2" />
</docking:ToolWindowContainer>
</docking:DockSite>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
namespace TestBug
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
private readonly object dummyNode = null;
public Window1()
{
InitializeComponent();
}
private void folder_Expanded(object sender, RoutedEventArgs e)
{
TreeViewItem item = (TreeViewItem)sender;
if (item.Items.Count == 1 && item.Items[0] == dummyNode)
{
item.Items.Clear();
try
{
foreach (string s in Directory.GetDirectories(item.Tag.ToString()))
{
TreeViewItem subitem = new TreeViewItem();
subitem.Header = s.Substring(s.LastIndexOf("\\") + 1);
subitem.Tag = s;
subitem.FontWeight = FontWeights.Normal;
subitem.Items.Add(dummyNode);
subitem.Expanded += new RoutedEventHandler(folder_Expanded);
item.Items.Add(subitem);
}
}
catch (Exception) { }
}
}
private void folderWindow_Loaded(object sender, RoutedEventArgs e)
{
folderTree.Items.Clear();
foreach (string s in Directory.GetLogicalDrives())
{
TreeViewItem item = new TreeViewItem();
item.Header = s;
item.Tag = s;
item.FontWeight = FontWeights.Normal;
item.Items.Add(dummyNode);
item.Expanded += new RoutedEventHandler(folder_Expanded);
folderTree.Items.Add(item);
}
}
}
}