我想更改" EstBonClient"的布尔复选框。我的Datagrid中的单元格为特定颜色。如果选中该复选框,则单元格的背景颜色将为绿色,如果未选中该复选框,则单元格的背景颜色将为红色。我希望复选框不在Datagrid中。
谢谢你们!
答案 0 :(得分:0)
的Xaml:
function checkSec(prevSec){
var mat = new THREE.MeshPhongMaterial( { color: 0xff9000 } );
var curTime = new Date();
if (prevSec != curTime.getSeconds() || prevSec == null){
scene.traverse(function(children){
if (children instanceof THREE.Mesh && children.name == 'sec'){
scene.remove(children)
}
});
prevSec = curTime.getSeconds();
prevSec = setZeros(prevSec);
var secGeometry = new THREE.TextGeometry(":" + prevSec, {size:5, height:1});
var sec = new THREE.Mesh( secGeometry, mat);
sec.name = 'sec';
sec.position.set(10,0,0);
scene.add(sec);
}
}
C#: 视图模型:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
xmlns:local="clr-namespace:WpfApplication1"
>
<Window.DataContext>
<local:MyViewModel/>
</Window.DataContext>
<Window.Resources>
<local:BooleanToTextConverter x:Key="booleanToTextConverter" />
<local:BoolToColorConverter x:Key="booleanToColorConverter" />
</Window.Resources>
<Grid>
<StackPanel Background="{Binding Path=IsChecked, Converter={StaticResource booleanToColorConverter}}">
<CheckBox IsChecked="{Binding Path=IsChecked}" Grid.Column="0">Check Me!</CheckBox>
<TextBlock FontSize="30" HorizontalAlignment="Center" Text="{Binding IsChecked, Converter={StaticResource booleanToTextConverter}}" />
</StackPanel>
</Grid>
转换器:
public class MyViewModel : INotifyPropertyChanged
{
bool _isChecked;
public bool IsChecked
{
get { return _isChecked; }
set {
_isChecked = value;
OnPropertyChanged("IsChecked");
}
}
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}