0

I have a windows phone application.

Whenever I set a buttons visibility to collapse and I make it visible again I have to click on it twice to get it to fire the command it binds to. How can I make it fire after the first time again? It does not even hit any code at all on the first time. Both the visibility and button command is set through binding it to the view model properties.

4

2 回答 2

0

我认为问题来自“焦点”问题。我怀疑焦点被能见度的变化弄糊涂了。然后使用第一次单击来恢复焦点。

为避免此问题,我在更改可见性后强制将焦点放在按钮上

  private void RequestDialogBoxEvent(object sender)
    {

        this.DialogBox.Visibility = System.Windows.Visibility.Visible;
        this.buttonOK.Focus();
    }

使用对话框的 XAML:

   <Border  x:Name="DialogBox" Background="Black" Grid.Row="1" Visibility="Collapsed" >
        <Grid  Margin="0,20" VerticalAlignment="Center" Background="Black">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <TextBlock Text="Confirm ?"  />
            <Button x:Name="buttonOK" Content="OK" Grid.Row="1" Click="Button_Click" />
        </Grid>
    </Border>
于 2014-04-11T20:40:59.703 回答
0

我猜你正在使用 MVVM 灯?

如果是这样,我在使用 ICommand 时遇到了一些类似的问题。如果您只使用内置的中继命令,那么这为我解决了问题。

于 2013-11-04T15:48:54.310 回答