我一直在寻找一种方法,将数字存储为对象的属性,并将其位模式显示为 Windows Presentation Foundation 中的一系列复选框。这是我现在使用的方法,当选中复选框时数值更新,当数字更改时复选框更新。请告诉我是否可以通过更简单的方式实现这一点。
MainWindow.xaml.cs
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Media;
using System.Windows;
using System.Windows.Controls;
namespace WPF_Interface_Tests
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public BitField BF { get; set; }
public MainWindow()
{
InitializeComponent();
DataContext = this;
BF = new BitField(0, 32);
}
private void Plus_Click(object sender, RoutedEventArgs e)
{
if (BF.Value < uint.MaxValue)
BF.Value += 1;
}
private void Minus_Click(object sender, RoutedEventArgs e)
{
if (BF.Value > …Run Code Online (Sandbox Code Playgroud) double test3 = 1/7;
NSLog(@"The value of test3 = %1.6f",test3);
Run Code Online (Sandbox Code Playgroud)
结果:
The value of test3 = 0.000000
为什么它不会给我一个浮动值的分数?它应该说:
The value of test3 = 0.142857
我究竟做错了什么?