【问题标题】:Wpf Material Design Date-Time PickerWpf Material Design 日期时间选择器
【发布时间】:2019-12-18 13:42:26
【问题描述】:

我使用了 XAML Toolkit 中 Material Design 中的代码,在代码下方。

<StackPanel Orientation="Horizontal">
    <TextBlock Text="{Binding Date, 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="0" Orientation="Horizontal">
                    <Calendar x:Name="CombinedCalendar" Margin="-1 -4 -1 0" />
                    <materialDesign:Clock x:Name="CombinedClock" DisplayAutomation="CycleWithSeconds" Is24Hours="True" />
                </StackPanel>
                <StackPanel Grid.Row="1" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
                    <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="0" Style="{DynamicResource MaterialDesignFlatButton}">
                        CANCEL
                    </Button>
                    <Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" CommandParameter="1" Style="{DynamicResource MaterialDesignFlatButton}">
                        OK
                    </Button>
                </StackPanel>
            </Grid>
        </Button.CommandParameter>
    </Button>
</StackPanel>

但是我有很多错误。我无法修复错误,因为我是 wpf 的新手。

错误:

如何修复错误?

编辑: 映射materialDesign前缀后,又报错:

“无法从文本‘CombinedDialogOpenedEventHandler’创建‘DialogOpenedAttached’。”行号 '21' 和行位置 '48'。'"

【问题讨论】:

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


    【解决方案1】:

    materialDesign 前缀应映射到 http://materialdesigninxaml.net/winfx/xaml/themes XAML 命名空间:

    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    

    【讨论】:

    • 也给出错误:“无法从文本‘CombinedDialogOpenedEventHandler’创建‘DialogOpenedAttached’。”行号'21'和行位置'48'。'"
    • 如果删除DialogOpenedAttachedDialogClosingAttached 会怎样?那么它会编译吗?
    • 后面的代码中有DialogOpenedAttachedDialogClosingAttached 吗?如果按 F7,您应该有两个具有这些名称的事件处理程序(无效方法)。如果您没有它们,请返回到它们在 xaml 中写入的位置(Shift+F7)并重新键入。完成名称后,按 Tab,它应该会为您创建它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-22
    • 2021-07-27
    • 1970-01-01
    • 2018-05-21
    • 2012-09-11
    • 1970-01-01
    相关资源
    最近更新 更多