私はwpfアプリケーションで作業しており、XAMLでチェックボックスを作成しました。次に、コードがクラスの関数を呼び出します。この関数には、チェックボックスがオンになっているかどうかをチェックするが、チェックボックスが表示されないif条件があります。このクラスでは、これを行う方法は?
どうもありがとう
編集:
私が行った手順は次のとおりです。次のように、KinectSkeletonの同じプロジェクトでViewModelクラスを作成しました。ViewModelクラス:
public class ViewModel
{
public bool IsChecked { get; set; }
public bool is_clicked { get; set; }
}
KinectSkeletonで、次のようにプロパティを定義しました。
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModelH", typeof(ViewModel), typeof(KinectSkeleton), new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.AffectsRender));
public ViewModel ViewModelH
{
get => (ViewModel)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
KinectWindow.xamlのチェックボックスとボタンのコードは次のとおりです。
<Button Content="Calibrate" Height="24" x:Name="Calibrate" x:FieldModifier="public" Width="90" Click="Calibrate_Click" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" DockPanel.Dock="Left" Panel.ZIndex="0" Padding="0" VerticalAlignment="Center" />
<CheckBox IsChecked="{Binding Mode=TwoWay, Path=IsChecked}" Content="AngleDifference" Height="22" x:Name="AngleDifference" x:FieldModifier="public" Width="117" Checked="AngleDifference_Checked" Unchecked="AngleDifference_Unchecked" HorizontalAlignment="Left" VerticalAlignment="Center" Panel.ZIndex="1" HorizontalContentAlignment="Left" />
そして、私が書いたチェックボックスの値をチェックしたいKinectSkeletonで:
if (this.ViewModelH.IsChecked == false)
// if(f.is_chekced == false)
{
// do something
}
チェックボックスのis_checkedイベントとボタンのis_clickedに何を書き込むか知りたいですか?また、これまでKinectスケルトンプロパティがチェックボックスis_checked値にバインドされていないと感じているので、上記の手順に欠けているものはありますか?