首页 > 编程知识 正文

c语言网,c++入门教程

时间:2023-05-03 17:10:32 阅读:174881 作者:2323

Popup控件是常用的非常有用的控件,wwdyet是弹出控件。 让我们先看看MSDN的描述。 表示有内容的弹出窗口。 这是非常重要的控件。 看看继承关系:

Popup控件直接从框架元素继承,属于非常高的级别。 我们使用最多的属性是以下属性。 1PlacementTarget表示放置Popup控件的位置所依赖的对象。 这通常使用绑定方法指示Popup控件的停靠位置。 例如,placement target=' { binding element name=pCheckBox } '表示Popup的停靠位置依赖于名为pcheckbox的ChenkBox对象。 这也是一种常用情况,当获取或设置Popup控件和checkbox为2 Placement属性:或设置方向的Popup控件时,控件将打开,指定行为的Popup控件将与屏幕边界重叠在MSDN的上面的描述中,可以通过设置关联的特性来定位弹出窗口,并且可以定位弹出窗口、放置目标、放置位置、水平偏移、垂直偏移、垂直偏移3实际上,这里PlacementRectangle、HorizontalOffset和VerticalOffsetProperty这些属性可以等价替换。 所有这些都可以微调Popup弹出窗口的位置。 4 IsOpen属性,这是最重要的属性之一,通常采用绑定方式赋值。 例如,is open=' { binding element name=pcheckbox,Path=IsChecked} '是绑定checkbox的IsChecked。最后,关于StayOpen属性MSDN被解释为获取或设置一个值,该值指示当Popup控件不再聚焦时是否关闭控件。 如果将StaysOpen属性设置为true,则Popup将始终处于打开状态,直到将IsOpen属性设置为false并显式禁用它为止。 如果StaysOpen设置为false,则Popup控件将侦听所有鼠标和键盘事件,并确保在Popup控件之外发生这些事件之一。 最明显的区别在于,当IsOpen设置为True时,Popup控件会弹出,如果用鼠标单击其他位置,Popup将失去焦点,Popup将隐藏,StaysOpen将隐藏

此外,还可以设置Popup弹出时的动画效果。 PopupAnimation='Fade '表示弹出窗口将淡入。 这些在使用时需要注意。

用小例子说明Popup的使用方法。 TextBox和Popup的组合可以达到类似百度搜索框的效果。 首先发布重点的实现代码。

Text='{Binding DutyPersonName,Mode=TwoWay,updatesourcetrigger=property changed } '

Width='70 '

Tag='{Binding DataContext,relative source={ relativesourcemode=find ancestor,AncestorType=ItemsControl}} '

command parameter=' { bindingrelativesource={ relativesourcemode=find ancestor,AncestorType=TextBox}} '

command parameter=' { bindingrelativesource={ relativesourcemode=find ancestor,AncestorType=TextBox}} '

Width='{Binding ActualWidth,ElementName=dutyPersonTextBox} '

is open=' { binding element name=dutypersontextbox,Path=IsKeyboardFocused,Mode=OneWay} '

StaysOpen='True '

SnapsToDevicePixels='true '

items source=' { bindingdatacontext.specifichistorymembers,relative sourcemode={ find ancestor}},ancestor,ancestor

HorizontalAlignment='Stretch '

scroll viewer.horizontalscrollbarvisibility=' disabled '

Background='#fff '

command parameter=' { bindingrelativesource={ relativesourcemode=find ancestor,AncestorType=ListBox}} '

Height='Auto '

Width='Auto '

border brush=' { templatebindingborderbrush } '

border thickness=' { templatebindingborderthickness } '

background=' { templatebindingbackground } '

Padding='1'

SnapsToDevicePixels='true '

snapstodevicepixels=' { templatebindingsnapstodevicepixels } '

vertical alignment=' { templatebindingverticalcontentalignment } ' /

Value='false '

value=' {动态资源{ x : staticsystemcolors.graytextbrushkey } } /

IsItemsHost='True '

HorizontalAlignment='Left '

VerticalAlignment='Center '

Width='{Binding ActualWidth,ElementName=dutyPersonTextBox} '

Padding='2'

SnapsToDevicePixels='true '

BorderThickness='1'

HorizontalAlignment='Stretch '

horizontalcontentalignment=' left '

FontSize='13 '

Value='true '

Value='#00a3d9'

TargetName='Border '

Value='0.6 '

TargetName='Border '

最终实现的效果如下。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。