我想在我的WPF应用程序中有一个按钮来重启机器.此应用程序始终在Vista上运行.
一个快速搜索没有提高任何东西的事实让我觉得这可能比我希望的更难......任何想法?谢谢!
与我之前的问题相关:在Silverlight中绑定ComboBox.SelectedItem
我有一个像这样绑定的ComboBox:
<ComboBox x:Name="PART_CommentaryList"
HorizontalAlignment="Left"
Margin="3"
ItemsSource="{Binding Path=CurrentVideo.Commentaries}"
SelectedItem="{Binding Path=CurrentCommentary, Mode=TwoWay}">
Run Code Online (Sandbox Code Playgroud)
CurrentVideo和CurrentCommentary属性都会定期更改.几次后,我收到此错误:
Category: ManagedRuntimeError
Message: System.ArgumentException: Value does not fall within the expected
range.
at MS.Internal.XcpImports.MethodEx(IntPtr ptr, String name,
CValue[] cvData)
at MS.Internal.XcpImports.MethodPack(IntPtr objectPtr, String methodName,
Object[] rawData)
at MS.Internal.XcpImports.UIElement_TransformToVisual(UIElement element,
UIElement visual)
at System.Windows.UIElement.TransformToVisual(UIElement visual)
at System.Windows.Controls.Primitives.Selector.IsOnCurrentPage(
Int32 index, Rect& itemsHostRect, Rect& listBoxItemRect)
at System.Windows.Controls.Primitives.Selector.ScrollIntoView(
Int32 index)
at System.Windows.Controls.Primitives.Selector.SetFocusedItem(
Int32 index, Boolean scrollIntoView)
at System.Windows.Controls.ComboBox.PrepareContainerForItemOverride(
DependencyObject element, Object item)
at System.Windows.Controls.ItemsControl.UpdateContainerForItem(
Int32 index)
at System.Windows.Controls.ItemsControl.RecreateVisualChildren()
at System.Windows.Controls.ItemsControl.RecreateVisualChildren(
IntPtr …Run Code Online (Sandbox Code Playgroud) 这个让我发疯.这是XAML:
<UserControl x:Class="SilverlightApplication1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
<ComboBox ItemsSource="{Binding Path=Thing.Stuff}"
SelectedItem="{Binding Path=Thing.SelectedStuff}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Button Content="Again" Click="Button_Click" />
</StackPanel>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
而代码隐藏:
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
namespace SilverlightApplication1
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
Data data = new Data();
data.Thing = new Thing();
data.Thing.Stuff = new ObservableCollection<Stuff>();
data.Thing.Stuff.Add( new Stuff { Name = "Stuff 1" } ); …Run Code Online (Sandbox Code Playgroud) I might be getting the terminology wrong here, but I think I'm trying to create an attached event.
In the Surface SDK, you can do things like:
<Grid Background="{StaticResource WindowBackground}" x:Name="Foo" s:SurfaceFrameworkElement.ContactChanged="Foo_ContactChanged"/>
Run Code Online (Sandbox Code Playgroud)
I want to create a custom event for which a handler can be added in XAML in the same way, but I'm having trouble.
I can create a custom routed event, but the XAML intellisense doesn't see it and the event handler isn't added if I just type …
我期待做三件事:
从麦克风访问数据.我真想知道的是设备所感知的声音的整体音量.
设置麦克风增益.
设置系统音量.
我所有的windows开发经验都是C#/ WPF,所以我想保持管理.我不需要特别高性能或实时处理或任何东西.
我环顾四周,似乎SlimDX可能是一个很好的包装,但即使在那里,我也不知道从哪里开始.
当然不是那么难吗?
关于这个问题已经有很多问题,并且已经提出了许多答案,但没有任何问题对我有用.
有一次,我使用以下指令启用了WPF项目的.NET符号加载:http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net -framework -源code.aspx
工作得很好,一切都很酷.
除了在Silverlight项目中,它还会尝试从该服务器加载符号,但它们不存在,因此调试项目的启动时间非常长.
所以,我关闭了符号加载,它确实停止尝试加载所有符号,除了一个名称空间:System.Windows.Browser.VS仍然试图加载每个F5,花几秒钟让我发疯.
我试图添加这里提到的符号服务器:http://blogs.msdn.com/seema/archive/2008/10/08/xperf-a-cpu-sampler-for-silverlight.aspx
想到可能符号在那里,他们会被加载和缓存,一切都会很好.但不,不仅它们不会被加载,而且VS试图为我项目中的每个其他DLL加载符号,包括那些从未有过符号的符号,这使得启动时间更长.
坦率地说,我甚至不需要调试这些DLL的源代码,我只是觉得它很酷.现在我无法将其关闭,这让我感到沮丧.有什么问题?
这是一个3d n00b问题.
我正在研究一个WPF控件,它实现了Silverlight的PerspectiveTransform功能的基础,允许2D平面在三个轴中的任何一个上旋转.它工作得很好.然而,我有点困在确定飞机后部是否显示所需的数学上.我现在想出的天真代码是:
bool isBackShowing = Math.Abs(RotationX) > 90 && Math.Abs(RotationY) < 90;
if (!isBackShowing)
{
isBackShowing = Math.Abs(RotationX) < 90 && Math.Abs(RotationY) > 90;
}
Run Code Online (Sandbox Code Playgroud)
但是,当任一轴上的旋转在+ -270和+ -360之间时,这会失败.
底层变换使用Quaternion对象进行实际旋转,并且具有良好的Axis和Angle属性,所以我猜我可以使用它,如果我知道如何.
.net ×2
c# ×2
combobox ×2
data-binding ×2
selecteditem ×2
silverlight ×2
wpf ×2
3d ×1
audio ×1
debugging ×1
events ×1
microphone ×1
quaternions ×1
reboot ×1
symbols ×1
windows ×1