我想我有一个非常简单的问题。我正在通过contentcontrol绑定显示一个用户控件。 做什么是创建该用户控件...WPF Window无法加载UserControl
<UserControl x:Class="Exxeta.ModeldrivenCostEstimation.WPF.UserControlModelAnalysis"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="350" d:DesignWidth="525">
<Grid Margin="0,0,0,0">
<Grid Background="#FFE5E5E5" HorizontalAlignment="Right" Width="489" Margin="0,93,11,0" Height="164" VerticalAlignment="Top" >
<DataGrid x:Name="DataGrid" HorizontalAlignment="Left" VerticalAlignment="Top"
Width="489" AutoGenerateColumns="False" ItemsSource="{Binding ViewModelModelAnalysis.GridObjects}" CanUserResizeRows="False" CanUserResizeColumns="False">
</DataGrid>
</Grid>
</Grid>
,并宣布ContentControl中在我的主窗口
<Window x:Class="WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Test" Height="350" Width="525" ResizeMode="NoResize" Background="#FFE5E5E5">
<ContentControl Name="Content" Width="Auto" Opacity="1" Background="Transparent" ></ContentControl>
</Window>
。而当我读到我创建一个这样的窗口。
public MainWindow(***)
{
InitializeComponent();
model = new BasicViewModel();
UserControl c1 = new UserControlModelAnalysis();
this.Content = c1;
this.DataContext = model;
}
但是内容不显示在窗口中。我错过了那里的东西吗? 希望你能帮助我摆脱这个小问题。
感谢您的帮助 壹岐
我想要建立的东西就像一个wizzard behavoir。我可以点击下一页。我不应该从代码背后启动它。这很容易为什么要建立这样的东西 –
所以想要与新的内容交换控制内容? –
我所拥有的是我的MainWindows,它是一个普通的WPF窗口。我也宣布了一个内容控制。我还宣布了一些用户控件与不同的UI元素。如果我启动WPF窗口,则应显示第一个用户控件。在“下一步”点击secound usercontrol应该显示等等..我希望它看起来像一个法师wizzard .. –