WPF的Mainwindow和Usercontrol之间的传值

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

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 建议你看下这篇博客👉 :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>
    

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