小编Dmi*_*riy的帖子

无法将事件处理程序附加到Style中的上下文菜单项

我试图修改默认ContextMenuXamNumericEditorXamDataGrid可编辑单元.

这是我的XAML代码:

<igDP:XamDataGrid.Resources>
  <Style TargetType="{x:Type editors:XamNumericEditor}">
    <Setter Property="ContextMenu">
      <Setter.Value>
        <ContextMenu>
          <ContextMenu.Items>
            <MenuItem Header="Select All"
                      Command="SelectAll">
              <MenuItem.Icon>
                <Image Source="..\icons\table_select_all.png"/>
              </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Accept for column"
                      Click="MenuItem_Click">
            </MenuItem>
          </ContextMenu.Items>
        </ContextMenu>
      </Setter.Value>
    </Setter>
  </Style>
</igDP:XamDataGrid.Resources>
Run Code Online (Sandbox Code Playgroud)

代码隐藏文件包含此MenuItem的事件hadler:

private void MenuItem_Click(object sender, RoutedEventArgs e)
{
//...
}
Run Code Online (Sandbox Code Playgroud)

但是当我启动它时,我捕获一个带有消息的异常: 无法将类型为'System.Windows.Controls.MenuItem'的对象强制转换为'System.Windows.Controls.ContextMenu'.

你能帮帮我吗?谢谢.

wpf xaml infragistics styles event-handling

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

INotifyPropertyChanged 不更新值转换器

我有一些实现INotifyPropertyChanged接口的属性。它工作正常。但是在我的代码中,我也使用了一些值转换器(如果值 < 3 - 将网格设为红色,如果值 >3 且值 < 10 - 将网格设为蓝色等)。

问题是如何在提出PropertyChanged后刷新值转换器?解决方案背后是否有简单的代码?谢谢大家,对不起我的英语不好!

这里有一些代码:

public class NotifyColors : INotifyPropertyChanged
{
    private Color _TodayColor;
    public Color TodayColor
    {
        get
        {
            return _TodayColor;
        }
        set
        {
            if (_TodayColor != value)
            {
                _TodayColor = value;
                OnPropertyChanged("TodayColor");
            }
        }

    }

    public event PropertyChangedEventHandler PropertyChanged;

    private void OnPropertyChanged(String info)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(info));
            // it raised correctly when I change color with color picker control
        }
    } …
Run Code Online (Sandbox Code Playgroud)

wpf binding inotifypropertychanged ivalueconverter

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

PHP PDO INSERT WHERE NOT EXISTS语句不起作用

我通过PDO向MySQL插入查询时出现了非常奇怪的错误.

如果此记录在此表中不存在,我想在表中插入记录.

$query = "INSERT INTO Phrases (KeyText)
            SELECT * FROM (SELECT :key_text) as tmp WHERE NOT EXISTS (SELECT 1 FROM Phrases WHERE KeyText = :key_text)";

    try
    {
        $preparedStatement = $db->prepare($query);
        foreach ($phrases as $phrase)
        {
            $preparedStatement->execute(array(':key_text' => $phrase));
            echo "-";
        }
    }
    catch(PDOException $e)
    {  
        echo $e->getMessage();  
    }
Run Code Online (Sandbox Code Playgroud)

它抛出exeption:在非对象上调用成员函数execute().

我不明白SQL命令中的错误在哪里.其他代码是正确的,因为当我将SQL命令更改为其他代码(例如:SELECT:key_text为kt)时,它可以正常工作.

谢谢你的回答.

更新:错误是:

[0] => HY000 [1] => 1096 [2] =>没有使用表格

如何为MySQL创建正确的SQL命令?变种与

INSERT INTO Phrases (KeyText)
SELECT :key_text WHERE NOT EXISTS (SELECT 1 FROM Phrases WHERE KeyText = …
Run Code Online (Sandbox Code Playgroud)

php mysql pdo

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

无法在 Kubernetes 中运行 .NET 应用程序

我正在尝试在本地 kubernetes 集群(Kind)中部署一个简单的 .NET 应用程序以进行测试。应用部署时,Pod 启动时不会出现错误。但镜像构建得很好,因为如果在 Docker 中本地启动,容器就可以很好地工作。

NAME                             READY   STATUS    RESTARTS   AGE
orderproducer-68d5ff7944-d2d89   0/1     Error     4          103s
Run Code Online (Sandbox Code Playgroud)
kubectl logs -l app=orderproducer

Could not execute because the application was not found or a compatible .NET SDK is not installed.
Possible reasons for this include:
  * You intended to execute a .NET program:
      The application 'OrderProducer.dll' does not exist.
  * You intended to execute a .NET SDK command:
      It was not possible to find any installed .NET SDKs.
      Install a .NET …
Run Code Online (Sandbox Code Playgroud)

.net docker kubernetes kind

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