我想在xaml中创建2个单独的窗口,我想从代码部分单独控制它们.你知道怎么做吗?如果您能提供一些代码示例,我将不胜感激.
谢谢你,从现在开始......
我可以在这里获得滑块的值:
public void TheSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
int k = (int)TheSlider.Value;
Debug.WriteLine(k);
}
Run Code Online (Sandbox Code Playgroud)
在这一部分中,我无法获取该值,因此无法使用它:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
_runtime.NuiCamera.ElevationAngle = (int)TheSlider.Value;
}
Run Code Online (Sandbox Code Playgroud)
这是xaml中的滑块代码:
<Slider x:Name="TheSlider"
DockPanel.Dock="Left"
Orientation="Horizontal"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
Minimum="-27"
Maximum="27"
Cursor="Hand"
IsSnapToTickEnabled="True"
Margin="322,392,329,87" ValueChanged="TheSlider_ValueChanged" Width="144" />
Run Code Online (Sandbox Code Playgroud)
这里有什么问题?你能帮我吗?
更新:
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
System.Windows.Data.Binding b = new System.Windows.Data.Binding();
b.ElementName = "TheSlider";
b.Path = new PropertyPath("Value");
SetBinding(ElevationAngleProperty, b);
}
public int ElevationAngle
{
get { return _runtime.NuiCamera.ElevationAngle; }
set { _runtime.NuiCamera.ElevationAngle = value; OnPropertyChanged("ElevationAngle"); } …Run Code Online (Sandbox Code Playgroud)