Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 嵌套WPF数据模板中的绑定_C#_Wpf_Xaml_Mvvm_Data Binding - Fatal编程技术网

C# 嵌套WPF数据模板中的绑定

C# 嵌套WPF数据模板中的绑定,c#,wpf,xaml,mvvm,data-binding,C#,Wpf,Xaml,Mvvm,Data Binding,我有一个叫做Foo的WPF控件。带有DevXPress LoadingDecorator的网格结构如下所示: <Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="60" /> </Grid.RowDefinitions> <StackPanel Grid.Row="

我有一个叫做Foo的WPF控件。带有DevXPress LoadingDecorator的网格结构如下所示:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="60" />
    </Grid.RowDefinitions>

    <StackPanel Grid.Row="0">
        <dx:LoadingDecorator Name="Decorator" IsSplashScreenShown="{Binding Path=ShowLoader}" SplashScreenLocation="CenterWindow">
            <dx:LoadingDecorator.SplashScreenTemplate>
                <DataTemplate>
                    <dx:WaitIndicator DeferedVisibility="True">
                        <dx:WaitIndicator.ContentTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="Operation:" FontSize="15"/>
                                    <TextBlock Text="{Binding Path=CurrLoadStat}"/>
                                </StackPanel>
                            </DataTemplate>
                        </dx:WaitIndicator.ContentTemplate>
                    </dx:WaitIndicator>
                </DataTemplate>
            </dx:LoadingDecorator.SplashScreenTemplate>
        </dx:LoadingDecorator>
    </StackPanel>

    ...

</Grid>
我的问题是绑定指令不起作用,我只看到第一个文本块中定义的文本。 你能提供一些解决这个问题的方法吗?< /P> < P>你的属性在名称中间有一个“T”,但是你的绑定路径(XAML)和魔法字符串传递给<代码> OnPrimTyType 。引发
PropertyChanged
事件方法时传递的字符串必须与视图模型的属性名称完全匹配

如果使用C 5或6,则切换到使用其中一种方法,这样就消除了传递魔法字符串的需要。

< P>你的属性在名称中间有一个“T”,但是你的绑定路径(XAML)和魔法字符串传递给<代码> OnPrimTyType 。引发
PropertyChanged
事件方法时传递的字符串必须与视图模型的属性名称完全匹配


如果您使用的是C#5或C#6,则切换到使用其中一种方法,这样就不需要传递魔术字符串。

运行时输出窗口是否显示绑定错误?如果您临时更改为仅
。。。Text={Binding}
,那么文本块中是否显示了任何内容?这将排除问题不是路径。输出窗口中的错误:“System.Windows.Data错误:40:BindingExpression路径错误:'CurrLoadStat'属性未在'object''String'(HashCode=-860452824')上找到。BindingExpression:Path=CurrLoadStat;DataItem='String'(HashCode=-860452824);目标元素为'TextBlock'(Name='');目标属性为“Text”(类型为“String”)。将绑定更改为Text={binding}只会给我从DevExpress属性中获取的文本“Loading…”。输出告诉您一件可以确定的事情,那就是DataContext或TextBlock不是视图模型类的实例,而只是一个字符串(如您所述设置为“Loading…”)。是的,DataContext没有正确定义。谢谢你给了我正确的思考方向。:)运行时输出窗口是否显示绑定错误?如果您临时更改为仅
。。。Text={Binding}
,那么文本块中是否显示了任何内容?这将排除问题不是路径。输出窗口中的错误:“System.Windows.Data错误:40:BindingExpression路径错误:'CurrLoadStat'属性未在'object''String'(HashCode=-860452824')上找到。BindingExpression:Path=CurrLoadStat;DataItem='String'(HashCode=-860452824);目标元素为'TextBlock'(Name='');目标属性为“Text”(类型为“String”)。将绑定更改为Text={binding}只会给我从DevExpress属性中获取的文本“Loading…”。输出告诉您一件可以确定的事情,那就是DataContext或TextBlock不是视图模型类的实例,而只是一个字符串(如您所述设置为“Loading…”)。是的,DataContext没有正确定义。谢谢你给了我正确的思考方向。:)
        private string currLoadStat = "Preparing data...";

        public string CurrtLoadStat
        {
            get
            {
                return currLoadStat;
            }
            set
            {
                currLoadStat = value;
                OnPropertyChanged("CurrLoadStat");
            }
        }