草庐IT

simple_bind_s

全部标签

c# - WPF:将 ContextMenu 绑定(bind)到 MVVM 命令

假设我有一个带有返回Command的属性的Window(实际上,它是一个ViewModel类中带有Command的UserControl,但让我们尽可能简单地重现问题)。以下作品:但是以下不起作用。我得到的错误信息是System.Windows.DataError:4:Cannotfindsourceforbindingwithreference'ElementName=myWindow'.BindingExpression:Path=MyCommand;DataItem=null;targetelementis'MenuItem'(Name='');targetpropertyis'

c# - WPF:将 ContextMenu 绑定(bind)到 MVVM 命令

假设我有一个带有返回Command的属性的Window(实际上,它是一个ViewModel类中带有Command的UserControl,但让我们尽可能简单地重现问题)。以下作品:但是以下不起作用。我得到的错误信息是System.Windows.DataError:4:Cannotfindsourceforbindingwithreference'ElementName=myWindow'.BindingExpression:Path=MyCommand;DataItem=null;targetelementis'MenuItem'(Name='');targetpropertyis'

c# - 绑定(bind)到 DataTemplate 中的 ToString() 方法

有什么简单的方法可以绑定(bind)到DataTemplate中的ToString()方法吗?我希望TextBlock的Text属性在默认情况下为其Text属性使用ToString(),但这并没有发生。所以任何简单的方法来做到这一点: 最佳答案 您可以使用Text="{Binding}"。ToString()方法被隐式调用。 关于c#-绑定(bind)到DataTemplate中的ToString()方法,我们在StackOverflow上找到一个类似的问题:

c# - 绑定(bind)到 DataTemplate 中的 ToString() 方法

有什么简单的方法可以绑定(bind)到DataTemplate中的ToString()方法吗?我希望TextBlock的Text属性在默认情况下为其Text属性使用ToString(),但这并没有发生。所以任何简单的方法来做到这一点: 最佳答案 您可以使用Text="{Binding}"。ToString()方法被隐式调用。 关于c#-绑定(bind)到DataTemplate中的ToString()方法,我们在StackOverflow上找到一个类似的问题:

c# - 为什么我绑定(bind)的 DataGridView 会抛出 "Operation not valid because it results in a reentrant call to the SetCurrentCellAddressCore function"错误?

将DataGridView控件绑定(bind)到绑定(bind)源时,我的应用程序出现以下错误:OperationisnotvalidbecauseitresultsinareentrantcalltotheSetCurrentCellAddressCorefunction绑定(bind)源取决于数据表。我正在从DataGridView中过滤记录。我在过滤DataGridView的地方使用了dataGridView1_CellValueChanged()事件。但是当我从当前单元格中删除数据时,出现了这个错误。我该如何解决这个问题? 最佳答案

c# - 为什么我绑定(bind)的 DataGridView 会抛出 "Operation not valid because it results in a reentrant call to the SetCurrentCellAddressCore function"错误?

将DataGridView控件绑定(bind)到绑定(bind)源时,我的应用程序出现以下错误:OperationisnotvalidbecauseitresultsinareentrantcalltotheSetCurrentCellAddressCorefunction绑定(bind)源取决于数据表。我正在从DataGridView中过滤记录。我在过滤DataGridView的地方使用了dataGridView1_CellValueChanged()事件。但是当我从当前单元格中删除数据时,出现了这个错误。我该如何解决这个问题? 最佳答案

c# - 将 DataTemplate 中的按钮绑定(bind)到表单的 ViewModel 中的命令

我的问题类似于这个问题中描述的问题:WPFMVVMButtonControlBindinginDataTemplate这是我的XAML:-->这只是一个ListBox,绑定(bind)到ObservableCollection名为CommandSets(在ViewModel中)。此绑定(bind)有效(它为集合中的每个项目显示一个按钮)。现在我想将按钮绑定(bind)到命令(FireCommand),它也在ViewModel中。这是ViewModel的相关部分:publicclassMainWindowViewModel:INotifyPropertyChanged{publicICo

c# - 将 DataTemplate 中的按钮绑定(bind)到表单的 ViewModel 中的命令

我的问题类似于这个问题中描述的问题:WPFMVVMButtonControlBindinginDataTemplate这是我的XAML:-->这只是一个ListBox,绑定(bind)到ObservableCollection名为CommandSets(在ViewModel中)。此绑定(bind)有效(它为集合中的每个项目显示一个按钮)。现在我想将按钮绑定(bind)到命令(FireCommand),它也在ViewModel中。这是ViewModel的相关部分:publicclassMainWindowViewModel:INotifyPropertyChanged{publicICo

c# - 如何将 DataTable 绑定(bind)到 Datagrid

我在将DataTable绑定(bind)到DataGrid时遇到问题。我已经在寻找解决方案,但无法摆脱错误。绑定(bind)在使用WindowsForms时工作正常,因此DataTable是正确的。我只是无法将它绑定(bind)到WPF-DataGrid。Errormessage:AmbiguousMatchExceptionwasunhandledSource:mscorlib我已经建立了新项目来摆脱任何不良链接等。XAML代码:我已经尝试过跟随C#-Codebehind:grid1.ItemsSource=dt.DefaultView;或grid1.DataContext=dt.D

c# - 如何将 DataTable 绑定(bind)到 Datagrid

我在将DataTable绑定(bind)到DataGrid时遇到问题。我已经在寻找解决方案,但无法摆脱错误。绑定(bind)在使用WindowsForms时工作正常,因此DataTable是正确的。我只是无法将它绑定(bind)到WPF-DataGrid。Errormessage:AmbiguousMatchExceptionwasunhandledSource:mscorlib我已经建立了新项目来摆脱任何不良链接等。XAML代码:我已经尝试过跟随C#-Codebehind:grid1.ItemsSource=dt.DefaultView;或grid1.DataContext=dt.D