locked
Include XAML into XAML RRS feed

  • Question

  • How can I include one XAML into an other XAML.

     

    Thursday, November 23, 2006 8:49 AM

All replies

  •  

    i think you have a resourcedictionary as a external XAML-document?! now, you can use this document (reference this document) with the tag <RecourceDictionary source="MyXAMLDocument.XAML"/> in the "Recource" tag from any container´s.

    a small sample for using a ResourceDicnionary.xaml in a window tag.

    ....

    <Window>

    <Window.Resources>

    <ResourceDictionary source="MyXAMLDocument.xaml"/>

    </Window.Resources>

    .....

    i hope it help ;-) sorry for my small englisch

     

    TOM

    Thursday, November 23, 2006 9:23 AM
  • Hi Tom

    I try to show a Page into a Windows as Included xaml.

    Adding a Resource in the Windows this Error accours:

    Error 1 Value 'Page1.xaml' cannot be assigned to property 'Source'. C:\DEVELOP\VITO64\Vitodata.Vito64.Client.UI.Windows\PilotProjekte\Vista\VistaMed\VistaMed\VistaMed\Window4.xaml 4 25 VistaMed

     

    My Window Code:

    <Window Name="Window1" Width="495" Height="292" Foreground="{x:Static SystemColors.WindowTextBrush}" Background="{x:Static SystemColors.WindowBrush}" IsTabStop="False" Title="VistaMed" WindowStartupLocation="Manual" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Window4" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <
    Window.Resources>
    <
    ResourceDictionary Source="Page1.xaml"/>
    </
    Window.Resources>
    <
    Grid Name="Grid1">
    </
    Grid>
    </
    Window>

    My Page Code:

    <Page x:Class="Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page1"
    >
    <
    Grid Background="#FF90EE90">
    <
    CheckBox Height="18" Margin="29,23,124,0" Name="CheckBox1" VerticalAlignment="Top">CheckBox</CheckBox>
    </
    Grid>
    </
    Page>

    Thursday, November 23, 2006 9:55 AM
  • You can use Frame to host the page:
    <Frame Source="MyPage.xaml"/>

    Sheva
    Thursday, November 23, 2006 11:54 AM
  •  If I add this Tag into my Windows an  unhandled Exception accours!

    <Window Name="Window1" Width="620" Height="429" Foreground="{x:Static SystemColors.WindowTextBrush}" Background="{x:Static SystemColors.WindowBrush}" IsTabStop="False" Title="VistaMed" WindowStartupLocation="Manual" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Window4" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
    <
    Grid Name="Grid1">
    <
    Button Height="72" HorizontalAlignment="Left" Margin="38,21,0,0" Name="Button1" VerticalAlignment="Top" Width="200">Button</Button>
    <
    Frame Source="Page1.xaml"/>
    </
    Grid>
    </
    Window>

    Page1.xaml:

    <Page x:Class="Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page1"
    >
    <
    Grid Background="#FF90EE90">
    </
    Grid>
    </
    Page>

    An Unhandled Exception accours:

    An unhandled exception has occurred in a designer within your application. This generally happens when an exception is thrown asynchronously through a storyboard or timer callback.

    You should save your work, close, and reopen the designer. If the problem persists contact the component vendor for the component that threw the exception.

    Exeption Information:

    'Class' attribute does not exist in XML namespace 'http://schemas.microsoft.com/w
    at System.Windwos.MarkupXamlParser.ThrowException(string message, int32 lineNumber, int32 linePosition)
    at System.Windwos.MarkupXamlParser.ThrowException(SRID id, String value, int32 lineNumber, int32 linePosition)
    at System.Windwos.MarkupXamlParser.WriteDefAttribute(...

     

    Thursday, November 23, 2006 2:10 PM
  • try
    <Frame x:Name="myFrame"/>

    C#
    myFrame.Navigate("Page1.xml")

    Saturday, February 16, 2008 7:37 PM
  • Hello,

     

    you could also use a UserControl instead of a Page.

     

    So, you have a UserControl to include :

    <UserControl x:Class="views.uc1" ...

     


    And in the main window :

     

    1. Declare the userControl

    <Windows x:Class="views.Window1"
    xmlns:uc="clr-namespace:views" ...


    2. Add the userControl

    <uc:uc1/>

    Sunday, May 11, 2008 7:39 PM