Click here to Skip to main content
12,503,591 members (43,623 online)

Silverlight / WPF

 
GeneralRe: WPF / MVVM Get Data From ViewModel Pin
Kevin Marois15-May-13 7:54
memberKevin Marois15-May-13 7:54 
GeneralRe: WPF / MVVM Get Data From ViewModel Pin
SledgeHammer0115-May-13 8:41
memberSledgeHammer0115-May-13 8:41 
GeneralRe: WPF / MVVM Get Data From ViewModel Pin
Kevin Marois15-May-13 9:00
memberKevin Marois15-May-13 9:00 
GeneralRe: WPF / MVVM Get Data From ViewModel Pin
Kevin Marois20-May-13 14:00
memberKevin Marois20-May-13 14:00 
GeneralRe: WPF / MVVM Get Data From ViewModel Pin
SledgeHammer0120-May-13 16:16
memberSledgeHammer0120-May-13 16:16 
GeneralRe: WPF / MVVM Get Data From ViewModel Pin
Kevin Marois15-Jun-13 10:37
memberKevin Marois15-Jun-13 10:37 
Questionweb services Pin
picasso212-May-13 12:54
memberpicasso212-May-13 12:54 
AnswerRe: web services Pin
Abhinav S12-May-13 18:29
mvpAbhinav S12-May-13 18:29 
GeneralRe: web services Pin
picasso212-May-13 20:21
memberpicasso212-May-13 20:21 
QuestionHow to acheive the given layout in Silverlight? Pin
New Coder1239-May-13 22:55
memberNew Coder1239-May-13 22:55 
AnswerRe: How to acheive the given layout in Silverlight? Pin
Abhinav S12-May-13 7:47
mvpAbhinav S12-May-13 7:47 
QuestionSL application does not works-nothing change Pin
picasso28-May-13 18:48
memberpicasso28-May-13 18:48 
AnswerRe: SL application does not works-nothing change Pin
Abhinav S12-May-13 7:45
mvpAbhinav S12-May-13 7:45 
QuestionBinding issues with Treeview C# WPF Pin
bartbartb2-May-13 11:41
memberbartbartb2-May-13 11:41 
I am using WPF, C#, Linq to Sql -- I have a stored procedure and I am trying to bind the results to a treeview two levels deep. Below is some of the code I thought might help understand better, I am not sure if I needed to post this much code, but I can remove the uneeded code. I am having trouble figuring out the bindings with the data-templates. Any suggestions or comments would be appreciated.

Here is part of the view model I am using



public sealed class AViewModel : ViewModel
        {
 
          public sealed class ItemsToGet
          {
             public Guid? Id {get; set; }
             public int? TNumber { get; set;}
             public string Title { get; set; }
             public string Description { get; set; }
             public string FullName { get; set;}
          }
 
          //this is the parameter I am passing to the procedure
          private Guid mText = Guid.Empty;
          private ObservableCollection<ItemsToGet> mHistory = new ObservableCollection<ItemsToGet>();
 
          public ObservableCollection<ItemsToGet> History
          {
          get
            {
               return mHistory;
            }
          }
 
           public Guid SearchText
           {
                get
                {
                    return mText ;
                }
                set
                {
                    mText = value;
                    OnPropertyChanged("SearchText");
                }
           }
 
    //This Guid is just for testing the Procedure and binding etc.
    //mText = new Guid("579BC2EF-6681-4728-8CC5-9671C1D54A35");

             var itemlist = from s in context.GetHistory(mText)
                                           select new ItemsToGet()
                                           {
                                               Id = s.Id,
                                               TNumber = s.TNumber,
                                               Title = s.Title,
                                               Description = s.Description,
                                               FullName = s.FullName
                                            };
 
List<ItemsToGet> Results = itemlist.ToList();
mHistory.Clear();
Results.ForEach(b => mHistory.Add(b));

Here is the View Code Behind


public partial class AView : UserControl
    {
        public AView()
        {
            InitializeComponent();
            AViewModel vm = this.DataContext as AViewModel;
 
        }
    }


Xaml -- I want to top level to display the Title, and the child(second level to be the TNumber)

<TreeView ItemsSource="{Binding History}">
 
    <!--  template -->
    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate ItemsSource="{Binding History}">
                <TextBlock Foreground="Red" Text="{Binding Title}" />
 
            <!--  template -->
            <HierarchicalDataTemplate.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding History}">
                        <TextBlock Text="{Binding TNumber}" />
 
                    <!--  template -->
                    <HierarchicalDataTemplate.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding}" />
                        </DataTemplate>
                    </HierarchicalDataTemplate.ItemTemplate>
 
                </HierarchicalDataTemplate>
            </HierarchicalDataTemplate.ItemTemplate>
 
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
 
</TreeView>
 
</UserControl>

Here is a snapshot of what the results look like, there are more rows than this, but this is the format.



//                 Id               TNumber    Title    Description    FullName
//D5C507FB-92FC-4179-BAB9-110928736428  1   Design 1    Random         John Doe
//D5C507FB-92FC-4179-BAB9-110928736428  2   Design 1    Another        John Two
//E00FE69C-BF14-4261-BEA6-2F4167BCB4F5  1   Design 2    Random Two     Jane Doe
//E00FE69C-BF14-4261-BEA6-2F4167BCB4F5  2   Design 2    Another Random Jane Two
//E00FE69C-BF14-4261-BEA6-2F4167BCB4F5  3   Design 2    Third Random   Jane Three
//D34CC0DD-F67B-48D6-B0A6-D91F5A4B27E2  1   Design 3    Another Random John Does
//06468A50-CC07-4CEC-B2EC-1817B29DC783  1   Design 4    Full Random    John Jane
//06468A50-CC07-4CEC-B2EC-1817B29DC783  2   Design 4    Full text      Jane John

Trying to display it like below. Thanks for any comments or suggestions.


Design 1
      --Tnumber 1
      --TNumber 2
Design 2
      --TNumber 1
      --TNumber 2
      --TNumber 3
Design 3
      --TNumber 1
ETC
ETC

AnswerRe: Binding issues with Treeview C# WPF Pin
Kenneth Haugland3-May-13 2:22
professionalKenneth Haugland3-May-13 2:22 
AnswerRe: Binding issues with Treeview C# WPF Pin
Mycroft Holmes9-May-13 12:23
professionalMycroft Holmes9-May-13 12:23 
QuestionVisualTreeHelper.HitTest / RectangleGeometry not working... Pin
SledgeHammer012-May-13 7:26
memberSledgeHammer012-May-13 7:26 
AnswerRe: VisualTreeHelper.HitTest / RectangleGeometry not working... Pin
Kenneth Haugland2-May-13 7:38
professionalKenneth Haugland2-May-13 7:38 
QuestionTab Closing Problem Pin
Kevin Marois1-May-13 20:14
memberKevin Marois1-May-13 20:14 
AnswerRe: Tab Closing Problem Pin
Amitosh Swain3-May-13 4:49
memberAmitosh Swain3-May-13 4:49 
QuestionAsynchronous Call Using MVVM Pin
jonkjon29-Apr-13 10:21
memberjonkjon29-Apr-13 10:21 
AnswerRe: Asynchronous Call Using MVVM Pin
SledgeHammer0129-Apr-13 10:32
memberSledgeHammer0129-Apr-13 10:32 
GeneralRe: Asynchronous Call Using MVVM Pin
jonkjon29-Apr-13 10:48
memberjonkjon29-Apr-13 10:48 
Questionwin32 window as c# wpf control Pin
mkusnjer29-Apr-13 8:58
membermkusnjer29-Apr-13 8:58 
AnswerRe: win32 window as c# wpf control Pin
SledgeHammer0129-Apr-13 9:28
memberSledgeHammer0129-Apr-13 9:28 
GeneralRe: win32 window as c# wpf control Pin
mkusnjer30-Apr-13 5:19
membermkusnjer30-Apr-13 5:19 
GeneralRe: win32 window as c# wpf control Pin
SledgeHammer0130-Apr-13 10:58
memberSledgeHammer0130-Apr-13 10:58 
GeneralRe: win32 window as c# wpf control Pin
mkusnjer1-May-13 8:31
membermkusnjer1-May-13 8:31 
GeneralRe: win32 window as c# wpf control Pin
SledgeHammer011-May-13 10:46
memberSledgeHammer011-May-13 10:46 
GeneralRe: win32 window as c# wpf control Pin
mkusnjer1-May-13 12:11
membermkusnjer1-May-13 12:11 
GeneralRe: win32 window as c# wpf control Pin
SledgeHammer011-May-13 12:20
memberSledgeHammer011-May-13 12:20 
GeneralRe: win32 window as c# wpf control Pin
mkusnjer1-May-13 12:39
membermkusnjer1-May-13 12:39 
GeneralRe: win32 window as c# wpf control Pin
SledgeHammer011-May-13 13:00
memberSledgeHammer011-May-13 13:00 
GeneralRe: win32 window as c# wpf control Pin
mkusnjer1-May-13 13:24
membermkusnjer1-May-13 13:24 
AnswerRe: win32 window as c# wpf control Pin
Amitosh Swain3-May-13 4:33
memberAmitosh Swain3-May-13 4:33 
QuestionDynamically create radiobuttons under the group header that can span to N - number of groups Pin
Rajesh Sajjanar27-Apr-13 10:29
memberRajesh Sajjanar27-Apr-13 10:29 
AnswerRe: Dynamically create radiobuttons under the group header that can span to N - number of groups Pin
Kenneth Haugland27-Apr-13 12:32
professionalKenneth Haugland27-Apr-13 12:32 
AnswerRe: Dynamically create radiobuttons under the group header that can span to N - number of groups Pin
Mycroft Holmes27-Apr-13 13:06
professionalMycroft Holmes27-Apr-13 13:06 
QuestionIdeaBlade vs OData Pin
Super Lloyd25-Apr-13 18:36
memberSuper Lloyd25-Apr-13 18:36 
QuestionWPF Login in MVVM Issue Pin
KishoreUHG21-Apr-13 23:44
memberKishoreUHG21-Apr-13 23:44 
AnswerRe: WPF Login in MVVM Issue Pin
Mycroft Holmes21-Apr-13 23:50
professionalMycroft Holmes21-Apr-13 23:50 
GeneralRe: WPF Login in MVVM Issue Pin
KishoreUHG21-Apr-13 23:52
memberKishoreUHG21-Apr-13 23:52 
GeneralRe: WPF Login in MVVM Issue Pin
Mycroft Holmes21-Apr-13 23:59
professionalMycroft Holmes21-Apr-13 23:59 
GeneralRe: WPF Login in MVVM Issue Pin
KishoreUHG22-Apr-13 0:08
memberKishoreUHG22-Apr-13 0:08 
AnswerRe: WPF Login in MVVM Issue Pin
Wayne Gaylard22-Apr-13 1:44
mentorWayne Gaylard22-Apr-13 1:44 
AnswerRe: WPF Login in MVVM Issue Pin
KishoreUHG22-Apr-13 2:52
memberKishoreUHG22-Apr-13 2:52 
GeneralRe: WPF Login in MVVM Issue Pin
Mycroft Holmes22-Apr-13 12:59
professionalMycroft Holmes22-Apr-13 12:59 
QuestionWPF Simular to tree view Pin
Saksida Bojan21-Apr-13 9:52
memberSaksida Bojan21-Apr-13 9:52 
AnswerRe: WPF Simular to tree view Pin
Richard MacCutchan21-Apr-13 22:39
mvpRichard MacCutchan21-Apr-13 22:39 
GeneralRe: WPF Simular to tree view Pin
Saksida Bojan2-May-13 7:41
memberSaksida Bojan2-May-13 7:41 

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.


Advertise | Privacy | Mobile
Web01 | 2.8.160919.1 | Last Updated 22 Sep 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid