棱镜和区域

发布于 2024-09-12 03:39:40 字数 1043 浏览 2 评论 0原文

0嗨,

我有一个 shell,其中设置了一个区域“MainContentRegion”。在该区域中,我加载此视图:

<UserControl x:Class="CustomControls.MainContent"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:cal="http://www.codeplex.com/CompositeWPF">
  <Border BorderThickness="1" BorderBrush="Black" Margin="2">
    <Grid x:Name="ContentGrid" Background="{StaticResource MainContentBackgroundColor}">
      <Grid.RowDefinitions>
        <RowDefinition Height="55" />
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <ContentControl Name="MainContentHeaderRegion" cal:RegionManager.RegionName="MainContentHeaderRegion" Grid.Row="1"/>
      <ContentControl Name="MainContentBodyRegion" cal:RegionManager.RegionName="MainContentBodyRegion" Grid.Row="2"/>
    </Grid>
  </Border>
</UserControl>

当尝试访问 2 个新添加的区域时,我收到错误,在查找加载的区域后,我只看到从 shell 添加的区域。有人可以帮忙吗?

0Hi

I have a shell in which i have a region "MainContentRegion" set. In that region i load this view:

<UserControl x:Class="CustomControls.MainContent"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:cal="http://www.codeplex.com/CompositeWPF">
  <Border BorderThickness="1" BorderBrush="Black" Margin="2">
    <Grid x:Name="ContentGrid" Background="{StaticResource MainContentBackgroundColor}">
      <Grid.RowDefinitions>
        <RowDefinition Height="55" />
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <ContentControl Name="MainContentHeaderRegion" cal:RegionManager.RegionName="MainContentHeaderRegion" Grid.Row="1"/>
      <ContentControl Name="MainContentBodyRegion" cal:RegionManager.RegionName="MainContentBodyRegion" Grid.Row="2"/>
    </Grid>
  </Border>
</UserControl>

When trying to access the 2 new added regions i get an error and after looking up the loaded regions i only see the regions added from the shell. Can someone help?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

屋檐 2024-09-19 03:39:41

如果包含嵌套区域的视图被加载多次,可能会导致错误,因为嵌套区域将不再是唯一的 - 在这种情况下,您应该使用作用域区域 - 请参阅 doc

If the view containing the nested regions is loaded more than once that could cause an error as the nested regions would no longer be unique - in which case you should use a scoped region - see doc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文