【发布时间】:2017-12-08 13:02:37
【问题描述】:
我有一个带有 TextBlock 和两个按钮的简单 UserControl。
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Height="30" Text="Please install updates" Foreground="#FFF" FontWeight="Bold" Margin="0,0,0,20" Grid.RowSpan="2"/>
<Button Grid.Column="0" Grid.Row="1" Content="Restart Now" Margin="5 0 0 0" Width="80" Height="25" HorizontalAlignment="Right" />
<Button Grid.Column="1" Grid.Row="1" Content="Snooze" Width="60" Height="25" Margin="10 0 0 0" HorizontalAlignment="Left" Click="bttnOK_Click" />
</Grid>
由于某种原因 TextBlock 是可点击的,当您点击它时,它会关闭控件。
期望的行为:不可点击的文本块。单击 TextBlock 时,控件保持打开状态。
【问题讨论】:
-
通常它们是不可点击的。也许您有一种覆盖默认属性的样式?将
IsCancel设置为true的位置。 -
你能提供更多关于父对象/样式的细节吗?
-
我刚刚将您的 XAML 复制到了一个全新的项目中,
Textblock是不可点击的。问题一定出在其他地方。 -
这个UserControl在telerik DesktopAlert里面,也许这就是导致问题的原因。