我正在使用Microsoft Visual C#2008 Express.
在我的主要表单中,有一个X按钮可以关闭右上角的表单.如何向此按钮添加代码?在我的菜单中,我有一个"退出"项,它有清理和关闭我的数据库的代码.如果用户选择相同的代码作为退出方式,如何将相同的代码添加到此按钮?
谢谢!
-Adeena
我有一个按钮样式:
<Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Path x:Name="path1" ... Data="...some data...">
<Path.Fill>
<LinearGradientBrush EndPoint="0.5,-0.3" StartPoint="0.5,0.8">
<GradientStop x:Name="gs1" Color="Green" Offset="0.44"/>
<GradientStop Color="Black" Offset="0.727"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
<ContentPresenter ...properties... />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="???" Property="Color" Value="Green"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Run Code Online (Sandbox Code Playgroud)
当鼠标悬停在按钮上时,我想用x:Name ="gs1"更改GradientStop的颜色,所以我使用Trigger IsMouseOver.如何在Trigger中访问Color Property?我尝试了TargetName ="gs1"和TargetName ="path1.gs1",但它不起作用.任何的想法?
我有一个QPushButton,我有一个文本和图标.我想让按钮上的文字变为粗体和红色.看着其他论坛,谷歌搜索,失去了我的希望.如果按钮有一个图标,那么似乎没有办法做到这一点(当然,如果你没有创建一个新的图标,那就是文字+前图标).这是唯一的方法吗?谁有更好的主意?
我在客户端使用json + jquery.我想在上传文件时禁用页面上的所有按钮.目前我只使用其ID来禁用上传按钮,如下所示.
Run Code Online (Sandbox Code Playgroud)$("#upload_attachment_button").addClass('ui-state-disabled');
我想知道是否有办法禁用页面上的其他按钮.我已经完成了一个我想要被所有系统使用的功能,而且每次我想调用这个函数时我都不想发送按钮id.
谢谢.
我有一个带有动态管理的arrayadapter的微调器.当它显示时,微调文本也会显示单选按钮.我怎么摆脱这个单选按钮?下拉箭头都是拉伸和令人讨厌的...这就是我的问题.注意:我不是在谈论在我选择微调器上的下拉列表时显示的列表中的单选按钮.
这里是相应的代码片段......几点:
问:我错过了什么?在我看来,我错过了Spinner的一些属性,导致单选按钮也显示在微调器的文本部分.
- 剪辑代码 -
public class ChoiceGroupImpl extends Spinner implements OnItemSelectedListener {
public ChoiceGroupImpl(Activity activity, WidgetContainer container, Value widget, AttributeImpl attributes, Object[] value, int selected) {
...
adapter = new ArrayAdapter<CharSequence>(activity, R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
for (int i = 0; i < value.length; i++)
adapter.add(value[i].toString());
if (attributes.isReadonly())
setEnabled(false);
setAdapter(adapter);
setSelection(selected);
setPrompt(adapter.getItem(selected));
setOnItemSelectedListener(this);
...
}
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
setPrompt(adapter.getItem(position));
((ToolkitImpl) Toolkit.getInstance()).hiddenCommand(container, "SelectionChanged");
}
...
Run Code Online (Sandbox Code Playgroud)
- 结束剪辑代码 -
我有一个快速的谷歌,并快速浏览StackOverflow,但找不到其他任何人遇到这个问题.
我想创建一个带有小X的关闭按钮.当你将鼠标悬停在包含它的项目上时,关闭按钮会执行淡入和淡出等操作,当鼠标悬停时更改颜色,以及所有常用的WPF可爱.最重要的是,它看起来似乎不应该那么困难,但是我已经遇到了在我进入这个阶段之前的一个最奇怪的问题.
这是按钮的XAML样式:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="TabCloseButtonStyle" TargetType="{x:Type Button}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Content">
<Setter.Value>
<Grid>
<Line Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
X1="0"
Y1="0"
X2="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualWidth, Mode=OneWay}"
Y2="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualHeight, Mode=OneWay}"/>
<Line Stroke="{Binding RelativeSource={RelativeSource AncestorType=Button}, Path=Foreground}"
X1="0"
Y1="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualHeight, Mode=OneWay}"
X2="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=ActualWidth, Mode=OneWay}"
Y2="0"/>
</Grid>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
我创建我的按钮,就像测试一样,如下所示:
<Window x:Class="WpfTestApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="124" Width="569">
<Grid Background="#2b3c59">
<StackPanel Orientation="Horizontal">
<!-- Other controls removed for clarity --> …Run Code Online (Sandbox Code Playgroud) 在Android上,我想创建一个包含其他一些视图的按钮.例如,像这样:
+---------------------------+
| Hello world! +-------+ |
| | image | |
| Some more info +-------+ |
+---------------------------+
Run Code Online (Sandbox Code Playgroud)
但我希望它比这个具体的例子更灵活.理想情况下,按钮只能包含一个ViewGroup,这样我就可以在一个单独的XML文件中实现它的布局.但是,因为Button扩展了View,而不是ViewGroup,所以这似乎不可能.
有没有办法使用标准的Android组件实现这一点,还是我不得不求助于编写自定义按钮类?
根据要求,一些示例XML可以解决这个问题:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:focusable="true"
android:clickable="true"
android:background="@android:drawable/btn_default">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/primary_text_light"/>
<TextView
android:id="@+id/additional_line_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/primary_text_light"/>
<TextView
android:id="@+id/additional_line_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/primary_text_light"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我必须明确地在TextViews上设置颜色,否则它们几乎不可读(默认情况下它们是白色的).我从SDK中挖出了标识符:.../platforms/android-7/data/res/values/public.xml.奇怪的是,primary_text_light给出了黑色文本,而primary_text_dark结果是白色......
如何隐藏JW Player中视频屏幕中心的播放按钮?
我正在使用播放器的5.4版,我使用他们自己的'JW Embedder'技术嵌入它.
我试过以下没有运气:
jwplayer("myPlayer").setup({
file: 'myMediaFile.mp4',
image: 'myPosterFile.jpg',
controlbar: 'bottom',
icons: false
});
Run Code Online (Sandbox Code Playgroud)
我已经在某个地方读到了这个版本5.0可能已被删除,现在必须用皮肤完成.但是,我也读到它在5.1版本中返回了......?
我有一个WPF应用程序,其中有一个列表框中填充了"匹配"类型的项目.如何使按钮(包含在项目中)实际选择项目以便我可以提取值?
这是我的代码:既不起作用,因为单击按钮实际上并不选择该项目
private void LayButton_Click(object sender, RoutedEventArgs e)
{
var x = (Market)ListBoxSelectedMarket.SelectedItem;
var y = (sender as ListBoxItem);
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我最近注意到样式<a>和<button>标签的问题出现在显示块或内联块,一定量的填充,以及位置相对于调整位置时:活动例如
a { display: inline-block; padding: 3px 6px; background: #aff; }
a:active { position: relative; top: 1px; left: 1px; }
Run Code Online (Sandbox Code Playgroud)
问题是文本周围有一个1像素的不可见框,其中点击没有被浏览器或JavaScript注册,但动画仍然会出现.这种情况发生在(至少)Windows上的Firefox和Chrome中.
这是一个有效的例子:http: //dl.dropbox.com/u/1186571/Test.htm
我也试过使用边距而不是position: relative;尝试.active使用javascript 设置而不是使用:active.
为了清楚起见:我正在谈论链接中的死区(在我的示例中为蓝色框),但在文本的边界框之外.这是我正在谈论的区域用深蓝色突出显示的图像: