【发布时间】:2012-06-18 11:34:23
【问题描述】:
这就是我想要做的。
切换按钮 1 (editNameOpen)
- 选中后,显示弹出内容
- 关闭它的唯一方法是使用弹出窗口内的另一个切换按钮 (editNameClose)
切换按钮 2 (editNameClose)
- 弹出窗口内的这个
- 当 IsChecked 时,关闭弹出窗口并关闭 editNameOpen
这是我用来尝试解决问题的一些 xaml。到目前为止的问题/疑问:
- 我的 MultiBinding 错误并引发运行时错误“无法设置 MultiBinding,因为必须指定 MultiValueConverter。”在这种情况下,MultiValueConverter 会转换什么?
- 在选中第二次时,我将如何关闭第1次切换按钮?
干杯,
浆果
<ToggleButton x:Name="editNameOpen" Style="{StaticResource EditToggleButtonStyle}" Grid.Column="1" Grid.Row="0"/>
<Popup x:Name="popupNameEditingControl"
PlacementTarget="{Binding ElementName=editeditNameOpenName}"
PopupAnimation="Slide"
StaysOpen="False" ** shoulf this be true?
MinWidth="50">
** open and stay open while until editNameClose is checked
<Popup.IsOpen>
<MultiBinding >
<Binding Mode="OneWay" ElementName="editNameOpen" Path="IsChecked"/>
<Binding Mode="OneWay" ElementName="editNameClose" Path="IsChecked" Converter="{StaticResource invertBoolConv}"/>
</MultiBinding>
</Popup.IsOpen>
** how do we reset editNameOpen to be NOT IsChecked when editNameClose is checked?
** how do we reset editNameClose to be NOT IsChecked and then reset editNameClose to also be not checked when this opens again?
<StackPanel Orientation="Horizontal" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
<Label Content="Hello Wolrd!"/>
<ToggleButton x:Name="editNameClose" Content="X"/>
</StackPanel>
</Popup>
【问题讨论】: