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>
在视图模型中:
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有点新意,抓住了我的头。最后提出这个问题。可能是错的。
答案 0 :(得分:1)
我认为问题在于您测试代码的方式。如果你在UI线程中睡觉,UI就不会感觉到绑定属性上从true变为false。 尝试在线程中使用计时器而不是Sleep。
答案 1 :(得分:-2)
鉴于msdn上的RaisePropertyChanged语法:
protected internal void RaisePropertyChanged (
string propertyName
)
您应该尝试RaisePropertyChanged("PopUpIsOpen");
而不是RaisePropertyChanged(() => this.PopUpIsOpen);