我想要做的是将两个控件放在相同的位置/点,具体来说是一个按钮,其中包含一个ProgressBar和一个包含图标的按钮,一旦进度栏已满,我想将它切换到具有图标的按钮,如复选框/切换按钮,它有多个状态,当我更改它时,它会更改控件。控件WPF切换2控件在同一地点
形象的例子:
OBS:这种控制的使用MahApps
标题栏控件 OBS2:我使用的材料设计XAML和Caliburn.Micro为真棒MVVM
XAML示例:
<Button FontSize="15"
FontWeight="Bold"
cal:Message.Attach="UpdateStatus"
ToolTip="Click here to show the update status."
Visibility="Visible">
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}"
Value="0"
IsIndeterminate="True"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Height="22"
Width="22" Foreground="White"/>
</Button>
<Button FontSize="15"
FontWeight="Bold"
cal:Message.Attach="Restart"
ToolTip="A update is scheduled, click here to restart the loader and apply the update."
Visibility="{Binding Path=RestartButtonVisibility, Mode=TwoWay}">
<materialDesign:PackIcon Height="22"
Width="22"
Kind="Cached"
FontWeight="Bold"/>
</Button>
是否有可能一个完成那个?有没有一种不是意大利面的完美方式?
更好地写'返回(双)值<100? Visibility.Collapsed:Visibility.Visible',或'return(double)value <100? Visibility.Hidden:Visibility.Visible',如果你想提前完成布局。如果转换器不支持反向转换,则抛出NotSupportedException。只是要有点细致。 – Clemens
谢谢你们,网格技巧解决了这个问题,但我会以另一种方式处理可见性变化。 –