你好.我有一个包含文本框的UserControl.我想访问文本框的textchanged事件,但在usercontrol的事件属性中,我没有看到文本框的事件.如何使用C#从Winforms中公开公开的UserControl公开和处理子控件的特定事件.
可以说我有这段代码:
<Window>
<Window.Resources>
<Color x:Key="MyColor"
A="255"
R="152"
G="152"
B="152" />
<DropShadowEffect x:Key="MyEffect"
ShadowDepth="0"
Color="{StaticResource MyColor}"
BlurRadius="10" />
<Style x:Key="MyGridStyle"
TargetType="{x:Type Grid}">
<Setter Property="Height"
Value="200" />
<Setter Property="Width"
Value="200" />
<Style.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Width"
Value="100" />
</Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Height"
Value="100" />
<Setter Property="Width"
Value="100" />
</Style>
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsMouseOver"
Value="true">
<!-- How do I apply my effect when this grid is hovered over to Image and TextBox, but not the grid itself? -->
</Trigger>
</Style.Triggers> …Run Code Online (Sandbox Code Playgroud) 我有一个TGridLayout在Firemonkey HD应用程序中填充了一些图像.在gridLayout的onMouseDown事件中,我想获取用户点击的图像对象,但我只有鼠标坐标.
为每个图像实现onMouseDown事件不是一种选择,因为如果从gridlayout中删除图像,则会留下空白空间.在这种情况下,我还想知道用户是否已经点击了这个空白区域.
是否有某种"getChildAtPos"或"FindVCLWindow"模拟在Firemonkey?
谢谢!
我有一个列表框,在datatemplate中我有一个Expander.
如果我单击Expander Header,扩展器将展开内容区域,但不会使父ListBoxItem选中.
如果我单击Expander的Expanded Content Zone,则会选择父ListBoxItem.
单击expandderHeader时如何使内容扩展并且父列表框项被选中?
如何更好地ListView.SelectedItem控制内部的儿童控制ListView?
<ListView ItemsSource="{Binding Path=Records, Mode=TwoWay}" IsSynchronizedWithCurrentItem="True">
<ListView.SelectedItem>
<Binding Path="SelectedRecord" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"/>
</ListView.SelectedItem>
<ListView.ItemContainerStyle>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Setter Property="IsSelected" Value="True"/>
</Trigger>
</Style.Triggers>
</Style>
</ListView.ItemContainerStyle>
<ListView.Resources>
<DataTemplate DataType="x:Type ListViewItem">
<ListViewItem IsSelected="{Binding IsKeyboardFocusWithin"/>
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn>
<TextBox ... Tag="{Binding}".../>
</GridViewColumn>
<GridViewColumn>
<TextBox ... Tag="{Binding}".../>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)
该ListView具有内子控件的行GridView列.我想更新ListView.SelectedItem任何行中的任何子控件具有键盘焦点时的绑定属性.如果可以在.xaml文件中完全完成而不必诉诸代码,那将是很棒的.
childcontrol ×5
wpf ×3
.net ×1
c# ×1
delphi ×1
effect ×1
firemonkey ×1
listbox ×1
listboxitem ×1
listview ×1
mousedown ×1
mouseover ×1
mvvm ×1
selecteditem ×1
triggers ×1
winforms ×1