小编dst*_*ssi的帖子

wpf mvvm嵌套用户控件datacontext

datacontext对nested 有问题user-controls。问题在于ViewModel中的模型绑定在第一个DependencyProperty的上user-control。第一user-control是第二user-control。第二个user-control也有一个DependencyProperty。第一个user-controlDependencyProperty第二个绑定user-control

主视图:

<UserControl x:Class="XXX.XXX.Hmi.Views.L1SetupViewerView"
             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:prism="http://prismlibrary.com/"
             xmlns:uc="clr-namespace:XXX.XXX.Hmi.UserControls"
             d:DesignHeight="450"
             d:DesignWidth="800"
             prism:ViewModelLocator.AutoWireViewModel="True"
             Background="{DynamicResource BaseBrush}"
             Foreground="{DynamicResource TextBrush}"
             mc:Ignorable="d">
.
.
.
    <GroupBox Grid.Row="1" Header="Entry Section">
        <uc:L1SetupViewerEntrySectionView Margin="8" Setup="{Binding L1Setup}" />
    </GroupBox>
.
.
.
</UserControl>
Run Code Online (Sandbox Code Playgroud)

MainViewModel:

public class L1SetupViewerViewModel : ViewModelBase
{
    private L1Setup _l1Setup;
    private Pdi _pdi;

    public L1SetupViewerViewModel()
    {
        Title = LanguageProvider.Instance.GetValue("L1SetupViewer_Window_Title");
        LanguageProvider.Instance.UiCultureChanged += Instance_UiCultureChanged; …
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm wpf-controls

0
推荐指数
1
解决办法
83
查看次数

标签 统计

c# ×1

mvvm ×1

wpf ×1

wpf-controls ×1