xaml代码将DialogHost与使用Material Design的Calendar和Clock控件结合使用时,WPF视图崩溃

时间:2018-12-08 20:14:58

标签: c# wpf material-design-in-xaml

使用日期和时间选择器时出现问题,该选择器是从“材料设计演示”中复制的。当我使用此自定义对话框时,会出现以下错误:

ArgumentException:无法绑定到目标方法,因为其签名或安全透明性与委托类型的签名或安全透明性不兼容。

我希望它与DialogHost.OpenDialogCommand或

有关
materialDesign:DialogHost.DialogOpenedAttached="CombinedDialogOpenedEventHandler"

当我使用Material Design Demo的日期选择器时,我的代码可以正常工作而没有任何问题。

XAML代码:

<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal">
        <TextBlock Text="{Binding Inspection.startDateTime, StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" VerticalAlignment="Center" FontSize="24" />
            <Button Margin="8 0 0 0" Content="..." Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}" materialDesign:DialogHost.DialogOpenedAttached="CombinedDialogOpenedEventHandler" materialDesign:DialogHost.DialogClosingAttached="CombinedDialogClosingEventHandler">
                <Button.CommandParameter>
                <Grid Margin="-1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="2" Orientation="Horizontal">
                        <Calendar x:Name="CombinedCalendar" Margin="-1 -4 -1 0" />
                        <materialDesign:Clock x:Name="CombinedClock" DisplayAutomation="CycleWithSeconds" Is24Hours="True" />
                    </StackPanel>
                    <StackPanel Grid.Row="2" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
                        <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="1" Style="{DynamicResource MaterialDesignFlatButton}">
                            OK
                        </Button>
                        <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="0" Style="{DynamicResource MaterialDesignFlatButton}">
                            CANCEL
                        </Button>
                    </StackPanel>
                </Grid>
            </Button.CommandParameter>
        </Button>
    </StackPanel>

编辑

材料设计网站:http://materialdesigninxaml.net/

材料设计演示的下载链接:https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/releases/download/v2.5.0/Demo.2.5.0.1205.zip

0 个答案:

没有答案