我在aspx页面中注册了一个用户控件在用户控件中单击按钮事件时,如何调用父页面代码隐藏中的方法?
谢谢.
下拉框和组合框[HTML]之间有什么区别吗?
实际上重点是,每次我说的话都是这样的:" 组合框有一些问题 ",我的大四学生说:" 这不是一个下拉的组合框 ",:)
我在自定义控件中有一个组合框.如何向实现我的自定义控件的任何人/事物公开其中的特定事件,例如SelectedIndexChanged或KeyPress等?
我有一个UserControl包含一个TextBox.当我的主窗口加载时,我想将焦点设置到此文本框,所以我添加Focusable="True" GotFocus="UC_GotFocus"到UserControls定义和FocusManager.FocusedElement="{Binding ElementName=login}"我的主窗口定义.在UC_GotFocus方法中,我只是调用.Focus()我想要关注的控件,但这不起作用.
我需要做的就是在应用程序启动时有TextBox一个UserControl接收焦点.
任何帮助将不胜感激,谢谢.
以下错误是什么?
模糊类型参考.名为"VisualState"的类型出现在至少两个名称空间中,即"System.Windows"和"System.Windows".考虑调整程序集XmlnsDefinition属性.
用户控件:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="ButtonWPF.MyButtonAdd"
x:Name="AddButton"
d:DesignWidth="84" d:DesignHeight="87">
<UserControl.Resources>
<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid x:Name="grid" RenderTransformOrigin="0.5,0.5">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
.............
<Trigger Property="IsDefaulted" Value="True"/>
<Trigger Property="IsMouseOver" Value="True"/>
<Trigger Property="IsPressed" Value="True"/>
<Trigger Property="IsEnabled" Value="False"/>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot"
Height="79"
Width="72">
<Button Content=""
HorizontalAlignment="Left"
Height="61"
Style="{DynamicResource ButtonStyle1}"
VerticalAlignment="Top"
Width="57"/>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
主窗口:
<Window x:Class="ButtonWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
xmlns:my="clr-namespace:ButtonWPF"
Title="winGroup"
Height="637"
Width="638"
FontSize="15"
FontWeight="Bold">
<Grid>
<my:MyButtonAdd HorizontalAlignment="Left"
Margin="540,519,0,0"
x:Name="btnAdd" …Run Code Online (Sandbox Code Playgroud) 如何以编程方式创建基于UserControl的元素并将其停靠到DockPanel?
我最好通过例子问这个问题.假设我有UserControl和Window使用此控件.
我想以这种方式设计这个控件(名为MyControl)(这是科幻语法!):
<Grid>
<Button>Just a button</Button>
<PlaceHolder Name="place_holder/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
在设计我的Window时以这种方式使用:
<MyControl/>
Run Code Online (Sandbox Code Playgroud)
要么
<MyControl>
<place_holder>
<Button>Button 1</Button>
</place_holder>
</MyControl>
Run Code Online (Sandbox Code Playgroud)
要么
<MyControl>
<place_holder>
<Button>Button 1</Button>
<Button>Button 2</Button>
</place_holder>
</MyControl>
Run Code Online (Sandbox Code Playgroud)
当然我希望能够在Window中为MyControl添加更多元素.因此,在某种程度上它应该作为容器(如Grid,StackPanel等)工作.该位置将在UserControl中定义(在此示例中,在按钮"只是一个按钮"之后)但是要添加的内容(哪些元素)将在Window中定义(使用UserControl - MyControl).
我希望这很清楚我想要实现的目标.关键点是在设计Window时使用XAML,因此我的类应该不比其他控件差.
现在,最大的问题是 - 如何做到这一点?
备注:样式超出范围.我想要做的就是在设计Window时添加我想要的任何控件MyControl(而不是在设计MyControl时).
要在WPF中实现基于选项卡的环境,我们需要将表单转换为用户控件,但是在执行此操作时,将Loaded调用用户控件的事件两次.
在互联网上搜索时,其他人也指出了这个问题.我们怎样才能确保只调用一次加载的事件?因为当它被多次调用时,我们的控件的初始化会多次发生.
我有一个页面,其中包含更新面板中的用户控件.$(document).ready(function() ) {是所谓的正确执行代码时的页面加载首创,但如果用户点击一个按钮(用户控制范围内),将document.ready()不会被调用(document.load,onload也不工作)
我在网上研究了这个,发现了类似的问题,但没有什么可以解释为什么这不起作用.还有什么其他原因可以document.ready不起作用?
我创建了一个带有TextBox和两个按钮的用户控件,但我还没有创建事件,只是将它们放到用户控件中.当我想将用户控件添加到我的表单时,它说:
无法移动Task_control.cs.目标文件夹与源文件夹相同.
我不明白为什么.
user-controls ×10
c# ×5
wpf ×5
asp.net ×2
winforms ×2
combobox ×1
containers ×1
dockpanel ×1
focus ×1
focusmanager ×1
html ×1
javascript ×1
jquery ×1
placeholder ×1