Wpf Material 设计日期时间选择器
Wpf Material Design Date-Time Picker
我使用了 Material Design in XAML Toolkit 中的代码,在代码下方。
<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前缀后,又报错:
"Failed to create a 'DialogOpenedAttached' from the text 'CombinedDialogOpenedEventHandler'.' Line number '21' and line position '48'.'"
materialDesign
前缀应映射到 http://materialdesigninxaml.net/winfx/xaml/themes
XAML 命名空间:
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
我使用了 Material Design in XAML Toolkit 中的代码,在代码下方。
<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前缀后,又报错:
"Failed to create a 'DialogOpenedAttached' from the text 'CombinedDialogOpenedEventHandler'.' Line number '21' and line position '48'.'"
materialDesign
前缀应映射到 http://materialdesigninxaml.net/winfx/xaml/themes
XAML 命名空间:
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"