如何将一个窗口添加到另一个窗口?

时间:2012-04-26 01:35:55

标签: wpf mvvm wpftoolkit

这里我想将accountview.xaml添加到accountlistview.xaml。我尝试了很多选项,但我不能这样做。 这里accountlistview.xaml包含grid和accountview.xaml包含textbox。代码为accountlistview.xaml

<UserControl x:Class="MyBooks.View.accountListView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vw="clr-namespace:MyBooks.View"
xmlns:uic="clr-namespace:UIControls;assembly=UIControls"
xmlns:wpftoolkit="http://schemas.microsoft.com/wpf/2008/toolkit">

<UserControl.Resources>
    <ResourceDictionary Source="ViewResources.xaml" />
</UserControl.Resources>

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition  Width="*"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions><wpftoolkit:DataGrid Grid.Row="1"
                         ItemsSource="{Binding Payments}"
                         SelectedItem="{Binding SelectedPayment, Mode=TwoWay}"
                         AutoGenerateColumns="False"
                         SelectionMode="Single"
                         IsReadOnly="True">
        <wpftoolkit:DataGrid.Columns>
            <wpftoolkit:DataGridTextColumn
                Header="{Resx ResxName=MyBooks.Properties.Strings, Key=Journal_Date_Label}"
                Binding="{Binding Date}"/>
            <wpftoolkit:DataGridTextColumn
                Header="{Resx ResxName=MyBooks.Properties.Strings, Key=Journal_CreditedParty_Label}"
                Binding="{Binding CreditedAccount.Name}"/>
            <wpftoolkit:DataGridTextColumn
                Header="{Resx ResxName=MyBooks.Properties.Strings, Key=Journal_Narration_Label}"
                Binding="{Binding Narration}"/>
        </wpftoolkit:DataGrid.Columns>
    </wpftoolkit:DataGrid>

如何在此窗口中添加accountview.xaml?

1 个答案:

答案 0 :(得分:1)

只需在AccountListView.xaml中包含以下行:

<uic:AccountView.xaml />