Click here to Skip to main content
Click here to Skip to main content

WPF Master Pages

By , 21 Jan 2008
 

Introduction

One of the really great enhancements in ASP.NET was the introduction of master pages. They help developers to create a consistent layout for the pages in an application. Unfortunately, there is no such concept in WPF and XAML. In the following sample, I would like to show a simple way to build a control in WPF similar to an ASP.NET master page.

Layout in WPF

My goal is to build a simple WPF application with three pages. Each of the pages should consist of three areas:

  1. A title
  2. An abstract
  3. The main content

The screenshot shows the first page of the application. In this case, all three areas contain some text. But as we will see later in the sample, we are not limited to text.

If I would build this page without using a master page, I would start with a new blank page and then I would arrange different types of controls on this page. I used Stackpanels and a Grid to arrange the logo and the three types of content on the page.

<Page x:Class="MasterPages.Page.PageWithoutMaster"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="PageWithoutMaster">
  <Page.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="../Style/Logo.xaml" />
        <ResourceDictionary Source="../Style/Standard.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Page.Resources>
  
  <StackPanel>
    <Grid Height="70">
      <Image Source="{StaticResource SoftwareArchitectsLogoBackground}"
        Stretch="Fill" />
      <Grid Margin="10">
        <Image Source="{StaticResource SoftwareArchitectsLogo}" 
          HorizontalAlignment="Left" />
      </Grid>
    </Grid>
    <StackPanel Margin="10">
      <TextBlock Style="{StaticResource Title}">
        About us
      </TextBlock>
      <TextBlock Style="{StaticResource Abstract}">
        software architects builds a ...
      </TextBlock>
      <TextBlock>
        In the long term software architects ...
      </TextBlock>
    </StackPanel>
  </StackPanel>
</Page>

This works very well for one single page, but when adding new pages I have to care about including the general layout code consistently. And it really gets bad when I would like to change the layout after building lots of pages. To avoid this problem, I would like to have something similar to ASP.NET master pages in my WPF projects.

Building a Master Page

The basis for my master page is a new custom control named Master in my project. I added three dependency properties:

  1. Title
  2. Abstract
  3. Content

Each property represents one area in my master page. The datatype for the dependency properties is object. This ensures that I cannot only add text but also controls to each area in the page.

namespace MasterPages.Master
{
  public class Master : Control
  {
    static Master()
    {
      DefaultStyleKeyProperty.OverrideMetadata(typeof(Master), 
        new FrameworkPropertyMetadata(typeof(Master)));
    }

    public object Title
    {
      get { return (object)GetValue(TitleProperty); }
      set { SetValue(TitleProperty, value); }
    }

    public static readonly DependencyProperty TitleProperty =
      DependencyProperty.Register("Title", typeof(object), 
      typeof(Master), new UIPropertyMetadata());

    public object Abstract
    {
      get { return (object)GetValue(AbstractProperty); }
      set { SetValue(AbstractProperty, value); }
    }

    public static readonly DependencyProperty AbstractProperty =
      DependencyProperty.Register("Abstract", typeof(object), 
      typeof(Master), new UIPropertyMetadata());

    public object Content
    {
      get { return (object)GetValue(ContentProperty); }
      set { SetValue(ContentProperty, value); }
    }

    public static readonly DependencyProperty ContentProperty =
      DependencyProperty.Register("Content", typeof(object), 
      typeof(Master), new UIPropertyMetadata());
  }
}

As you may know, WPF does not add layout information into the class implementing a custom control like Master. The content of the file generic.xaml defines the look of the control. This file is automatically created by Visual Studio as soon as you add a custom control to your project.

In my case, I defined a style for my new class Master in generic.xaml. This is the place where the arrangement of the areas should happen. Just as in the single page before I used Stackpanels and Grids to arrange the logo and all the other parts of the page. The key to include the content of the dependency properties is the control ContentPresenter. I inserted three of them and bound them to the three dependency properties of the Master class.

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:MasterPages.Master">

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Style/Logo.xaml" />
    <ResourceDictionary Source="Style/Master.xaml" />
  </ResourceDictionary.MergedDictionaries>

  <Style TargetType="{x:Type local:Master}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type local:Master}">
          <StackPanel>
            <Grid Height="70">
              <Image 
                Source="{StaticResource SoftwareArchitectsLogoBackground}"
                Stretch="Fill" />
              <Grid Margin="10">
                <Image Source="{StaticResource SoftwareArchitectsLogo}" 
                  HorizontalAlignment="Left" />
              </Grid>
            </Grid>
            <StackPanel Margin="10">
              <ContentPresenter Content="{TemplateBinding Title}" 
                Style="{StaticResource Title}" />
              <ContentPresenter Content="{TemplateBinding Abstract}" 
                Style="{StaticResource Abstract}" />
              <ContentPresenter Content="{TemplateBinding Content}" />
            </StackPanel>
          </StackPanel>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>

I added some ResourceDictionary objects to the generic.xaml for my more complex styles like the logo, which is entirely built in XAML.

Now our master page is ready to use. All we had to do was to:

  • Insert a new custom control
  • Add a dependency property for each area of the page
  • Define the layout of the control in the file generic.xaml

Using the Master Page

Finally we are able to build a new page based on the master page. Therefore we need a reference to the Master class in our WPF file: xmlns:m="clr-namespace:MasterPages.Master". I chose the prefix m for my Master class. With this prefix, I can add a new instance of Master to the page. Inside of <m:Master> I can set the Title, the Abstract and the Content property of the class.

<Page x:Class="MasterPages.Page.Page1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:m="clr-namespace:MasterPages.Master"
  Title="Page1">
  <m:Master>
    <m:Master.Title>
      About us
    </m:Master.Title>
    <m:Master.Abstract>
      software architects builds a new generation of ...
    </m:Master.Abstract>
    <m:Master.Content>
      In the long term software architects will offer ...
    </m:Master.Content>
  </m:Master>
</Page>

In this case, I only used text but as you can see in the next sample I am not limited to text.

To show the advantage of a master page, I added a second page to my project. Again I do not have to care about layout any more. I just add the Master control to my page and set the properties of the control. But this time, I add more advanced content to the control. The Content property holds a StackPanel with a ListBox.

<Page x:Class="MasterPages.Page.Page2"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:m="clr-namespace:MasterPages.Master"
  Title="Page2">
  <m:Master>
    <m:Master.Title>
      Page 2
    </m:Master.Title>
    <m:Master.Abstract>
      Page 2 contains a ListBox.
    </m:Master.Abstract>
    <m:Master.Content>
      <StackPanel>
        <ListBox>
          <ListBoxItem>Item 1</ListBoxItem>
          <ListBoxItem>Item 2</ListBoxItem>
          <ListBoxItem>Item 3</ListBoxItem>
        </ListBox>
      </StackPanel>
    </m:Master.Content>
  </m:Master>
</Page>

As you can see in the following screenshot, my second page looks similar to my first one. Instead of the text, it shows a ListBox with some items.

If you want to access controls of your page in the codebehind file, you just have to add a name to the control. In the following sample, I added a Button to the Content area of my page:

 <Page x:Class="MasterPages.Page.Page3"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:m="clr-namespace:MasterPages.Master"
  Title="Page3">
  <m:Master>
    <m:Master.Title>
      Page 3
    </m:Master.Title>
    <m:Master.Abstract>
      Page 3 contains a Button, which opens a MessageBox.
    </m:Master.Abstract>
    <m:Master.Content>
      <StackPanel>
        <Button Name="btnShowMessage" Content="Show MessageBox" />
      </StackPanel>
    </m:Master.Content>
  </m:Master>
</Page>

In the codebehind file of the page, I added a click eventhandler to the button which shows a messagebox when it is clicked.

...

protected override void OnInitialized(EventArgs e)
{
  base.OnInitialized(e);
  btnShowMessage.Click += new RoutedEventHandler(BtnShowMessage_Click);
}

private void BtnShowMessage_Click(object sender, RoutedEventArgs e)
{
  MessageBox.Show("You clicked the button.");
}

...

Again, I do not have to worry about the layout of the page. The logo, the background, the colors and everything else that makes up a page in my project are encapsulated in the Master class. I just have to care about the things that are unique to my page like the button and its eventhandler.

Page3.png

History

  • 21st January, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Karin Huber
Software Developer software architects
Austria Austria
Member
Hi, my name is Karin Huber. Since 1998 I have been working as a developer and IT consultant focusing on building database oriented web applications. In 2007 my friend Rainer and I decided that we want to build a business based on COTS (component off-the-shelf) software. As a result we founded "software architects".
 
These days we are offering our first version of the time tracking software called 'time cockpit'. You can find more information at www.timecockpit.com.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionVery nicememberCIDev26 Mar '13 - 5:58 
A well written and interesting article.
Just because the code works, it doesn't mean that it is good code.

QuestionThank you!membergpalmieri8419 Nov '12 - 11:05 
Hi, thank you for your article, write modular ui is very important for me...
QuestionGoodmemberyangshaokai22 Apr '12 - 15:49 
非常好,谢谢共享!
GeneralMy vote of 5membermojmos19 Oct '11 - 23:36 
thanks
good job
GeneralMy vote of 5memberStiaan Jacobs9 Oct '11 - 20:49 
Exactly what I needed for my app
GeneralMy vote of 5memberMember 805109012 Aug '11 - 3:41 
you are beautiful.
your article is good.
It helps me lot.
 
Thanks
atulchirame@gamil.com
QuestionSet Content From Content PagememberTalabér Ferenc22 Mar '11 - 2:13 
Hello!
 
I would like to set the frmContent from Code, in a Contant Page.
I have a page with the account head datas and the account image, and if the user click the detailt button, the details must be showned by the application (in the frmContent)
Could you help me?
Thanks in advice!
GeneralMy vote of 5membermzworowski28 Sep '10 - 16:59 
Very compact info about pages/navigation I was looking for (learning C#). And good looking author ;o)
GeneralProblem using LINQ inside Content PagememberDani Boi28 Sep '09 - 22:21 
Hi
 
I am not able to retrive nor post data from and to the database using LINQ inside a Content Page that is built on the Master Page, when I explicitly open the connection like this: _instance.Connection.Open() I get the XamlParseException, Anybody please any response will be much appreciated.
 
The last part of the error message reads: Error in markup file 'Namespace;component/Pagename.xaml' Line 1 Position 7
GeneralShe tightmemberDani Boi16 Sep '09 - 1:53 
Great-Nice-Exellent-Adorable article, babe-gal got it goin' on wow thanks for the super tight demonstration WPF is the FUTURE
GeneralWOW TALK ABOUT PURE BEAUT IN A LADYmemberstecevsrf3 Aug '09 - 11:35 
With all that gorgeous beauty Karin possess
Karin should be a cover girl model
or be on the cover of a bride magazine
 
Karin you are pure beauty
I do not even think words or all the roses in the world
can begin to describe your magnificient beauty.
Karin you are pure beauty the eyes, and the heart
GeneralLosing all design from master windowmemberAshish Sehajpal5 Jan '09 - 0:55 
Hi,
 
I am facing problem while showing the content from master window in the child window. i have put the logos etc. on a master window and inherited that window in all other windows.
if i do not put any control in child window, then it shows the design from master window....
but if i try to put some controls on it, even a single label, it loses all of the design from master window???? and only white background is shown
 
can you spot why it is so?
 
Ashish Sehajpal

QuestionExtracting Master.cs into a separate assemblymemberryan.riley18 Jun '08 - 4:08 
Will this still work if you move the control to a separate assembly? I've got a solution with multiple projects for which I want to apply a similar set of styles. I tried to do this just briefly, but I can't get it to pull the styles from the new assembly containing the Master Page control.
GeneralGreat Article!memberKavan Shaban18 Apr '08 - 18:52 
Code reuse and consistent UI are so important. Like you mentioned the lack of Master pages like ASP.NET and even worse the lack of direct designer inheritence like WinForms is a problem with WPF at first glance.
 
But the solution you show here achieves a few of those goals, but probably in a cleaner manner.
 
Keep up the good work.
GeneralFurther details on the fixmemberMember 267213525 Feb '08 - 5:09 
In master.cs inherit from ContentControl
 
AND
 
Change the following type of entries in the generic.xaml
 
<contentpresenter content="{TemplateBinding Status}" />
 
to
 
<contentcontrol content="{TemplateBinding Status}" />
GeneralFix For Control: Derive from ContentControl instead of ControlmvpKarl Shifflett19 Feb '08 - 2:19 
The problem is, Karin didn't implement her Content property correctly.
 
If you derive from ContentControl and remove her Content property, the control works as advertised.
 

To fix this control so that the data binding errors no longer occur change the Master class as follows:
 
namespace MasterPages.Master
{
 
  public class Master : ContentControl
  {
    static Master()
    {
      DefaultStyleKeyProperty.OverrideMetadata(typeof(Master), 
        new FrameworkPropertyMetadata(typeof(Master)));
    }
 
    public object Title
    {
      get { return (object)GetValue(TitleProperty); }
      set { SetValue(TitleProperty, value); }
    }
 
    public static readonly DependencyProperty TitleProperty =
      DependencyProperty.Register("Title", typeof(object), 
      typeof(Master), new UIPropertyMetadata());
 
    public object Abstract
    {
      get { return (object)GetValue(AbstractProperty); }
      set { SetValue(AbstractProperty, value); }
    }
 
    public static readonly DependencyProperty AbstractProperty =
      DependencyProperty.Register("Abstract", typeof(object), 
      typeof(Master), new UIPropertyMetadata());
  }
}

 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralRe: Fix For Control: Derive from ContentControl instead of ControlmemberMember 267213522 Feb '08 - 12:16 
Hi there,
 
Even with your suggested changes, I cannot performing binding between a TextBox and a CheckBox.
 
I had look and the window in Mole, and it seems that the TextBox and CheckBox are not accessible.
 









 
Suggestions please,
 
Thanks

QuestionBinding to a property of a control inside master page [modified]memberEshva19 Feb '08 - 1:06 
Have you ever tried to bind to a property of a control placed inside a "zone" of your master page? Seems like it's impossible. I think the problem is that control template has another NameScope. Here is my code snippet.
<code>
<Master:CustomControlLayout01.TopRightZone>
      <StackPanel Orientation="Vertical">
            <TextBlock Text="Some text" Name="someText1" />
            <TextBlock Text="{Binding ElementName=someText1, Path=Text}" />
      </StackPanel>
</Master:CustomControlLayout01.TopRightZone>
</code>
 
Here is an error message from Output window:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=someText1'. BindingExpression:Path=Text; DataItem=null; target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
 
Do you know any reasonable way to bind in such a situation? If you don't, your idea about master pages is not usable in real world projects.
 
<div class="ForumMod">modified on Tuesday, February 19, 2008 7:13 AM</div>
GeneralRe: Binding to a property of a control inside master pagemvpKarl Shifflett19 Feb '08 - 2:10 
I did verify that their code does not work if you bind inside it. I went to Page2.xaml and added in the two TextBlocks and the Binding gave the same error.
 
Try using Snoop or Mole to see what is going on inside.
 
You can just rewrite their approach to make it work.
 
I have never seen this problem with my own code.
 
Maybe Karin can address this issue also.
 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralNot neededmemberWilliam E. Kempf22 Jan '08 - 10:12 
This isn't meant to criticize the article or the code, but there's really no need for this concept in WPF. First, we're not dealing with a browser here. This means many things we consider to be bad when building web applications don't apply. In particular, using a Frame here is not like using a Frame in web applications, because we have no issues with the tension between the Frame and the address bar. This means that a lot of what you use a MasterPage for in ASP.NET could be accomplished by using Frames in WPF.
 
Another thing to keep in mind, is that templates in WPF are a lot more powerful than CSS templates in web development. Templates in WPF can actually add content, for instance. This means you can also achieve your goals here by using templates.
 
William E. Kempf

GeneralRe: Not neededmemberdrumbun.ailn11 Jun '08 - 2:21 
Well, I guess described solution is a template solution, but when we need multiple "Content Placeholders" we create our Master control, that provides ones.
GeneralNice ( minor issue - need to change the base class) [modified]mvpKarl Shifflett21 Jan '08 - 3:36 
Karin,
 
I've done this same thing with our business applications. I also added common code to my base UserControl.
 
Suggestion To Correct Minor Issue. With your control writen the way it is, users can't use Blend to add controls to your content region. This is because you didn't attribute your class correctly. I was trying to remember the attribute you need to use but can't.
 
As an alternate approach, just inherit from either UserControl or ContentControl your control will be Blend friendly. You can also remove your property Content from your code file. After changing your base class to UserControl, the control instantly became Blend friendly.
 
Using your default Control base class, here are the issues I had:
 
I ran up your project in Blend. The problem you have with this approach, is that you can't add controls to the Content region using Blend. You have to manually add them. I have not tried this code in VS2008. In order to add controls to your CustomControl using Blend, you have to edit the Control Template and then add the controls. This is probably not ideal.
 
So just changing the base class corrected the issue.
 
By inheriting from UserControl, I can use your control like this:
 
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:M="clr-namespace:WPFMDIMasterPageSample"
    x:Class="Window1"
    Title="WPFMDIMasterPageSample" Height="300" Width="300"
    >
    <Grid>
    	<M:Master HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
		  Title="Hello" Abstract="Hi too!">
		  
    		<StackPanel Height="100">
    			<TextBlock Text="TextBlock" TextWrapping="Wrap"/>
    			<TextBlock Text="TextBlock" TextWrapping="Wrap"/>
    			<TextBlock Text="TextBlock" TextWrapping="Wrap"/>
    		</StackPanel>
    	</M:Master>        
    </Grid>
</Window>
 
Thank you for sharing with us and have a great day!
 
Cheers, Karl
 
My Blog | Mole's Home Page | Choosing WPF over ASP.NET
 

Just a grain of sand on the worlds beaches.

modified on Monday, January 21, 2008 11:22:01 AM

GeneralRe: Nice ( minor issue - need to change the base class)mvpSacha Barber21 Jan '08 - 6:01 
Nice improvement Karl.
 
Sacha Barber
  • Microsoft Visual C# MVP 2008
  • Codeproject MVP 2008
Your best friend is you.
I'm my best friend too. We share the same view, and never argue
 
My Blog : sachabarber.net

GeneralRe: Nice ( minor issue - need to change the base class)memberEshva19 Feb '08 - 1:13 
Have you tried to change the parent class to UserControl by yourself? Have you tried to name a control inside a "zone" in a concrete page after that? It's impossible. You've got a runtime exception like this:
 
<code>
Cannot set Name attribute value 'TTT' on element 'TextBlock'. 'TextBlock' is under the scope of element 'Master', which already had a name registered when it was defined in another scope. Line '127' Position '32'.
</code>
GeneralRe: Nice ( minor issue - need to change the base class)mvpKarl Shifflett19 Feb '08 - 1:49 
Eshva wrote:
Have you tried to change the parent class to UserControl by yourself?

 
This is how I write all my programs.
 
See my reply on your above post.
 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralRe: Nice ( minor issue - need to change the base class)memberEshva19 Feb '08 - 2:08 
Seems like I have to make the point clear. I told about using UserControl as a base class for MASTER PAGE. Yes, you can do this but the problem arises when you place a control (a Button for instance) inside a "zone" of master page (Abstract, Content in the original article) and assign something to Name attribute of this control. After you run application you have an error message I stated in my previous post to you.
 
Do you understand Karl?
GeneralRe: Nice ( minor issue - need to change the base class)mvpKarl Shifflett19 Feb '08 - 2:10 
I just replied to the top post.
 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralRe: Nice ( minor issue - need to change the base class)mvpKarl Shifflett19 Feb '08 - 2:21 
I just posted a fix for the control. Check it out, this fixed the problem.
 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralRe: Nice ( minor issue - need to change the base class)memberEshva19 Feb '08 - 3:29 
Thanks Karl, but anyway it doesn't fix my problem with binding. Laugh | :laugh:
GeneralRe: Nice ( minor issue - need to change the base class)mvpKarl Shifflett19 Feb '08 - 3:32 
Did you try editing her project?
 
When I did, it worked great.
 
Something else is wrong.
 
Try posting your code here and I'll take a look at it.
 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralRe: Nice ( minor issue - need to change the base class)memberEshva19 Feb '08 - 3:50 
No I have my test project. Sorry I can't publish it, it's too big.
Did binding work great? Confused | :confused:
GeneralRe: Nice ( minor issue - need to change the base class)mvpKarl Shifflett19 Feb '08 - 4:02 
Understand about the large project.
 
I just took the source from the article download, made the changes, added your databinding TextBlocks to her Page2.xaml, Content section and the databinding worked like it was supposed to. Without my change, the databinding did not work.
 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralRe: Nice ( minor issue - need to change the base class)memberEshva19 Feb '08 - 4:11 
Well...
I tried to update her project as you just sugested. Binding works only if your target inside Content "zone". Here is my code snippet:
<Page x:Class="MasterPages.Page.Page1"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:m="clr-namespace:MasterPages.Master"
         Title="Page1">
      <m:Master>
            <m:Master.Title>
                  About us
            </m:Master.Title>
            <m:Master.Abstract>
                  <StackPanel Orientation="Vertical">
                        <TextBlock Text="Some Text"
                                       Name="someText" />
                        <TextBlock Text="{Binding ElementName=someText, Path=Text}" />
                  </StackPanel>
            </m:Master.Abstract>
            <m:Master.Content>
                  <Button Content="{Binding ElementName=someText, Path=Text}" />
            </m:Master.Content>
      </m:Master>
</Page>
 
The button has caption "Some text" but the second text block is empty.
Cry | :((
GeneralRe: Nice ( minor issue - need to change the base class)mvpKarl Shifflett19 Feb '08 - 4:30 
Yes, this is a bummer.
 
I did some reading here but the solution didn't work, however they may have been on the right road.
 
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2860436&SiteID=1[^]
 
You may want to post this on the MSDN WPF forums and see what comes back, I'm not exactly sure why this is working like this.
 
Cheers, Karl
 
My Blog | Mole's Home Page | How To Create Screen Capture Videos For Your Articles
 

Just a grain of sand on the worlds beaches.


GeneralRe: Nice ( minor issue - need to change the base class)memberdrumbun.ailn10 Jun '08 - 22:25 
The problem can be solved if in Master class you just specify [Bidable(true)] attribute to Abstract and Title properites:
 
[Bindable(true)]
public object Title
{
    get
    {
        return (object)GetValue(TitleProperty);
    }
    set
    {
        SetValue(TitleProperty, value);
    }
}  

GeneralRe: Nice ( minor issue - need to change the base class)memberdrumbun.ailn11 Jun '08 - 2:13 
Actually it works even without Bindable attribute, except for the VS designer - it doesn't catch binding on the fly. But application work fine. Maybe I missunderstood something, but specified example works fine in my project.
GeneralSource code linkmemberGreg Russell21 Jan '08 - 2:49 
Excellent article - I located the source code on your web site. Could you please include it in a link on this page? Smile | :)
GeneralRe: Source code linkmemberKarin Huber21 Jan '08 - 9:09 
Oh, sorry. I deleted it somehow when editing the article. Now it is there.
 
Visit my blog at http://www.cubido.at/karin

Generalcool onemembermarlongrech20 Jan '08 - 23:39 
I really like this idea... great job
I think I saw you at Tech Ed Barcelona, was that you?
 
Regards
C# Disciple
My Blog >>
Avalon Controls Lib >>

GeneralRe: cool onememberKarin Huber21 Jan '08 - 9:12 
I was there Smile | :) . Maybe you saw me.
 
Visit my blog at http://www.cubido.at/karin

GeneralI like itmvpSacha Barber20 Jan '08 - 22:18 
Not as good as your lookless control article, but cool.
 
Thanks
 
Sacha Barber
  • Microsoft Visual C# MVP 2008
  • Codeproject MVP 2008
Your best friend is you.
I'm my best friend too. We share the same view, and never argue
 
My Blog : sachabarber.net

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 21 Jan 2008
Article Copyright 2008 by Karin Huber
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid