XAML
<Popup Name="popUpProgress" Width="225" Height="85"
IsOpen="{Binding PopUpIsOpen,Mode=OneWay}"
Placement="Center" PlacementTarget="{Binding ElementName=stkListview}"
VerticalAlignment="Top">
<Border BorderThickness="1" Background="Blue" >
<Grid Width="225" Height="85">
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Label x:Name="lblProgress" Content="Please Wait ...." Margin="10,5,0,0" HorizontalAlignment="Left" Grid.Row="1" />
</Grid>
</Border>
</Popup>
在 View 模型中:
private bool _PopUpIsOpen;
public bool PopUpIsOpen
{
get { return _PopUpIsOpen; }
set
{
_PopUpIsOpen = value;
RaisePropertyChanged(() => this.PopUpIsOpen);
}
}
public RelayCommand SubmitCommand { get; private set; }
private bool SubmitCommandCanExecute()
{
return true;
}
private void SubmitCommandExecute()
{
PopUpIsOpen = true;
dsStandardListbyMarket = marketBL.StandardListbyMarketBL(Convert.ToInt32(SelectdMarketId), Convert.ToInt32(Users.UserId));
GetComboboxMappingCollections(Convert.ToInt32(this.SelectdMarketId), Users.UserId);
FItems = new ObservableCollection<MarketRecord.FItem>();
FItems.CollectionChanged += OnUICollectionChanged;
marketBL.FetchMarketRecords(Convert.ToInt32(this.SelectdMarketId));
IsSubmitButtonVisible = true;
PopUpIsOpen = false;
}
当我单击提交按钮时,控件进入 SubmitCommandExecute
但未显示 Popup
窗口。我对 WPF 有点陌生,摸不着头脑。终于在这里提出这个问题。可能出了什么问题。
最佳答案
我认为问题在于您测试代码的方式。由于您在 UI 线程中休眠,因此 UI 感觉不到绑定(bind)属性从 true 到 false 的变化。 尝试在线程中使用计时器而不是 Sleep。
关于c# - MVVM+ WPF PopUp 打不开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14099666/