Click here to Skip to main content
15,887,450 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Virtual classroom using silverlight Pin
Pete O'Hanlon4-Sep-13 5:45
mvePete O'Hanlon4-Sep-13 5:45 
QuestionWPF TreeView on a Windows 8 Tablet Pin
Kevin Marois3-Sep-13 6:56
professionalKevin Marois3-Sep-13 6:56 
AnswerRe: WPF TreeView on a Windows 8 Tablet Pin
Pete O'Hanlon3-Sep-13 10:12
mvePete O'Hanlon3-Sep-13 10:12 
GeneralRe: WPF TreeView on a Windows 8 Tablet Pin
Kevin Marois3-Sep-13 10:37
professionalKevin Marois3-Sep-13 10:37 
QuestionHow to avoid repeating dynamic tabitem at runtime? Pin
LAPEC2-Sep-13 15:07
LAPEC2-Sep-13 15:07 
AnswerRe: How to avoid repeating dynamic tabitem at runtime? Pin
Pete O'Hanlon2-Sep-13 19:25
mvePete O'Hanlon2-Sep-13 19:25 
GeneralRe: How to avoid repeating dynamic tabitem at runtime? Pin
LAPEC3-Sep-13 1:46
LAPEC3-Sep-13 1:46 
GeneralRe: How to avoid repeating dynamic tabitem at runtime? Pin
Pete O'Hanlon3-Sep-13 2:02
mvePete O'Hanlon3-Sep-13 2:02 
The tabs are there - all you need to do is search through your ObservableCollection of tabs and see if there's one of the type you want to create. That's what I was alluding to. A naive implementation would be something like this:
C#
if (viewType == "Users")
{
  foreach (var tab in ObservableCollectionTabItems)
  {
    if (tab is VMUserExplorer)
      return;
  }
  // The rest of your processing occurs here.
}
You could simplify this somewhat so that your AddTab and constructor looks like this :
C#
private Dictionary<string, VMParentForViews> viewsDictionary = new Dictionary<string, VMParentForViews>();
public VMBackOfficeWindow()
{
  ObservableCollectionTabItems = new ObservableCollection<VMParentForViews>();
  viewsDictionary.Add("Users", new VMUserExplorer());
  viewsDictionary.Add("Category Explorer", new VMCategoryExplorer());
}
public void AddTab(string viewType)
{
  VMParentForViews vm = viewsDictionary[viewType];
  Type vmType = vm.GetType();
  foreach (var tab in ObservableCollectionTabItems)
  {
    if (tab.GetType() == vmType)
      return;
  }
  ObservableCollectionTabItems.Add(vm);
  // Carry on processing here.
}
Again, it's still a relatively naive solution, and relies an awful lot on things like string matching and the likes, but it should serve to suffice. If I were doing this, I would go for a much more decoupled approach - you have started some of the way towards this, but there's still a long way to go to get it DI and MVVM.

GeneralRe: How to avoid repeating dynamic tabitem at runtime? Pin
LAPEC3-Sep-13 3:12
LAPEC3-Sep-13 3:12 
GeneralRe: How to avoid repeating dynamic tabitem at runtime? Pin
Pete O'Hanlon3-Sep-13 3:59
mvePete O'Hanlon3-Sep-13 3:59 
QuestionMVVM pattern Pin
columbos1492731-Aug-13 18:46
columbos1492731-Aug-13 18:46 
AnswerRe: MVVM pattern Pin
SledgeHammer013-Sep-13 9:56
SledgeHammer013-Sep-13 9:56 
GeneralRe: Prism Quick Starts Pin
NotPolitcallyCorrect30-Aug-13 4:29
NotPolitcallyCorrect30-Aug-13 4:29 
QuestionHow to force refresh of images being cached in Silverlight Deep Zoom app? Pin
Member 297027028-Aug-13 6:04
Member 297027028-Aug-13 6:04 
AnswerRe: How to force refresh of images being cached in Silverlight Deep Zoom app? Pin
Jason Gleim28-Aug-13 7:49
professionalJason Gleim28-Aug-13 7:49 
GeneralRe: How to force refresh of images being cached in Silverlight Deep Zoom app? Pin
Member 297027028-Aug-13 8:14
Member 297027028-Aug-13 8:14 
GeneralRe: How to force refresh of images being cached in Silverlight Deep Zoom app? Pin
Jason Gleim28-Aug-13 8:18
professionalJason Gleim28-Aug-13 8:18 
GeneralRe: How to force refresh of images being cached in Silverlight Deep Zoom app? Pin
Member 297027028-Aug-13 8:44
Member 297027028-Aug-13 8:44 
GeneralRe: How to force refresh of images being cached in Silverlight Deep Zoom app? Pin
Jason Gleim28-Aug-13 8:54
professionalJason Gleim28-Aug-13 8:54 
QuestionCan someone explain this PRISM concept? Pin
SledgeHammer0127-Aug-13 8:39
SledgeHammer0127-Aug-13 8:39 
QuestionAssign a null value to DateTime property Pin
maxRazar26-Aug-13 21:00
maxRazar26-Aug-13 21:00 
AnswerRe: Assign a null value to DateTime property Pin
Pete O'Hanlon26-Aug-13 23:02
mvePete O'Hanlon26-Aug-13 23:02 
GeneralRe: Assign a null value to DateTime property Pin
maxRazar28-Aug-13 5:57
maxRazar28-Aug-13 5:57 
GeneralRe: Assign a null value to DateTime property Pin
Pete O'Hanlon28-Aug-13 21:56
mvePete O'Hanlon28-Aug-13 21:56 
AnswerRe: Assign a null value to DateTime property Pin
Jason Gleim27-Aug-13 5:30
professionalJason Gleim27-Aug-13 5:30 

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.