index > Windows Presentation Foundation ("Avalon") > Custom Window

Custom Window

I am creating a custom window that looks similar to the Office 2007 UI. I was able to create an appropriate ControlTemplate/Style with dragging and "Close", Maximize/Minimize buttons etc... But here' the question: What's the best approach to have it encapculated in the separate class/component so I can easily re-use this style for other windows in the app?




-- Alex Yakhnin, Device Application Developer MVP | http://blog.opennetcf.org/ayakhnin
AlexY

You could put the template and style into the App's resources, without a x:Key, and set the TargetType to {x:Type Window} to make every window in the app automatically use that style. Is that what you're looking for?




Josh Smith - http://www.infusionblogs.com/blogs/jsmith/default.aspx
Josh Smith
Yeah... this is what I've done as well, but how do I go about events? For example, I have the LeftButtonDown events for 3 elements that are doing window dragging, closing and maximizing and in the App.xaml.cs we don't know about the window's instance.


-- Alex Yakhnin, Device Application Developer MVP | http://blog.opennetcf.org/ayakhnin
AlexY
Probably you can inherit your own Window class from the stock Window and use it everywhere.
P.S. Have you implemented window mouse resizing functionality as well? Does it works fine?
EugeneZ

>Probably you can inherit your own Window class from the stock Window and use it everywhere.

AlexY
Alex, in v1.0 of WPF, you cannot subclass from a xaml generated class, probably this feature will be checked in in the v2.0.

Sheva



WPF C# & Other .Net Related Goodness http://shevaspace.spaces.live.com/
footballism

>I was thinking about that. Still trying to figure out how to declare XAML for the new window >that inherits from my custom window. This is what I am doing:

EugeneZ
If to take into view the thing Footbalism wrote, I would rather write the base class code in a procedural manner. In context of WPF it is quite inconvinient, but at least it probably will work.
EugeneZ
Yeah... IMO, this kinda defeats the whole XAML useability.


-- Alex Yakhnin, Device Application Developer MVP | http://blog.opennetcf.org/ayakhnin
AlexY
Well, Alex, one ulgy trick you can do here is that, you define the OfficeWindow class in the standalone assembly, and apply the following attribute:
footballism
reply 10

You can use google to search for other answers

 

More Articles

• XBAP application not picking relative path
• How is the control to which externals are dynamically changed mad...
• PrintTicket.PageOrientation does not have an effect
• I want trap attached property change notify.
• Cannot re-initialize ResourceDictionary instance. Error at object...
• Sharing ControlTemplate
• How to apply Sorting in a List view control???
• How can I get the Drawing of a Button for rendering on an Adorner...
• Dynamic databind in Expressive Interactive Designer
• Event happening twice
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• ObservableCollection for IList
• how to get the values back from DataGrid
• What is the meaning of double "?&q
• about WindowsFormsHost
• Problem with MergedDictionaries and Elem
• WPF Text blurry
• Frame.set_Source throws NullReferenceExc
• Frame Disappearing on Clicking the ListV
• MouseEnter + grid row + animation problem
• PrintTicket.PageOrientation does not hav
• Elements wrapping in Panel
• Possible Bug.... WPF throws excpetion wh
• Strange problem while displaying Visuals
• How to bind a collection directly to a c
• Distance between 3d objects / world coor

Hot Articles

• Navigation between pages
• How To Get Element within a Listview Cel
• Implementing INotifyPropertyChanged with
• Importing a DirectX mesh (.x file) into
• Raising an event when a Storyboard hits
• Opening Window in WPF application
• How: Animation when item of a ListView g
• Missing references in basic WPF example
• Moving objects around in a Viewport3D us
• Problem in Listview
• WPF apps slow for some reason
• How does one implement a Validation temp
• Terminal Server and WPF
• EMF or WMF export
• forms authentication with wba

Recommend Articles

• Line break in textbox
• XAML Namespace Mapping
• Vertical lines in the GridView
• What's the recommended way to save an bi
• Dynamic diagram creation
• Access sub-properties in <Setter/>
• Writing a string property value as a CDA
• How to get StoryBoard name in its Comple
• DoubleClick on FrameworkElement
• Is it possible to do a MasterDetail Bind
• Take a window screenshot with borders
• Memory Leak Discovered
• WPF application template....
• How is AutoComplete in TextBox mounted?
• Providing alternate styles for a control