.NET Framework 4.8迁移至.NET 6后WPF自定义模板按钮不显示
.NET Framework 4.8迁移至.NET 6.0后WPF按钮消失问题
将.NET WPF应用从.NET Framework 4.8迁移至.NET 6.0后,原本正常显示的按钮消失了,迁移过程中未修改任何代码。
.NET Framework下正常显示效果:
.NET 6.0下按钮缺失的显示效果:
相关按钮的XAML代码如下:
<Style TargetType="{x:Type dialog:DialogTemplate}" BasedOn="{StaticResource {x:Type Window}}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type dialog:DialogTemplate}"> <Grid Background="White"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="42" /> </Grid.RowDefinitions> <ContentPresenter Margin="10" /> <StackPanel HorizontalAlignment="Right" Grid.Row="1" Orientation="Horizontal" Margin="10"> <Button IsDefault="True" Command="dialog:DialogTemplate.DialogOKClickedCommand" Width="100" Margin="0,0,5,0" Content="{TemplateBinding OKButtonText}" /> <Button IsCancel="True" Width="100">Abbrechen</Button> </StackPanel> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
已尝试调整ControlTemplate和ContentPresenter,但问题未解决,求排查按钮无法显示的原因。
内容的提问来源于stack exchange,提问作者Lukman
相关产品推荐
相关产品推荐

