我试图创建一种情况,ToggleButton任何时候都可以打开两个分组中的一个或两个.我遇到的问题是,如果我更改后备变量的状态,则UI状态不会更新.
我确实已经INotifyPropertyChanged实施了.
我创建了ToggleButton这样的:
<ToggleButton IsChecked="{Binding Path=IsPermanentFailureState, Mode=TwoWay}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
<TextBlock TextWrapping="Wrap"
TextAlignment="Center">Permanent Failure</TextBlock>
</ToggleButton>
<ToggleButton IsChecked="{Binding Path=IsTransitoryFailureState, Mode=TwoWay}"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center">
<TextBlock TextWrapping="Wrap"
TextAlignment="Center">Temporary Failure</TextBlock>
</ToggleButton>
Run Code Online (Sandbox Code Playgroud)
这是我的支持属性(我使用MVVM模式,其他绑定工作,IE点击ToggleButton确实输入这些属性设置.当我通过代码更改状态时,切换按钮不会改变视觉状态.IE I我将backing属性设置为false,但按钮保持选中状态.
public bool? IsPermanentFailureState
{
get { return isPermFailure; }
set
{
if (isPermFailure != value.Value)
{
NotifyPropertyChanged("IsPermanentFailureState");
}
isPermFailure = value.Value;
if (isPermFailure) IsTransitoryFailureState = false;
}
}
public bool? IsTransitoryFailureState
{
get { return isTransitoryFailureState; }
set
{
if (isTransitoryFailureState != value.Value)
{
NotifyPropertyChanged("IsTransitoryFailureState"); …Run Code Online (Sandbox Code Playgroud) 当我点击它时,我想在切换按钮下放置一个弹出窗口。在这个弹出窗口中,我想添加按钮和其他控件。但是,当我调整我的 mian 窗口大小时,如何确保弹出窗口始终位于我的切换按钮下方。
我的 XAML 代码:
<ToggleButton
x:Name="userBtn"
Margin="610,25,378,0"
VerticalAlignment="Top"
Height="29"
Grid.Column="2"
>
<ToggleButton.Resources>
<BitmapImage x:Key="imgNormal" UriSource="/Resources/home.jpg"/>
<BitmapImage x:Key="imgHover" UriSource="/Resources/home_checked.jpg"/>
<BitmapImage x:Key="imgChecked" UriSource="/Resources/home_checked.jpg"/>
</ToggleButton.Resources>
<ToggleButton.Style>
<Style TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton" >
<StackPanel Orientation="Horizontal" VerticalAlignment="Top" Width="150" Height="32">
<Image x:Name="PART_Image" Height="22" Width="22" RenderOptions.BitmapScalingMode="HighQuality" HorizontalAlignment="Center" Margin="0,0,0,0" Source="{StaticResource imgNormal}"/>
<TextBlock x:Name="PART_TEXT" FontFamily="Arial" Foreground="#FFAFADAD" FontSize="13" HorizontalAlignment="Center" Text="{x:Static properties:Resources.BtnDashboard}" Margin="10,9,0,0"></TextBlock>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="PART_Image" Property="Source" Value="{StaticResource imgChecked}"/>
<Setter TargetName="PART_TEXT" Property="Foreground" Value="#79B539" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="PART_Image" Property="Source" Value="{StaticResource imgHover}"/> …Run Code Online (Sandbox Code Playgroud) 我有这个代码
@FXML
private ToggleButton tb1;
@FXML
private ToggleButton tb2;
@FXML
ToggleGroup group = new ToggleGroup();
String cpuLoad1 ="D:/myWorkspace/TestAttacks/input_folder/app_debug.apk";
String cpuLoad2 = "D:/myWorkspace/TestAttacks/input_folder/cpuLoad1.apk";
@FXML
private void onToggleClick(){
tb1.setUserData(cpuLoad1);
tb1.setToggleGroup(group);
tb2.setUserData(cpuLoad2);
tb2.setToggleGroup(group);
ChangeListener<Toggle> cLt = new ChangeListener<Toggle>(){
public void changed(ObservableValue<? extends Toggle> ov,
Toggle toggle, Toggle new_toggle){
if (new_toggle != null){
System.out.println(group.getSelectedToggle().getUserData().toString());
}else{
System.out.println("hello no");
}
}
};
group.selectedToggleProperty().addListener(cLt);
}
Run Code Online (Sandbox Code Playgroud)
尽管我仍然没有使用用户数据,但问题是,每当我单击切换按钮时,我都会按升序获得所需的输出。
这是输出:
hello no //click2
D:/myWorkspace/TestAttacks/input_folder/app_debug.apk //click3
D:/myWorkspace/TestAttacks/input_folder/app_debug.apk
hello no //click4
hello no
hello no
D:/myWorkspace/TestAttacks/input_folder/app_debug.apk //click5
D:/myWorkspace/TestAttacks/input_folder/app_debug.apk
D:/myWorkspace/TestAttacks/input_folder/app_debug.apk
D:/myWorkspace/TestAttacks/input_folder/app_debug.apk
hello no …Run Code Online (Sandbox Code Playgroud) ToggleButton突出于底部边框的背景。
有人可以告诉我我做错了什么吗?
我在SceneBuilder中设置了id ToggleButton。
CSS:
#blue-unselected {
-fx-border-color: #26b4d5;
-fx-border-radius: 4;
-fx-background-color: white;
-fx-background-radius: 4;
-fx-font-size:14;
-fx-text-fill: #26b4d5;
-fx-font-family: "Verdana Pro Cond SemiBold"
}
Run Code Online (Sandbox Code Playgroud) 我是颤振新手,我需要自定义一个切换按钮,如下所示,任何人都可以帮助我吗?我使用堆栈并定位两个按钮重叠,但当它们更改移动显示时,请帮助我关于这一点。图像
我想知道如何只切换一个"子"div,点击一个重复html的按钮,如下所示:
<div class="button">
<div class="hide toggle">
Blah1
</div>
</div>
<div class="button">
<div class="hide toggle">
Blah2
</div>
</div>
<div class="button">
<div class="hide toggle">
Blah3
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
目标是仅影响中级子div,并保持隐藏其余部分.
我不知道是否有可能.
这段代码正在切换我所有的div:
<script type="text/javascript">
$(document).ready(function(){
$('.button').click(function() {
$('.toggle').slideToggle();
}, function () {
$('.toggle').slideToggle();
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
非常感谢您的帮助.
我是WPF中使用样式,资源和模板的新手。我需要做的是将TreeView中的ToggleButton +/-重写为一个图像,每个TreeViewItem根节点都有一个不同的图像。例如,我需要“ Car”节点的汽车图像和“ Plane”节点的飞机图像。我每个都有彩色和灰度图像(用于展开/折叠)。
我发现样式可以覆盖树视图并为切换按钮设置图像,但是我不确定以不同方式设置每个项目的最佳方法。
项目的样式代码很长,因此我敢肯定,有一种比复制/粘贴完整样式来更改source属性更好的方法。
有人可以指出正确的方向,以最好的方式做到这一点吗?
谢谢。
这是我一直在使用的风格,它是从另一篇文章中复制并为我的图像更改的。
<Style x:Key="TreeViewItemFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Width" Value="16"/>
<Setter Property="Height" Value="16"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Width="16" Height="16" Background="Transparent">
<Border Width="16" Height="16" SnapsToDevicePixels="true" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" BorderThickness="1">
<Image x:Name="ExpandImg" Width="16" Height="16" Source="/MyApp;component/Images/Icons/Grayscale/car.ico" />
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Source" TargetName="ExpandImg" Value="/MyApp;component/Images/Icons/Color/car.ico"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TreeViewItemStyle1" TargetType="{x:Type TreeViewItem}"> …Run Code Online (Sandbox Code Playgroud) 我在列表框中有一些切换按钮.当我取消选中切换按钮时,按钮上会运行一个动画,让他不断地从灰色到蓝色"闪烁".
我怎么能阻止这个动画被播放,以便它保持灰色,即使它是聚焦的?
提前致谢
麦克风
我要做的是检查SharedPreferences音量和振动是否为on或off.如果是,ToggleButton应该设置为on,否则,off.
我使用已经尝试过setChecked(),并setSelected()在ToggleButton秒,但它并没有改变TogggleButtonS'的状态.
我也尝试初始化变量true,false只是为了确保但仍然不起作用.
什么似乎是问题?
optionsDB = getSharedPreferences(table, 0);
String volReturned = optionsDB.getString("volume", "Couldn't load data");
String vibReturned = optionsDB.getString("vibration", "Couldn't load data");
Toast.makeText(this, "Vol: "+volReturned+" Vib: "+ vibReturned, Toast.LENGTH_LONG).show();
boolean boolT = true;
boolean boolF = false;
if (volReturned=="On"){
/*tbtnvol.setChecked(true);*/
tbtnvol.setSelected(boolT);
}else{
tbtnvol.setSelected(boolF);
}
if (vibReturned=="On"){
tbtnvib.setSelected(boolT);
}else{
tbtnvib.setSelected(boolF);
}
Run Code Online (Sandbox Code Playgroud) 我创造了这个小提琴,专门用来解决我的问题.我正在ng-repeat某些部分.我有一个在其中实现的切换功能.但是,当我单击按钮时,将触发所有重复项的功能.即使ng-repeat在点击时使用相同的功能名称,也可以正常工作.下面是代码.我想this我可以在这里使用像操作员这样的东西.到目前为止我的代码(我为小提琴而不是原作创建了这个代码),
HTML
<div ng-app="app">
<div ng-controller="CommentController">
<div ng-repeat="list in lists">
<button ng-click="showDiv()" class="review">{{lists[$index]}}</button>
<div ng-show="hiddenDiv">This is the div to be toggled on clicking any of the above button. And they do so as they make use of <i>same function on click.</i>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
调节器
var app = angular.module('app', []);
app.controller('CommentController', function ($scope) {
$scope.hiddenDiv = true;
$scope.showDiv = function () {
$scope.hiddenDiv = !$scope.hiddenDiv;
};
$scope.lists = ["one", "two", "three", …Run Code Online (Sandbox Code Playgroud)