这是我的代码片段
public class Notation : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private Notes _note;
}
Run Code Online (Sandbox Code Playgroud)
如何正确编写 public event PropertyChangedEventHandler PropertyChanged; UML类图?
首先,我认为是:
+ PropertyChanged:PropertyChangedEventHandler
但后来,我意识到它并不代表event代码的一部分.
任何的想法?谢谢
任何人如何在我自己的WPF应用程序中使用Visual Studio 11 Dark Theme?我指的是控件的颜色和设计.(我也使用VS 11编写代码)
Visual Studio团队自己说:
作为Visual Studio 11整体发布计划的一部分,我们将以多种文件格式(包括vector)为您提供此版本的所有图标.您可以在自己的应用程序中充分利用这些资产的简单主题功能和调整大小的能力.
来源:http://blogs.msdn.com/b/visualstudio/archive/2012/05/29/visual-studio-dark-theme.aspx(主题图标部分的最后一段)
好吧,所以,这个问题似乎很简单,但不知怎的,我无法弄明白,反正我会问它...
我想用Visibility在这样CommandParameter的KeyBinding(支付注意<!--THIS LINE-->部分):
<Window ...
xmlns:sys="clr-namespace:System;assembly=System"
...>
...
<Window.InputBindings>
</Window.InputBindings>
<Grid DataContext="{StaticResource MainWindowVM}">
...
<ScrollViewer Grid.Column="0" Grid.Row="1" Background="Gray">
<ScrollViewer.InputBindings>
...
<!--THIS LINE--><KeyBinding Key="OemOpenBrackets" Command="{Binding EditLeftBarLineVisibilityCommand}" CommandParameter="{x:Static sys:Visibility.Visible}"/>
<!--THIS LINE--><KeyBinding Key="OemCloseBrackets" Command="{Binding EditRightBarLineVisibilityCommand}" CommandParameter="{x:Static sys:Visibility.Visible}"/>
</ScrollViewer.InputBindings>
...
</ScrollViewer>
</Grid>
Run Code Online (Sandbox Code Playgroud)
但是,似乎:
名称"Visibility"在名称空间"clr-namespace:System; assembly = System"中不存在
我Visibility在我的VM中寻找并且它位于System.Windows,但我在XAML上找不到,上面(System)是我发现的最接近的一个,结果并不好.
任何人都知道在XAML中使用什么命名空间?(虽然System.Windows在XAML中没有列出,如果结果我没有引用它,我的VM也不能正确使用它?)
或者,是否有必要ObjectDataProvider仅用于System Enum?(因为ObjectDataProvider如果它是我自己的自定义枚举,我可以无缝地执行此操作)
PS MSDN:http://msdn.microsoft.com/en-us/library/system.windows.uielement.visibility%28v=vs.95%29.aspx
我想加载图像并将其放入视图框中。图像显示正确,但是,当我要获取它的宽度和高度时,它都是 NaN。
这是我的图像加载代码:
Image img = new Image();
img.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("1.png");
Viewbox vb = new Viewbox();
vb.Width = img.Width;
vb.Height = img.Height;
vb.Child = img;
cnv.Children.Add(vb);
Run Code Online (Sandbox Code Playgroud)
我想要获取图像宽度和高度的原因是这样我可以稍后在应用程序内调整它的大小(通过视图框调整大小)。
知道如何获取图像尺寸吗?
这就是我要调整它的大小的方法(通过鼠标滚轮)
private void cnv_MouseWheel(object sender, MouseWheelEventArgs e)
{
if (vb != null)
{
vb.Width += Mouse.MouseWheelDeltaForOneLine;
vb.Height += Mouse.MouseWheelDeltaForOneLine;
}
}
Run Code Online (Sandbox Code Playgroud)
它返回错误并表示 vb.Width 不是有效值。
总结一下问题:
谢谢
PS Viewbox vb;,Image img;是一个全局变量,我只是缩短了脚本。PSS 我知道 Viewbox 的宽度和高度是否由数字初始化,比如说 100 和 100,它会起作用,我只是想知道如何获取图像的原始大小。
编辑:调整大小可以通过检测是否向上或向下滚动来实现e.Delta > 0(e.Delta …
我不太确定如何授权它,但是,我说我Rectangle的中心有3个红色Canvas.
如果我点击a Rectangle,颜色变为蓝色,如果我点击Canvas但不是Rectangle,则每个蓝色Rectangle开关颜色变回红色.
我的问题是这样的:如果我做了2个MouseLeftButtonDown事件,每个用于Rectangle-s而另一个用于Canvas,那么如果我点击它Rectangle,Canvas_MouseLeftButtonDown事件也会在Rectangle一个之后触发.
问题:Canvas_MouseLeftButtonDown如果有一个也单击的子控件,如何防止(父控件)事件被触发.
谢谢.
更新+代码:
这是Rectangle事件:
private void rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//Change clicked rectangle color to blue
}
Run Code Online (Sandbox Code Playgroud)
这是Canvas事件:
private void canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
//Change all Child rectangle color back to red
}
Run Code Online (Sandbox Code Playgroud)
我想要的一句话:如果"矩形"事件触发,则禁止"画布"事件触发.
由于方法内代码与问题不太相关,因此我将其删除以使其看起来更简单.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace NumberedMusicScores
{
public enum KeySignatures
{
C,
G,
D,
A,
E,
B,
FCress,
CCress,
F,
Bb,
Eb,
Ab,
Db,
Gb,
Cb
}
}
Run Code Online (Sandbox Code Playgroud)
如果我使用它,我希望FCress并CCress显示为F#和C#.怎么做到这一点?
我试过这个:怎么用?字符枚举,但Description在[Description("F#")]似乎不存在.(用红线加下划线,如果我右键单击它,它甚至不会显示任何"Resolve".
更新:澄清:
enum,而是一个配置为的类enum.我想要enum解决方案.谢谢.
Firebase Cloud函数提供了一个名为的错误.
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
Run Code Online (Sandbox Code Playgroud)
当我尝试重新部署时,它会出现以下错误.
Error setting up the execution environment for your function. Please try again after a few minutes.
Run Code Online (Sandbox Code Playgroud)
可能是什么原因?它是否跟随问题?Sates:https://status.firebase.google.com/incident/Functions/18018
我似乎找不到下面某些键的键枚举。我也通读了这个:http : //msdn.microsoft.com/en-us/library/system.windows.forms.keys.aspx,但仍然没有找到(或者我可能错过了)

问题 :
Oemtilde在给定链路,任何想法的关键是什么?谢谢你。
(我的编程语言是 C#,我用 WPF 编码)
首先,我想说,在对 2 个不同的线程(如下所示)进行了几次研究之后,我决定发布这个问题,因为它完全不同。
因此,我想将ItemsControl视图中的an 绑定到一个属性以获取集合的反向版本。
我有这个观点(为了清晰起见进行了修剪):
<UserControl x:Class="NumberedMusicalScoresWriter.V.NotationGroupV" ...>
...
<Grid>
<ItemsControl ...
ItemsSource="{Binding ReversedNotationVMs, Mode=OneWay}">
...
</ItemsControl>
</Grid>
...
</UserControl>
Run Code Online (Sandbox Code Playgroud)
而且,我有这个视图模型(为了清晰起见进行了修剪):
public class NotationGroupVM : ...
{
...
public ObservableCollection<NotationVM> ReversedNotationVMs
{
get { return (ObservableCollection<NotationVM>)NotationVMs.Reverse(); //ERROR!! }
}
public ObservableCollection<NotationVM> NotationVMs
{
get { return _notationVMs; }
set { _notationVMs = value; NotifyPropertyChanged("NotationVMs"); NotifyPropertyChanged("ReversedNotationVMs"); }
}
}
Run Code Online (Sandbox Code Playgroud)
但是有这个错误(请参阅上面的错误注释以发现有问题的行):
无法转换类型为“d__a0
1[NumberedMusicalScoresWriter.VM.NotationVM]' to type 'System.Collections.ObjectModel.ObservableCollection1[NumberedMusicalScoresWriter.VM.NotationVM]”的对象。
我还尝试.ToList<NotationVM>()在倒车之前申请,并在每次主字段更新时创建一个新集合。但他们没有成功。
我还需要保持反转与未反转的同步。不只是一次还原
我也在这里和这里阅读了一个关于它的问题,但它们都只提供了 xaml 解决方案,或者我不理解它们。我需要一台虚拟机。
谢谢。
所以,我有 3 个用户控件:
1.第五节.xaml
<UserControl x:Class="NumberedMusicalScoresWriter.V.SectionV"...>
...
<Grid Background="{Binding BackgroundColor, Mode=OneWay}" Grid.IsSharedSizeScope="True">
...
<V:BarV Grid.Column="0" Grid.Row="0" DataContext="{Binding GClefBarVM, Mode=OneWay}"/>
<V:BarV Grid.Column="0" Grid.Row="2" DataContext="{Binding FClefBarVM, Mode=OneWay}"/>
</Grid>
...
Run Code Online (Sandbox Code Playgroud)
2.BarV.xaml
<UserControl x:Class="NumberedMusicalScoresWriter.V.BarV"...>
...
<Grid Background="{Binding BackgroundColor, Mode=OneWay}">
...
<ItemsControl Grid.Column="0" Grid.Row="0"
ItemsSource="{Binding NotationGroupVMs, Mode=OneWay}">
...
<ItemsControl.ItemTemplate>
<DataTemplate>
<V:NotationGroupV/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
...
Run Code Online (Sandbox Code Playgroud)
3.NotationGroupV.xaml
<UserControl x:Class="NumberedMusicalScoresWriter.V.NotationGroupV"...>
...
<Grid Background="{Binding BackgroundColor, Mode=OneWay}">
...
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" SharedSizeGroup="Mid"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
...
</Grid>
...
Run Code Online (Sandbox Code Playgroud)
正如您所想到的,是inNotationGroupV的集合,并且由 2拥有。(也用作其父控件的集合成员) …