yashao1987 2015-03-30 06:50 采纳率: 0%
浏览 4119

WPF的Mainwindow和Usercontrol之间的传值

我用的是ModernWindow框架,现在就是在MordernWindow定义了一个按钮和一个标签,在点击按钮的时候总是回到一个主界面,在UserControl切换的时候,可以让标签改变值,要怎么做啊

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-10-27 15:56
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:
    • 建议你看下这篇博客👉 :WPF 用户控件(UserControl)
    • 除此之外, 这篇博客: WPF 用户控件(UserControl)中的 窗体引用用户控件 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:
      <Window x:Class="WpfDemo.UserControlDemo.UseUserControlWindow"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:userControlDemo="clr-namespace:WpfDemo.UserControlDemo"
              mc:Ignorable="d"
              Title="UseUserControlWindow" Height="600" Width="400">
          <Grid>
              <Grid.RowDefinitions>
                  <RowDefinition Height="0.2*"></RowDefinition>
                  <RowDefinition Height="*"></RowDefinition>
                  <RowDefinition Height="0.2*"></RowDefinition>
                  <RowDefinition Height="*"></RowDefinition>
              </Grid.RowDefinitions>
              <Label Content="使用OwnUserControl用户控件"></Label>
              <userControlDemo:OwnUserControl Grid.Row="1"></userControlDemo:OwnUserControl>
              <Label Grid.Row="2" Content="使用UseUserControlUserControl用户控件"></Label>
              <userControlDemo:UseUserControlUserControl Grid.Row="3"></userControlDemo:UseUserControlUserControl>
          </Grid>
      </Window>
      

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog