In regards to Question #1, your BaseNode needs to PROPERLY implement INotifyPropertyChanged on the Header and List properties.
In regards to Question #2, yes, the IsExpanded property is in the TreeViewItem. HierarchialDataTemplate doesn't support binding to that out of the box. However, you can easily derive a class HierachialDataTemplateEx which exposes an IsExpanded property and override the ValidateTemplatedParent method and bind it to TreeViewItem.
But I'm stuck after that. Can you continue my code and point me in the correct direction?
Also I got some further question for this solution:
1) Does this mean I need to stop using my BaseNode class and use TreeViewItem instead?
2) Using an derived version of HierarchicalDataTemplate class, does this mean my XAML code for the TreeView must be altered?
The way you have it set up above, you'll only be able to control the IsExpanded "once" (at creation of the node). I.e. create a node expanded. If that is not sufficient and you need to be able to expand and collapse at will, you'll need to go a slightly different route. It is more complicated, so I won't go into that unless you need it .
Yes, you will need to slightly modify your XAML (assuming your namespace is local):
In your ValidateTemplateParent() method, you just do something like:
// set the properties on the TreeViewItem
if ((object)templatedParent != null)
TreeViewItem tvi = templatedParent.TemplatedParent as TreeViewItem;
if ((object)tvi != null)
tvi.IsExpanded = IsExpanded;
That should be sufficient for most use cases (creating a node in its expanded state). As I mentioned above, you need to do additional stuff if you need to control expansion state dynamically or get the node expansion state at runtime for saving expansion state, etc.
However, this basic way will let you for example create the top level expanded and the rest of the levels collapsed.
I am building a WPF application in which I need to do some OCR. I understand that it is possible to use the Microsoft Office Document Imaging 12.0 Type Library in Office 2007. However, I want my application to run also without office 2007 installed. Is there a separate download of Microsoft Office Document Imaging 12.0 Type Library that I can use for this purpose. I assume that all I need to do is to reference the appropriate dll in my application - correct?
NOTE: in local system my WPF Application working Fine.
Local system having Office 2007. but i want to run with out office..
Microsoft Office Document Imaging (MODI) is a discontinued Microsoft Office application that supports editing documents scanned by Microsoft Office Document Scanning. It is first introduced in Microsoft Office XP and is included in Office 2003...
The description clearly indicates what you should be doing now...
It is not available as a separate product anywhere, even not in later versions of office
When I run the app, it crashes and throws the following exception which can be investigated in the Application_UnhandledException handler in the App.xaml.cs.
Error HRESULT E_FAIL has been returned from a call to a COM component.
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
at MS.Internal.XcpImports.FrameworkElement_MeasureOverride(FrameworkElement element, Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth
Note: If I reduce the amount of hierarchy layers of the box collection, everything works fine.
Please help, I have been struggling for several days. I cannot find anything in forums or blogs.
All or some of the text can be a hyperlink, with different commands bound to the links. The content of the messages will be automatically generated.
My first thought was have a table like this:
ImageName MessageDate Message ================================================================================================================
vehicle.jpg 2014-05/06 Vehicle Ford F150 Serial # ^L^256565^L^ has maintenance item ^L^Oil Change^L^ ready.
So it would look like:
"Vehicle Ford F150 Serial # 256565 has maintenance item Oil Change ready."
Clicking the serial # would open the vehicle screen. The Oil Change link would open the Maintenance screen.
I would then need to include in the message an action for each link. Like the link symbol, I could follow it with an enum item to denote what type of screen to open. And I would also need the PK's in there also.
Then, when the dashboard item is loaded, it would use a flow panel with both text and links in the data template so the Message column can wrap.
All this is fine, but it feels weird. Anyone done anything like this? Anyone got a better approach?
Exactly, but it seems that you just happened to use the correct word. System.Action is the class to use, or (more typical in WPF) a Command object (take a look at the Command Pattern). When the link is clicked, you call the Invoke() method of the Action object.
I am currently developing an application but I need to have to switch between two languages , but I can't do it .
In fact , I created two Resources files for both languages and I set them to public and then then I put the propertie to Static as mentioned in many tutorials .
Thank you so much for your help.
My code written :
if (Presentation.ViewModels.LoginWindow.LanguageSelect != null)
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("it-IT");
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");
Console.WriteLine("Verify the choosig langa=uage!");
I am creating a user control. I will be using this user control in a few different apps. Once it's done I'll include its assembly in my project, reference it, and use it in my XAML somewhere. Pretty standard.
The question is... How do I apply a different set of styles to it based on the app I'm in?
The simplest way to achieve this is to have application level themes. In other words, in App A - you would set the styles for your control to be the ones you want in App A; in App B you set the styles for the control based on the ones you want in App B, and so on. Make sure you have a default theme for your control in place as well.
1.You can create a seperate styles for appA, Appb... and apply the theme accordingly as a staticresource.
2.Suppose in same application you want different theme based on some action then just use the above mentioned idea and apply themes using Dynamicresource.