相关疑难解决方法(0)

C#3.0自动属性,为什么不直接访问该字段?

使用在类的属性中获取/设置的新方法,如:

public string FirstName {
        get; set;
    }
Run Code Online (Sandbox Code Playgroud)

为什么不简单地将属性FirstName公开而没有访问者?

properties c#-3.0

12
推荐指数
2
解决办法
2528
查看次数

无法绑定超链接在我的视图中命令ICommand

我将我的xaml中两个超链接的command属性绑定到视图中的命令(这是datacontext):

<TextBlock>
   <Hyperlink x:Name="linkCheckAll" Command="{Binding CheckAllZonesCommand}" CommandParameter="{Binding}">Check All</Hyperlink>
   <TextBlock Margin="0,0,20,0"/>
   <Hyperlink x:Name="linkUncheckAll" Command="{Binding UncheckAllZonesCommand}" CommandParameter="{Binding}">Uncheck All</Hyperlink>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)

看起来像这样:

在此输入图像描述

绑定命令时出现以下错误:

System.Windows.Data Error: 40 : BindingExpression path error: 'CheckAllZonesCommand' property not found on 'object' ''ZonesView' (HashCode=56756307)'. BindingExpression:Path=CheckAllZonesCommand; DataItem='ZonesView' (HashCode=56756307); target element is 'Hyperlink' (HashCode=50738642); target property is 'Command' (type 'ICommand')
System.Windows.Data Error: 40 : BindingExpression path error: 'UncheckAllZonesCommand' property not found on 'object' ''ZonesView' (HashCode=56756307)'. BindingExpression:Path=UncheckAllZonesCommand; DataItem='ZonesView' (HashCode=56756307); target element is 'Hyperlink' (HashCode=53994596); target property is 'Command' (type 'ICommand')
Run Code Online (Sandbox Code Playgroud)

"ZonesView"是我的dataContext,我很肯定它包含有问题的命令:

public class …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml binding .net-4.0

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

标签 统计

.net-4.0 ×1

binding ×1

c# ×1

c#-3.0 ×1

properties ×1

wpf ×1

xaml ×1