我将一个 AppBarToggleButton 的 IsChecked 设置如下(当我选中它时,能够使 MySplitView
展开 Pane,反之亦然):
<AppBarToggleButton
IsChecked="{Binding IsPaneOpen, ElementName=MySplitView, Mode=TwoWay}" />
这个 AppBarToggleButton 如果处于 Page 的 Grid
中,那么,当我点击它时,它能够实现这一作用:
<Page>
<Grid x:Name="LayoutRoot">
<AppBarToggleButton
IsChecked="{Binding IsPaneOpen, ElementName=CommentSplitView, Mode=TwoWay}" />
// 略。
<Grid>
</Page>
但当我把它放入
自定义用户控件时,它
IsChecked 却不起作用了(能被选中,但没有实现应有的功能):
<Page>
<Grid x:Name="LayoutRoot">
<control:MyContol>。
<control:MyControl.Content> // 这个 Content 属性是个 ContentPresenter
<AppBarToggleButton
IsChecked="{Binding IsPaneOpen, ElementName=CommentSplitView, Mode=TwoWay}" /> // 现在,当我选中它时,Pane 不在发生改变。
<control:MyControl.Content>
</control:MyContol>
// 略。
<Grid>
</Page>