Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
My existential question about WPF
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Aline Paponaud  
View profile  
 More options Jun 16 2008, 4:44 pm
From: "Aline Paponaud" <boo...@gmail.com>
Date: Mon, 16 Jun 2008 22:44:28 +0200
Local: Mon, Jun 16 2008 4:44 pm
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.

Aline


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mike Brown  
View profile  
 More options Jun 16 2008, 5:13 pm
From: "Mike Brown" <mbrow...@gmail.com>
Date: Mon, 16 Jun 2008 17:13:54 -0400
Local: Mon, Jun 16 2008 5:13 pm
Subject: Re: My existential question about WPF

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!

--Mike


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Aline Paponaud  
View profile  
 More options Jun 16 2008, 5:26 pm
From: "Aline Paponaud" <boo...@gmail.com>
Date: Mon, 16 Jun 2008 23:26:59 +0200
Local: Mon, Jun 16 2008 5:26 pm
Subject: Re: My existential question about WPF

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?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Laurent Bugnion [MVP, MCP]  
View profile  
 More options Jun 16 2008, 5:34 pm
From: "Laurent Bugnion [MVP, MCP]" <laur...@galasoft.ch>
Date: Mon, 16 Jun 2008 23:34:42 +0200
Local: Mon, Jun 16 2008 5:34 pm
Subject: Re: My existential question about WPF
Salut Aline,

Wow, enfin je peux parler de WPF en français!! Ca fait du bien :)

Bon, on ne va pas ennuyer nos amis ricains plus longtemps? Sorry guys,
back to EN :)

The classic answer to the "Why shouldn't I subclass" answer is Kevin
Moore's post:
http://work.j832.com/2007/06/don-subclass-panel-unless-you-making.html

In short, markup subclassing is bad.

That said, you can subclass in code, for example to add specific
functionality. About this, see my (I hope) classic post:

http://blog.galasoft.ch/archive/2007/03/02/107747.aspx

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" :)

Bien du plaisir,
Laurent

--
Laurent Bugnion [Microsoft MVP, MCP]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Laurent Bugnion [MVP, MCP]  
View profile  
 More options Jun 16 2008, 5:39 pm
From: "Laurent Bugnion [MVP, MCP]" <laur...@galasoft.ch>
Date: Mon, 16 Jun 2008 23:39:35 +0200
Local: Mon, Jun 16 2008 5:39 pm
Subject: Re: My existential question about WPF
Hi again,

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.

Friendly,
Laurent

--
Laurent Bugnion [Microsoft MVP, MCP]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sacha Barber  
View profile  
 More options Jun 17 2008, 4:19 am
From: Sacha Barber <sachabar...@hotmail.com>
Date: Tue, 17 Jun 2008 08:19:58 +0000
Local: Tues, Jun 17 2008 4:19 am
Subject: RE: My existential question about WPF

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.

This is described in this post

http://forums.msdn.microsoft.com/en-US/wpf/thread/80eb3f57-9907-4bf7-...

Pay close attention to the comment from Marco Zhou

Laurent also has a nice post about inheriting from a custom Window. check out

http://geekswithblogs.net/lbugnion/archive/2007/03/02/107747.aspx

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.

Aline

_________________________________________________________________

http://clk.atdmt.com/UKM/go/msnnkmgl0010000002ukm/direct/01/

[ 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
    }

  ucWizardPanelBase.xaml
3K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google