编辑:我再次测试了另一个对话框,它似乎显示出与上述对话框相同的问题。
编辑2:经过更多测试后,这似乎是一个焦点问题。对话框弹出时,它没有响应。但是,如果我单击到其他窗口或屏幕,然后单击返回,则控件将按预期工作。
我有一个UserControl,它将用作DialogHost(来自MaterialDesignInXAML Toolkit)中的对话框。当我在对话框上调用DialogHost.Show时,它会弹出,但其中的控件(即一些文本框,一些列表视图和一个按钮)实际上什么也没做。它们会播放与它们关联的任何动画,但是例如在文本框中,我实际上无法键入它们。
我注意到,当我在.Show()调用之前进行调试时添加断点时,它可以按预期工作。我可以在文本框中键入内容,也可以单击列表视图中的项目,等等。我也尝试过移动电话,但这似乎仍然存在问题。
ThreeSixtyPackageDialog.xaml
<UserControl x:Class="MultiCapture2._0.Views.ThreeSixtyPackageDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MultiCapture2._0.Views"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
MinWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="{StaticResource DvsportBlackHeaderFooter}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Name="TitleTextBlock" Text="360 Package Information" Foreground="{StaticResource DvsportLightText}" Padding="10"
HorizontalAlignment="Left"></TextBlock>
<Button Grid.Column="1" Name="CloseButton" Content="{materialDesign:PackIcon Close}" Command="materialDesign:DialogHost.CloseDialogCommand"
Foreground="{StaticResource DvsportLightText}" Background="Transparent" BorderThickness="0" materialDesign:ShadowAssist.ShadowDepth="Depth0"></Button>
</Grid>
<StackPanel Grid.Row="1" Background="{StaticResource DvsportBlackBackground}">
<TextBox Name="FromTextBox" materialDesign:HintAssist.Hint="From" Padding="10 0 0 0" Foreground="{StaticResource DvsportLightText}" Style="{StaticResource MaterialDesignFloatingHintTextBox}"></TextBox>
<TextBox Name="MessageTextBox" materialDesign:HintAssist.Hint="Message" Padding="10 0 0 0" Foreground="{StaticResource DvsportLightText}" Style="{StaticResource MaterialDesignFloatingHintTextBox}"></TextBox>
<TextBox Name="PathTextBox" materialDesign:HintAssist.Hint="Path" Text="/MULTICAPTURE" CharacterCasing="Upper" Padding="10 0 0 0" Foreground="{StaticResource DvsportLightText}" Style="{StaticResource MaterialDesignFloatingHintTextBox}"></TextBox>
</StackPanel>
<Button Grid.Row="2" Height="40" Foreground="{StaticResource DvsportBlackBackground}" Background="{StaticResource DvsportGold}" BorderBrush="{StaticResource DvsportBlackBackground}" BorderThickness="0" Click="SaveButton_OnClick" Content="Save"/>
</Grid>
</UserControl>
ThreeSixtyPackageDialog.xaml.cs
public partial class ThreeSixtyPackageDialog : UserControl
{
public ThreeSixtyPackageDialog()
{
InitializeComponent();
}
private void SaveButton_OnClick(object sender, RoutedEventArgs e)
{
DialogHost.CloseDialogCommand.Execute(null, null);
}
}
MonitorUserControl.Events.xaml.cs(弹出对话框的位置
...
packageFileUtil.CreatePackageFile(result.Payload, input.InputNum, pendingScheduleToStop);
if (pendingScheduleToStop == null)
{
var threeSixtyPkgDialog = new ThreeSixtyPackageDialog();
await DialogHost.Show(threeSixtyPkgDialog, "
}
...
我从完全相同的位置调用了另一个对话框,它按预期加载,我可以按预期单击并键入。因此,我无法弄清此对话框被打破的原因。