locked
Creating Custom PartPane - partpane.xaml resource error RRS feed

  • Question

  • I am finding that Acropolis is fantastic and could be the cornerstone of all my projects.

    Unfortunately Acropolis provides very limited LayoutPanes at this stage.  There is a great need of custom layout capabilities, as the default styles will never be enough.

    As having the right LayoutPane style at the early stage of my project was crucial, I decided to create a custom layout - MDI style.  It could be similiar to forthcoming FloatingLayoutPane but I could not wait and also mine could be a bit different.

    Manipulating Content and ChildPanes I created a MDI LayoutPane class.  It worked fine even with my other custom child Pane class (which extends from either ContentPane or just Pane).   So far so good.

    But when I tried to extend from PartPane to provide Part support, it caused a runtime error "The component 'MyNamespace.TestPartPane' does not have a resource identified by the URI '/Microsoft.Acropolis.Windows;component/partpane.xaml'."  I tried everything possible without any success.

    Does anybody have any idea of what this means or how this could be fixed. 

    Is there any resource regarding custom Acropolis LayoutPanes yet?

    If possible, I really wish that somehow Acropolis team could help us in this area asap. Thanks.

     

    Monday, June 18, 2007 8:17 AM

Answers

  • You're getting this error because PartPane constructor calls InitializeComponent() which is doing something like that:

     

    Code Snippet
    Uri resourceLocater = new Uri("/Microsoft.Acropolis.Windows;component/partpane.xaml", UriKind.Relative);
    Application.LoadComponent(this, resourceLocater);

     

     

    Also if you try defining your own TestPartPane in XAML:

     

    <Awx:PartPane x:Class="AcropolisApp1.TestPartPane1"

    ....

     

    </Awx:PartPane>

     

    You'll get an error saying it "cannot be the root of a XAML file because it was defined using XAML".

    The solution to me seems that you need to derive from Pane or LayoutPane.

     


     

    Monday, June 18, 2007 4:06 PM

All replies

  • You're getting this error because PartPane constructor calls InitializeComponent() which is doing something like that:

     

    Code Snippet
    Uri resourceLocater = new Uri("/Microsoft.Acropolis.Windows;component/partpane.xaml", UriKind.Relative);
    Application.LoadComponent(this, resourceLocater);

     

     

    Also if you try defining your own TestPartPane in XAML:

     

    <Awx:PartPane x:Class="AcropolisApp1.TestPartPane1"

    ....

     

    </Awx:PartPane>

     

    You'll get an error saying it "cannot be the root of a XAML file because it was defined using XAML".

    The solution to me seems that you need to derive from Pane or LayoutPane.

     


     

    Monday, June 18, 2007 4:06 PM
  •  

    Thanks, Alex.  

    With your clear guidance I could find the answer, even if it took some time.

    I described my finding in a related subject. (http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1765244&SiteID=1). 

    My suggestion is that PartPane becomes an inheritable class in future Acropolis.

    Friday, June 22, 2007 2:00 PM
  • Thanks for your feedback,

    You mentioned you wanted to derive from PartPane "to provide Part support". Could you please elaborate a little - what were you trying to extend?

    Friday, June 22, 2007 3:44 PM
  • Here is the situation where I need to extend a PartPane, as PartPane could be the only pane which has updatable .Part property.

    I created a custom layoutpane where its content is a Canvas to support MDI clients.  Each client window contains a part.  To create such a child window(childpane) ideally I should be able to create it extending from PartPane, as PartPane has .Part to link a part to its content area.

    At the moment PartPane cannot be extended as discussed above.  As you suggested I used LayoutPane. Then within this LayoutPane I created .Part property using a PartPane.  This way I could link a Part to the PartPane within a LayoutPane.

    If I could create this client window extending PartPane directly, I didn't need this extra mile going around LayoutPane.  That is why I suggest that PartPane should be extendable so that we could create custom partpane.

    I am finding that Acropolis is/will be a great application framework to save our precious time and energy.  Thanks to Acropolis team.

    Saturday, June 23, 2007 5:20 AM
  • In July CTP we removed the call to InitializeComponent from PartPane's constructor so inheriting from this class now isn't longer causing runtime error.

     

    Thanks!

    Saturday, July 7, 2007 1:12 AM
  • Hi Alex, Thanks for listening and making PartPane inheritable.   But it looks like that ShowChrome=false does not work as expected.  Somehow it leaves unknown black border around the pane.  I could not figure out how to remove these borders.

    Monday, July 9, 2007 5:52 AM
  • The black border that you're seeing (I assume when you don't specify the theme) is the defined on the generic theme, i.e. the theme that you get when you don't specify any theme. Currenly to get rid of/modify this theme you need to do something like that:

     

    Code Snippet

    <Awx:PartPane ShowChrome="False" Part="{Binding Part.NavigationManager.ActivePart}">

    <Awx:PartPane.Resources>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type Awx:Pane}, ResourceId=redChromeTemplate}" TargetType="{x:Type Awx:Pane}">

    <Border Name="PaneBorder" CornerRadius="2" BorderThickness="2" Padding="1" Background="{TemplateBinding Background}" BorderBrush="Red" DataContext="{Binding}">

    <Transitions:TransitionElement Name="PART_PaneTransitionElement">

    <ContentPresenter Name="PART_PaneContentPresenter"/>

    </Transitions:TransitionElement>

    </Border>

    </ControlTemplate>

    <Style TargetType="{x:Type Awx:PartPane}">

    <Setter Property="Template" Value="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type Awx:Pane}, ResourceId=redChromeTemplate}}"/>

    </Style>

    </Awx:PartPane.Resources>

    </Awx:PartPane>

     

    In this example above I'm substituting the default border with a red border. Note that you need to have PART_PaneTransitionElement and PART_PaneContentPresenter names specified, because the partpane behaviour is tied up to these names, so otherwise the partpane won't display.

    Obviously this is quite cumbersome way to change the border of a partpane, so in the future we may start considering exposing it to the pane.

     

    BTW, if you would like to move your custom pane style into your custom theme, my post here may be useful: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1740050&SiteID=1  

    Monday, July 16, 2007 4:52 PM
  • Thanks, Alex.  I could get rid of the black border following your advice.  But it was only for one part pane.  To get rid of the borders for the LayoutPane and all other panes in my application I followed your other link.  I created a custom theme as instructed.  But it didn't do anything. Would you have a look the resource file below and let me know where I am doing wrong?  It is from my customtheme.xaml.  By the way I had to use 'Window Classic Theme' to have a window header for my custom shell. I couldn't have a shell header using other themes. Many thanks.

    <Awx:Theme.MergedDictionaries>

    <Awxth:ClassicTheme/>

    <ResourceDictionary>

    <Style TargetType="{x:Type Awx: PartPane}">

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type Awx: Pane}, ResourceId=redChromeTemplate}" TargetType="{x:Type Awx: Pane}">

    <Border Name="PaneBorder" CornerRadius="2" BorderThickness="2" Padding="1" Background="{TemplateBinding Background}" BorderBrush="Blue" DataContext="{Binding}">

    <Awxt:TransitionElement Name="PART_PaneTransitionElement">

    <ContentPresenter Name="PART_PaneContentPresenter"/>

    </Awxt:TransitionElement>

    </Border>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style>

    </ResourceDictionary>

    </Awx:Theme.MergedDictionaries>

     

     

    Tuesday, July 17, 2007 2:10 PM
  • Hi reachpoint,

     

    I modified your XAML slightly - you only need to merge the theme you're inheriting from (in this example it's ClassicTheme), the other styles should be placed outside MergedDictionaries node:

     

    Code Snippet

    <Awx:Theme.MergedDictionaries>

       <Awxth:ClassicTheme/>

    </Awx:Theme.MergedDictionaries>

    <Style TargetType="{x:Type Awx:PartPane}">

       <Setter Property="Template">

          <Setter.Value>

             <ControlTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type Awx:Pane}, ResourceId=redChromeTemplate}" TargetType="{x:Type Awx:Pane}">

                <Border Name="PaneBorder" CornerRadius="2" BorderThickness="2" Padding="1" Background="{TemplateBinding Background}" BorderBrush="Blue" DataContext="{Binding}">

                   <Awxt:TransitionElement Name="PART_PaneTransitionElement">

                      <ContentPresenter Name="PART_PaneContentPresenter"/>

                   </Awxt:TransitionElement>

                </Border>

             </ControlTemplate>

          </Setter.Value>

       </Setter>

    </Style>

     

    Also, as I mentioned in the other post, please add InitializeComponent() call to the constructor of your CustomTheme in the code-behind file (I'm currently investigating how we can get rid of the code-behind file at all, and I'll let you know if we can). Register your theme in the Application constructor: RegisterThemeAssembly(typeof(CustomTheme)); Then set your theme in the Application XAML (theme name is "<namespace>.<classname>")

    I hope this helps. Please let me know if it works for you (I've just tried and it works, so I can upload a small project with this custom theme if you need to.

    Thanks!

     

     

     

    Tuesday, July 17, 2007 4:50 PM
  • Hi Alex,

    I think I followed your instruction to the letter.  I updated Application as well.  Somehow the new custom theme had no effect.  I can wait until the next release. Thanks a lot.

    Saturday, July 21, 2007 5:47 AM
  • Hi reachpoint, can you check this sample project? (it's created off Acropolis July CTP)

    Thanks!

    Sunday, July 22, 2007 4:09 PM