Hello everyone, I am new in this list and am following your interesting conversations. I didn't take the time to send a "hello world" message. Then, it's done.
Well i am really a noob at WPF and, more generally, development. Actually i just finished my studies and started working on a project that uses WPF in my new company. I have a quite good theoretical background (about oo design, and abt the structure and the theory of a IT development project in general). Then, developing with WPF is very complicated for me. I know Windows forms and have already fulfilled little projects using this technology. Now i feel lost...
So my existential question is: - Why is there no inheritance possible in *graphical* terms; i mean if i have a baseclass which is a usercontrol defined in xaml, why can't I create a usercontrol, defined in xaml too, which inherits from it, and use the designer to add some specific controls in my child class for example? And... Why do i feel so alone with this problem? Is there a "new" way to design user interfaces (using interface implementations instead of inheritance, ...) and why? Was I wrong during my studies doing my little projects and designing my UIs that way (with inheritance everywhere there was something common... It worked well with winforms...) Don't hesitate to tell me that my question is stupid ;-) but only if you explain me why ;-)
And, to answer the "who are you" subject: my name is Aline, i am a French developer, and will finish my studies (with the end of my internship) the 26th June. and then i will be hired in the company i did my training in. I am a geek, and a geek girlfriend too. My friends are geeks (Jeremy Alles invited me in this group), my parents are geeks, even my cat is a geek. My sister too, and her boyfriend too. I love linux and free software, and discovered WPF and the Microsoft world only because it is the most used in companies. (and, unfortunately for my great ideas and for the Free Software Song, i think companies are right... Sorry, RMS) Except that, I am currently discovering French culture, operas, books, theater, because I actually was geeking during French lessons at school.
That's all! Thanks in advance for the answers... and hope i am not too ridiculous with it.
The big difference with WPF compared to Winforms is that you don't have to use inheritance to modify the Look and Feel of a control. With attached properties, in many cases you don't have to use inheritance to add new behavior to a control.
I forget the reason I was told that UserControls can't be extended in WPF, but even if you could, you probably wouldn't want to. I've found that people have gotten a little "is a" crazy when they should be thinking in "has a" terms. It's the classic diamond example when people talk of the "pitfalls" of multiple inheritance. I have a horse and a bird that both inherit from animal. If I add Pegasus to the picture, I have a bird that is a horse or a horse that is a bird. If you look at it a different way...a Pegasus is a Horse that "has" wings, or that can fly, it's not a problem at all. This "pitfall" not a problem with MI per se...it's a problem with using inheritance, when you should use containment.
What if you could take the functionality of a bird being able to fly and attach it to a horse...without extending horse? This is what attached properties give in WPF. One example I give on my blog is a GridView that doesn't have sorting out of the box. Instead of inheriting from GridView to make a SortableGridView, you can attach the capability to sort onto the existing GridView.
Back to UserControls, there are several solutions to your problem depending on the circumstances. All of them require you to think of WPF from a new perspective. If you can give an example (genericized if need be) of why you feel you need to inherit a usercontrol from another, we can definitely help. Welcome aboard and happy trails!
I think I might read that book that is on my desk, actually, and i will understand this new dependency property huge concept.
Now the thing is: with a very theoretical Object Oriented design (without thinking about what technology or language or framework we are using), i think we cannot use or make the dependency property and "has a"/"is a" choice correctly... The design has to be made in a WPF way. it is a real revolution in the architecture world! Because we will have to think our classes and design, knowing that it will be WPF. (i think we didn't do that before, we were just designing classes using UML or whatever and then, code it, and the program had exactly the same behavior if it is windows forms or java or something else). Maybe it is a little exagerated, but is Microsoft proposing here something very new and, finally, different from a "pure" object-oriented language?
On Mon, Jun 16, 2008 at 11:13 PM, Mike Brown <mbrow...@gmail.com> wrote: > The big difference with WPF compared to Winforms is that you don't have to > use inheritance to modify the Look and Feel of a control. With attached > properties, in many cases you don't have to use inheritance to add new > behavior to a control.
> I forget the reason I was told that UserControls can't be extended in WPF, > but even if you could, you probably wouldn't want to. I've found that people > have gotten a little "is a" crazy when they should be thinking in "has a" > terms. It's the classic diamond example when people talk of the "pitfalls" > of multiple inheritance. I have a horse and a bird that both inherit from > animal. If I add Pegasus to the picture, I have a bird that is a horse or a > horse that is a bird. If you look at it a different way...a Pegasus is a > Horse that "has" wings, or that can fly, it's not a problem at all. This > "pitfall" not a problem with MI per se...it's a problem with using > inheritance, when you should use containment.
> What if you could take the functionality of a bird being able to fly and > attach it to a horse...without extending horse? This is what attached > properties give in WPF. One example I give on my blog is a GridView that > doesn't have sorting out of the box. Instead of inheriting from GridView to > make a SortableGridView, you can attach the capability to sort onto the > existing GridView.
> Back to UserControls, there are several solutions to your problem depending > on the circumstances. All of them require you to think of WPF from a new > perspective. If you can give an example (genericized if need be) of why you > feel you need to inherit a usercontrol from another, we can definitely help. > Welcome aboard and happy trails!
And yes, like Mike says, most of the time you don't need to because you can modify the L&F of the element using templates. And also, you can add your own DependencyProperties to implement new functionality.
Le plus grand challenge avec WPF, c'est de "désapprendre" ce qu'on sait des technologies "classiques" :)
Aline Paponaud wrote: > Hello everyone, > I am new in this list and am following your interesting conversations. > I didn't take the time to send a "hello world" message. Then, it's done.
> Well i am really a noob at WPF and, more generally, development. > Actually i just finished my studies and started working on a project > that uses WPF in my new company. I have a quite good theoretical > background (about oo design, and abt the structure and the theory of a > IT development project in general). Then, developing with WPF is very > complicated for me. > I know Windows forms and have already fulfilled little projects using > this technology. Now i feel lost...
> So my existential question is: > - Why is there no inheritance possible in /graphical/ terms; i mean if > i have a baseclass which is a usercontrol defined in xaml, why can't I > create a usercontrol, defined in xaml too, which inherits from it, and > use the designer to add some specific controls in my child class for > example? > And... Why do i feel so alone with this problem? Is there a "new" way > to design user interfaces (using interface implementations instead of > inheritance, ...) and why? Was I wrong during my studies doing my > little projects and designing my UIs that way (with inheritance > everywhere there was something common... It worked well with winforms...) > Don't hesitate to tell me that my question is stupid ;-) but only if > you explain me why ;-)
> And, to answer the "who are you" subject: my name is Aline, i am a > French developer, and will finish my studies (with the end of my > internship) the 26th June. and then i will be hired in the company i > did my training in. > I am a geek, and a geek girlfriend too. My friends are geeks (Jeremy > Alles invited me in this group), my parents are geeks, even my cat is > a geek. My sister too, and her boyfriend too. > I love linux and free software, and discovered WPF and the Microsoft > world only because it is the most used in companies. (and, > unfortunately for my great ideas and for the Free Software Song, i > think companies are right... Sorry, RMS) > Except that, I am currently discovering French culture, operas, books, > theater, because I actually was geeking during French lessons at school.
> That's all! > Thanks in advance for the answers... and hope i am not too ridiculous > with it.
While it's true that WPF is very new in many ways, DependencyProperties (DPs) are actually a "has" relationship between objects, but with something more. The WPF property system adds much functionality (such as a built-in controller to help you realize a MVC pattern), but you can actually inherit DependencyObjects to represent your datas in an UML way. Note that there was a long discussion in this group about using DOs and DPs versus using "normal" CLR objects and something called INotifyPropertyChanged. Check the group's archive and you'll find it.
Where do you live? I am in Zurich, though I was born in Lausanne.
Aline Paponaud wrote: > Thanks a lot, now I understand...
> I think I might read that book that is on my desk, actually, and i > will understand this new dependency property huge concept.
> Now the thing is: with a very theoretical Object Oriented design > (without thinking about what technology or language or framework we > are using), i think we cannot use or make the dependency property and > "has a"/"is a" choice correctly... The design has to be made in a WPF > way. it is a real revolution in the architecture world! Because we > will have to think our classes and design, knowing that it will be > WPF. (i think we didn't do that before, we were just designing classes > using UML or whatever and then, code it, and the program had exactly > the same behavior if it is windows forms or java or something else). > Maybe it is a little exagerated, but is Microsoft proposing here > something very new and, finally, different from a "pure" > object-oriented language?
> On Mon, Jun 16, 2008 at 11:13 PM, Mike Brown <mbrow...@gmail.com > <mailto:mbrow...@gmail.com>> wrote:
> The big difference with WPF compared to Winforms is that you don't > have to use inheritance to modify the Look and Feel of a control. > With attached properties, in many cases you don't have to use > inheritance to add new behavior to a control.
> I forget the reason I was told that UserControls can't be extended > in WPF, but even if you could, you probably wouldn't want to. I've > found that people have gotten a little "is a" crazy when they > should be thinking in "has a" terms. It's the classic diamond > example when people talk of the "pitfalls" of multiple > inheritance. I have a horse and a bird that both inherit from > animal. If I add Pegasus to the picture, I have a bird that is a > horse or a horse that is a bird. If you look at it a different > way...a Pegasus is a Horse that "has" wings, or that can fly, it's > not a problem at all. This "pitfall" not a problem with MI per > se...it's a problem with using inheritance, when you should use > containment.
> What if you could take the functionality of a bird being able to > fly and attach it to a horse...without extending horse? This is > what attached properties give in WPF. One example I give on my > blog is a GridView that doesn't have sorting out of the box. > Instead of inheriting from GridView to make a SortableGridView, > you can attach the capability to sort onto the existing GridView.
> Back to UserControls, there are several solutions to your problem > depending on the circumstances. All of them require you to think > of WPF from a new perspective. If you can give an example > (genericized if need be) of why you feel you need to inherit a > usercontrol from another, we can definitely help. Welcome aboard > and happy trails!
Actually you can inherit a usercontrol from another usercontrol in WPF I do just that.
Check the attached out
What is NOT possible is to use a wplit XAML/Cs class that inherits from another split XAML/CS class. This is a shortfall with the current version of WPF and the designers.
Date: Mon, 16 Jun 2008 22:44:28 +0200 From: boo...@gmail.com To: wpf-disciples@googlegroups.com Subject: My existential question about WPF
Hello everyone, I am new in this list and am following your interesting conversations. I didn't take the time to send a "hello world" message. Then, it's done.
Well i am really a noob at WPF and, more generally, development. Actually i just finished my studies and started working on a project that uses WPF in my new company. I have a quite good theoretical background (about oo design, and abt the structure and the theory of a IT development project in general). Then, developing with WPF is very complicated for me.
I know Windows forms and have already fulfilled little projects using this technology. Now i feel lost...
So my existential question is: - Why is there no inheritance possible in graphical terms; i mean if i have a baseclass which is a usercontrol defined in xaml, why can't I create a usercontrol, defined in xaml too, which inherits from it, and use the designer to add some specific controls in my child class for example?
And... Why do i feel so alone with this problem? Is there a "new" way to design user interfaces (using interface implementations instead of inheritance, ...) and why? Was I wrong during my studies doing my little projects and designing my UIs that way (with inheritance everywhere there was something common... It worked well with winforms...)
Don't hesitate to tell me that my question is stupid ;-) but only if you explain me why ;-)
And, to answer the "who are you" subject: my name is Aline, i am a French developer, and will finish my studies (with the end of my internship) the 26th June. and then i will be hired in the company i did my training in.
I am a geek, and a geek girlfriend too. My friends are geeks (Jeremy Alles invited me in this group), my parents are geeks, even my cat is a geek. My sister too, and her boyfriend too. I love linux and free software, and discovered WPF and the Microsoft world only because it is the most used in companies. (and, unfortunately for my great ideas and for the Free Software Song, i think companies are right... Sorry, RMS)
Except that, I am currently discovering French culture, operas, books, theater, because I actually was geeking during French lessons at school.
That's all! Thanks in advance for the answers... and hope i am not too ridiculous with it.
[
ucEncoreMain.cs 1K ] using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace EncoreWizard
{
public class ucEncoreMain : ucWizardPanelBase
{
public ucEncoreMain() : this(null)
{
}
public ucEncoreMain(IFadable parent) : base(parent)
{
//as this is 1st main form, set these 2 properties to empty
(this as IFadable).HostWindowLogoUrl = string.Empty;
(this as IFadable).HostWindowTitleText = string.Empty;
(this as IFadable).HostWindowBreadCrumbText = "Encore Home";
this.Loaded += delegate
{
lblSubTitle.Content = "Good Morning Colin, you have the following activities available to you";
CreateWizardButton("View Performance Management Stats with Optima", "../Images/arrow.png", null);
CreateWizardButton("View Configuration Data with Datasafe", "../Images/arrow.png", null);
CreateWizardButton("Begin Tranmission and Network Element Planning with Conductor", "../Images/arrow.png", new ucConductor1(this));
CreateWizardButton("Begin Radio Planning With Asset", "../Images/arrow.png", null);
};
}
}
[
ucWizardPanelBase.xaml.cs 6K ] using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace EncoreWizard
{
/// <summary>
/// Provides a base class for Wizard Panels to inherit from.
/// Where this base class provides a fading out of itself which
/// eventually raises the IFadable.FadeOutComplete event.
/// All Wizard buttons should be added using the /// </summary>
public partial class ucWizardPanelBase : UserControl, IFadable
{
#region Ctors
public ucWizardPanelBase()
{
InitializeComponent();
spItems.Children.Clear();
}
public ucWizardPanelBase(IFadable parent)
{
InitializeComponent();
spItems.Children.Clear();
(this as IFadable).Parent = parent;
}
#endregion
#region Public Properties
public bool IsAnimating { get; set; }
public IFadable NewControl { get; private set; }
#endregion
#region Protected Methods
/// <summary>
/// Returns a new new Button with an image some text and also associated the next
/// control to be shown with the button, such that the host Window will know what
/// control to show next
/// </summary>
protected virtual void CreateWizardButton(string text, string imageUrl, IFadable GotoControl)
{
Button btn = new Button
{
Content = text,
Tag = imageUrl
};
btn.SetValue(WizardButtonProps.ToControlProperty, GotoControl);
Style wizButtonStyle = this.TryFindResource("wizButtonStyle") as Style;
if (wizButtonStyle != null)
btn.Style = wizButtonStyle;
//return the button
spItems.Children.Add(btn);
}
#endregion
#region Private Methods
//Find the fade out StoryBoard and fade out current control, when done
//raise the FadeOutComplete event
private void DoFadeOut()
{
Storyboard fadeStoryBoard = this.TryFindResource("FadeOutStoryBoard") as Storyboard;
if (fadeStoryBoard != null)
{
fadeStoryBoard.Completed += new EventHandler(fadeStoryBoard_Completed);
fadeStoryBoard.Begin(this);
}
}
/// <summary>
/// Obtain the new control for the selected item and then
/// begin the fade out and raise the FadeOutComplete event
/// using the new control to show wihin the <see cref="FadeEventArgs">
/// FadeEventArgs</see>
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void spItems_Click(object sender, RoutedEventArgs e)
{
if (!IsAnimating)
{
Button btn = e.OriginalSource as Button;
NewControl = btn.GetValue(WizardButtonProps.ToControlProperty) as IFadable;
if (NewControl != null)
DoFadeOut();
}
}
/// <summary>
/// Raise the FadeOutComplete event when the fade out is done
/// </summary>
private void fadeStoryBoard_Completed(object sender, EventArgs e)
{
OnFadeOutComplete(new FadeEventArgs(NewControl));
}
/// <summary>
/// The actual fadeComplete event to alert host window to navigate to
/// new control
/// </summary>
protected virtual void OnFadeOutComplete(FadeEventArgs e)
{
if (FadeOutComplete != null)
{
IsAnimating = false;
FadeOutComplete(this, e);
}
}
#endregion
#region IFadable Members
public event FadeOutHandler FadeOutComplete;
public string HostWindowLogoUrl { get; set; }
public string HostWindowTitleText { get; set; }
public string HostWindowBreadCrumbText { get; set; }
public new IFadable Parent { get; set; }
#endregion
}