WPF: Command bindings for Buttons in datagrids -


The button works in the header, I have two buttons in this sample, but one of the grids shows me the error below .

  & lt; Groupboxes dockpanel.doc = "top" & gt; & Lt; GroupBox.Header & gt; & Lt; StackPanel Orientation = "Horizontal" & gt; & Lt; Label content = "recent server" /> & Lt; Checkbox content = "auto-refresh" /> & Lt; Button content = "monitor" command = "{binding monitor comand, element name = top}" commandpalmter = "{binding}" /> & Lt; / StackPanel & gt; & Lt; /GroupBox.Header> & Lt; DataGrid CanUserAddRows = "False" CanUserDeleteRows = "False" AutoGenerateColumns = "False" ItemsSource = "{Binding ServerHistory}" & gt; & Lt; DataGrid.Columns & gt; & Lt; DataGridTextColumn Header = "Machine Name" Binding = "{Binding Data Point [Server Name}, Mode = Options]" / & gt; & Lt; DataGridTextColumn Header = "Ultimate Heartbeat" Binding = "{Binding Data Point [Last Heartbeat], Mode = Options)" / & gt; & Lt; DataGridTemplateColumn Header = "Monitor" & gt; & Lt; DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Button content = "monitor" command = "{binding monitor comand, element name = top}" commandpalmter = "{binding}" /> & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellTemplate> & Lt; / DataGridTemplateColumn & gt; & Lt; /DataGrid.Columns> & Lt; / Data grid & gt; & Lt; / GroupBox & gt;  

System.Windows.Data Error: 4: Source can not be found to bind with the 'ElementName = Top' BindingExpression: Path = MonitorCommand; DataItem = Null; Target element 'button' (name = ''); Target property 'command' (type Icommand)

I believe your second The button is attached as part of a template. Instead, click on a click event, grab it in the back code and try to exclude the sender's relationship with your data, then issue the command trigger.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -