- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
如下所示,我有一个弹出窗口,我想用右下角的拇指调整它的大小。拇指有一个附加行为,我想调整大小。
<Popup x:Name="Popbox" Placement="Mouse" StaysOpen="False" Width="50" Height="50" >
<Grid>
<Border Background="AliceBlue"/>
<Thumb HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Width="16" Height="16" >
<i:Interaction.Behaviors>
<helpers:PopupResizeBehaviors PopupObject="{Binding ElementName=Popbox}"/>
</i:Interaction.Behaviors>
</Thumb>
</Grid>
</Popup>
class PopupResizeBehaviors : Behavior<Thumb>
{
private bool mouseDown;
private Point oldMousePosition;
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.PreviewMouseLeftButtonDown += (s, e) =>
{
mouseDown = true;
};
AssociatedObject.DragDelta += (s, e) =>
{
if (!mouseDown) return;
double tempWidth = 0;
double tempHeight = 0;
PopupObject.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
tempWidth = PopupObject.DesiredSize.Width;
tempHeight = PopupObject.DesiredSize.Height;
double yadjust = tempHeight + e.VerticalChange;
double xadjust = tempWidth + e.HorizontalChange;
PopupObject.Width = xadjust;
PopupObject.Height = yadjust;
};
AssociatedObject.PreviewMouseLeftButtonUp += (s, e) =>
{
mouseDown = false;
};
}
protected override void OnDetaching()
{
base.OnDetaching();
}
public static readonly DependencyProperty PopupObjectProperty =
DependencyProperty.RegisterAttached("PopupObject", typeof(Popup), typeof(PopupResizeBehaviors), new UIPropertyMetadata(null));
public Popup PopupObject
{
get { return (Popup)GetValue(PopupObjectProperty); }
set { SetValue(PopupObjectProperty, value); }
}
}
它目前无法正常工作,但应该可以很好地了解我的目标。
如何让这种行为发挥作用?
最佳答案
这是我最后用的。
class PopupResizeBehaviors : Behavior<Thumb>
{
private const int MaxSize = 500;
private const int MinSize = 50;
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.DragDelta += (s, e) =>
{
Thumb t = s as Thumb;
if (t.Cursor == Cursors.SizeWE || t.Cursor == Cursors.SizeNWSE)
{
PopupObject.Width = Math.Min(MaxSize,
Math.Max(PopupObject.Width + e.HorizontalChange,
MinSize));
}
if (t.Cursor == Cursors.SizeNS || t.Cursor == Cursors.SizeNWSE)
{
PopupObject.Height = Math.Min(MaxSize,
Math.Max(PopupObject.Height + e.VerticalChange,
MinSize));
}
};
}
protected override void OnDetaching()
{
base.OnDetaching();
}
public static readonly DependencyProperty PopupObjectProperty =
DependencyProperty.RegisterAttached("PopupObject", typeof(Popup), typeof(PopupResizeBehaviors), new UIPropertyMetadata(null));
public Popup PopupObject
{
get { return (Popup)GetValue(PopupObjectProperty); }
set { SetValue(PopupObjectProperty, value); }
}
}
关于c# - 通过具有附加行为的 Thumb 调整弹出窗口的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28064999/
我正在尝试学习对固件修改有用的技能(我没有源代码) 这些问题涉及使用 BX 从拇指代码跳转或调用其他现有拇指代码。 我如何使用 BX 从我的 THUMB 代码跳转到现有固件 THUMB 代码。 我如何
我正在研究具有 Thumb-2 指令集的 ARM Cortex-M3 Controller 。 Thumb 模式用于将指令压缩为 16 位大小。 因此减少了代码的大小。但是正常的Thumb模式下,为什
我对指令集有点困惑。有 Thumb、ARM 和 Thumb 2。从我所读到的 Thumb 指令都是 16 位的,但在 内。 ARMv7M 用户手册 (第 vi 页)提到了 Thumb 16 位和 Th
我有一个要求,我需要在其中实现竖起大拇指、不竖起大拇指的类型的切换按钮,我正在努力了解如何实现这一点。我不确定我是否可以创建一种样式,并且这种样式会根据按钮的按下方式改变图像的背景.... 谁能分享一
我正在尝试创建一个带有拇指的搜索栏,当用户按下它时会改变颜色,当用户松开时会变回颜色。我设法使用 set thumb 更改了 thumb drawable。但是,我还必须在 java 中设置可绘制边界
以下是thumb-2指令的w后缀,如果没有它,它将如何改变指令的语义?搜索结果非常嘈杂,我没有得到答案。 addw r0, r1, #0 最佳答案 我在Cortex-M3 TRM表2-5中看到了ADD
为什么 ARM Controller 在发生异常时要从 THUMB 状态返回到 ARM 状态? 最佳答案 一种解释可能是 ARM 模式是 CPU 的“ native ”操作模式,与有限的 Thumb
我正在为需要链接到现有 THUMB 代码的嵌入式内核 (ARM7TDMI) 编写 THUMB 代码。我正在使用 GNU ARM 嵌入式工具链 ( link )。我无法让链接器将现有的外部代码视为 TH
我正在尝试使用 THUMB 指令创建一个阶乘方法,我基本上做到了。 我只有一个关于 PUSH/POP 操作码的问题:如果我使用 push 将 r0 的值存储在堆栈中(所以 push {r0} ),我可
我正在尝试显示位于拇指上方居中的范围项的值。通过读取值并将元素定位在范围元素上方作为其 clientWidth 的百分比,这非常有效。 然而,距离中间的偏移量越来越大(见图片),这导致值不在拇指上居中
我有一个弹出控件,我添加了一个拇指,这样我就可以将它拖动到屏幕上。拇指的 DragDelta 事件已重载: private static void Thumb_DragDelta(object sen
是否有用于 thumb-2 汇编的模拟器之类的东西?我想编写简单的 ARM Thumb-2 汇编程序并在不需要使用实际 ARM 设备的情况下对其进行测试,所以我唯一的选择是仿真。 我的目标是在 thu
我正在尝试在 slider 组件内的 JSlider Thumb 上方添加一个标签(按坐标方向)。因此,我尝试在 slider 的父组件中执行以下操作: this.setLayout(
我运行了一个我发明的 Java 守护程序,它监视我的 Windoze 10 笔记本电脑上的一个目录,并通过打开它来粉碎进入它的所有内容,将其当前大小写入 NULL,保存它,然后删除它。它笨手笨脚,但有
我正在尝试在 Google App Engine 中调整图像大小并裁剪图像以创建缩略图 我希望能够创建任意尺寸的 200x150 拇指。 这是我到目前为止使用的代码,现在我需要对其进行裁剪,使其不大于
我已经制作了我的音乐应用程序,现在我需要在搜索栏上制作音乐播放/暂停控件。这是图片 如您所见,seekbar 带有自定义拇指图像,当用户触摸拇指音乐时,音乐开始播放或停止。是否可以实现类似的功能?基本
我正在开发谷歌浏览器扩展程序。在那里我想获取顶级站点的缓存缩略图。 当我访问像 chrome://thumb/http://www.google.com/ 这样的 url 时,我可以看到缩略图。但在我
我为一些 slider 创建了一个自定义类。在 chrome 中一切正常。请参见下图: Chrome 但我的问题是在 Internet Explorer 上我得到了这个: 现在这是我的 CSS: in
有没有人对 IE11 中输入范围控件上的 ms-thumb 伪元素的样式和控制行为有任何经验? 如果控件比 thumb 伪元素高,则拖动后 thumb 会粘在顶部并且不会返回到它的原始位置。 Here
我正在使用 prettyphoto 并想切换到 fancybox,我的画廊正在使用 isotope 进行滤镜和动画处理,但我认为这不是问题所在。图像出现,但没有拇指!在开发工具中,当选择图片时,有一个
我是一名优秀的程序员,十分优秀!