Click here to Skip to main content
15,891,423 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Separator in WPF's TreeView Pin
Aviad P.21-Dec-09 2:42
Aviad P.21-Dec-09 2:42 
QuestionHow can i Impliment WPF programing in C# Dialog? Pin
pallaka20-Dec-09 20:33
pallaka20-Dec-09 20:33 
QuestionWPF, Serial Port, MutliThreading Pin
cppwxwidgetsss18-Dec-09 18:37
cppwxwidgetsss18-Dec-09 18:37 
AnswerRe: WPF, Serial Port, MutliThreading Pin
Garth J Lancaster18-Dec-09 19:27
professionalGarth J Lancaster18-Dec-09 19:27 
GeneralRe: WPF, Serial Port, MutliThreading Pin
cppwxwidgetsss22-Dec-09 18:32
cppwxwidgetsss22-Dec-09 18:32 
GeneralRe: WPF, Serial Port, MutliThreading Pin
C_Johnson28-Mar-11 9:37
C_Johnson28-Mar-11 9:37 
QuestionHow to connect MySql DataBase with ODBC connectivity to WPF display Pin
pallaka18-Dec-09 3:10
pallaka18-Dec-09 3:10 
QuestionCreating TreeViewItem dynamically ? Pin
Mohammad Dayyan17-Dec-09 20:28
Mohammad Dayyan17-Dec-09 20:28 
Hi everybody.
I've created a TreeViewItem in WPF via C# :

///////////////////////////////////////////////////
//History
TreeView1.Items.Clear();

Image imageHistory = new Image();
imageHistory.Source = new BitmapImage(new Uri(@"/passwordManager;component/images/TreeView/history.png", UriKind.Relative));
imageHistory.Width = imageHistory.Height = 16;

Label labelHistory = new Label();
labelHistory.Content = "History";

StackPanel stackPanelHistory = new StackPanel();
stackPanelHistory.Orientation = Orientation.Horizontal;
stackPanelHistory.Children.Add(imageHistory);
stackPanelHistory.Children.Add(labelHistory);

TreeViewItem treeViewHistory = new TreeViewItem();
treeViewHistory.Name = "TreeViewItemHistory";
treeViewHistory.Header = stackPanelHistory;

TreeView1.Items.Add(treeViewHistory);


The result of above codes :

<TreeView x:Name="TreeView1" FontSize="13" Grid.Column="0" BorderBrush="Transparent" Padding="0">
    <TreeViewItem Name="TreeViewItemHistory">
        <TreeViewItem.Header>
            <StackPanel Orientation="Horizontal">
                <Image Source="images/TreeView/history.png" Width="16" Height="16"></Image>
                <Label Content="History"/>
            </StackPanel>
        </TreeViewItem.Header>
    </TreeViewItem>
</TreeView>


After that, I'm gonna add some TreeViewItems within TreeViewItemHistory,
For doing it , I've written the following C# codes :

private void MenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
{
    for (int i = 0; i < 10; i++)
    {
        Image img1 = new Image();
        img1.Source = new BitmapImage(new Uri(@"/passwordManager;component/images/TreeView/empty-bookmark.png", UriKind.Relative));
        img1.Width = img1.Height = 16;

        Label label = new Label();
        label.Content = "Test " + i;

        StackPanel sp = new StackPanel();
        sp.Orientation = Orientation.Horizontal;
        sp.Children.Add(img1);
        sp.Children.Add(label);

        TreeViewItem treeViewItem = new TreeViewItem();
        treeViewItem.Name = "TreeViewItem" + i;
        treeViewItem.Header = sp;

        TreeViewItemHistory.Items.Add(treeViewItem);
    }
} 


The above method runs without any Exceptions , but nothing happen and no TreeViewItem doesn't add to TreeViewItemHistory.
I don't know what wrong is with it!
Could you please guide me ?

Editing : I added the XAML code of TreeViewItemHistory within TreeView1 at first. Then, in a method I have cleared all TreeView's TreeVewItems with TreeView1.Items.Clear();. finally I've added TreeViewItemHistory via C# again.

Thanks.
AnswerRe: Creating TreeViewItem dynamically ? Pin
Aviad P.18-Dec-09 0:51
Aviad P.18-Dec-09 0:51 
GeneralRe: Creating TreeViewItem dynamically ? Pin
Mohammad Dayyan18-Dec-09 1:01
Mohammad Dayyan18-Dec-09 1:01 
GeneralRe: Creating TreeViewItem dynamically ? Pin
Pete O'Hanlon18-Dec-09 2:18
mvePete O'Hanlon18-Dec-09 2:18 
NewsFree Silverlight 4 Developer Training Now Available on Channel 9 Pin
brucedkyle17-Dec-09 11:10
brucedkyle17-Dec-09 11:10 
GeneralRe: Free Silverlight 4 Developer Training Now Available on Channel 9 Pin
Abhinav S17-Dec-09 16:55
Abhinav S17-Dec-09 16:55 
QuestionGetting WPF in VC++ Pin
Anu_Bala16-Dec-09 18:29
Anu_Bala16-Dec-09 18:29 
Questionunable to understand concurrencymode Pin
Mogamboo_Khush_Hua16-Dec-09 7:15
Mogamboo_Khush_Hua16-Dec-09 7:15 
AnswerRe: unable to understand concurrencymode Pin
Ian Shlasko16-Dec-09 7:26
Ian Shlasko16-Dec-09 7:26 
GeneralRe: unable to understand concurrencymode Pin
Mogamboo_Khush_Hua16-Dec-09 7:50
Mogamboo_Khush_Hua16-Dec-09 7:50 
GeneralWrite code in client to check concurrency Pin
Mogamboo_Khush_Hua16-Dec-09 9:01
Mogamboo_Khush_Hua16-Dec-09 9:01 
GeneralRe: Write code in client to check concurrency Pin
Ian Shlasko16-Dec-09 9:09
Ian Shlasko16-Dec-09 9:09 
GeneralRe: unable to understand concurrencymode Pin
Ian Shlasko16-Dec-09 9:08
Ian Shlasko16-Dec-09 9:08 
GeneralRe: unable to understand concurrencymode Pin
Mogamboo_Khush_Hua16-Dec-09 18:12
Mogamboo_Khush_Hua16-Dec-09 18:12 
GeneralRe: unable to understand concurrencymode Pin
Pete O'Hanlon16-Dec-09 22:02
mvePete O'Hanlon16-Dec-09 22:02 
GeneralRe: unable to understand concurrencymode Pin
Mogamboo_Khush_Hua16-Dec-09 22:51
Mogamboo_Khush_Hua16-Dec-09 22:51 
Generalproblem in thread Pin
Mogamboo_Khush_Hua17-Dec-09 1:13
Mogamboo_Khush_Hua17-Dec-09 1:13 
QuestionHow can I deploy an application using VISIFIRE Pin
cutudi16-Dec-09 2:00
cutudi16-Dec-09 2:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.