2

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;
}

当我单击提交按钮控件时,SubmitCommandExecutePopup窗口未显示。我对 WPF 有点陌生,摸不着头脑。最后在这里提出这个问题。可能有什么问题。

4

2 回答 2

1

I think the problem is in the way you are testing the code. SInce you are sleeping in the UI thread, the UI does not feel the change from true to false on the bound property. Try to use a timer instead of a Sleep in the thread.

于 2012-12-31T09:33:20.057 回答
-2

鉴于 msdn 上的 RaisePropertyChanged 语法:

protected internal void RaisePropertyChanged (
   string propertyName
)

你应该尝试RaisePropertyChanged("PopUpIsOpen");而不是RaisePropertyChanged(() => this.PopUpIsOpen);

于 2012-12-31T09:26:10.667 回答