小编God*_*ene的帖子

前缀(++ x)和后缀(x ++)操作如何工作?

有人能告诉我前缀/后缀运算符是如何工作的吗?我一直在网上看很多但没找到任何东西.

从我可以告诉prefex第一个增量,然后执行操作,然后分配.
Postfix将首先执行操作,然后分配然后递增.

但是我的代码遇到了一些麻烦:

int x, y;
x = 1;
y = x + x++; // (After operation y = 2)(x=2)
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时:

y = x++ + x; // (After operation y = 3)(x=2)
Run Code Online (Sandbox Code Playgroud)

我不确定为什么这些操作会有所不同.我有两个问题:

  • 你能解释一下这个区别吗?

  • 这如何适用于其他运营商Prefix?

c c# c++ sequence-points

26
推荐指数
4
解决办法
2万
查看次数

Windows 8 Windows应用中的中继命令

是否有版本的RelayCommand,因为在win8 metro应用程序中没有CommandManager?

c# xaml mvvm windows-8

7
推荐指数
1
解决办法
5085
查看次数

从链表中删除C#

我正在尝试删除一个节点,如果x当前与我的链表中的int匹配.

我试过这个,但是一旦它删除了节点,它就会在检查foreach循环时抛出一个错误

public void DeleteNode(int x, LinkedList<name> myLinkedList) {
    foreach (name item in myLinkedList) {
         if (item.num.equals(x)) mylinkedList.Remove(x);
    }
}
Run Code Online (Sandbox Code Playgroud)

希望有道理.

c#

6
推荐指数
1
解决办法
1万
查看次数

使用扩展面板平等地伸展所有孩子

我想做的是创建一个带有 4 个按钮的停靠面板,并使按钮大小相等。

但是,当我现在这样做时,它会格式化前 3 个按钮以填充按钮的内容,最后一个按钮填充剩余空间。

有没有办法让我可以在控件中放入 4 个按钮并使它们大小相等。我已经看到了 StackPanel 的问题,通过阅读,我认为 Dockpanel 可以为我解决这个问题。

我知道我可以使用设置网格来解决这个问题,但我试图找到另一个解决方案。

xaml

4
推荐指数
1
解决办法
1141
查看次数

创建treeview绑定wpf

我一直试图制作看起来像的树视图

2001(root)
-Student1(node)
-Student2(node)

我曾尝试使用hierarchicaldatatemplates但我仍然没有抓住我需要的东西.这是我的代码,我正在寻找绑定我的树视图.任何有关Xaml的帮助都会受到关注.

我觉得它看起来像

    <TreeView ItemsSource="{Binding CurrentClass}">
        <TreeView.Resources>
            <HierarchicalDataTemplate DataType="{x:Type local:Student}" ItemsSource="{Binding CurrentClass.Students}">
                    <TextBlock Text="{Binding CurrentClass.Students/FirstName}" />
                </HierarchicalDataTemplate>
        </TreeView.Resources>
    </TreeView>
Run Code Online (Sandbox Code Playgroud)
public class ViewModel
{
    public FreshmenClass currentClass = new FreshmenClass();

    public ViewModel()
    {
        currentClass.Year = "2001";
        currentClass.Students.Add(new Student("Student1", "LastName1"));
        currentClass.Students.Add(new Student("Student2", "LastName2"));
    }

    public FreshmenClass CurrentClass
    {
        get { return currentClass; }
    }
}

public class FreshmenClass
{
    public string Year { get; set; }
    public List<Student> students = new List<Student>();

    public List<Student> Students
    {
        get { return …
Run Code Online (Sandbox Code Playgroud)

c# wpf xaml

2
推荐指数
1
解决办法
5100
查看次数

模型更改更新View-Model WPF

我有一个问题,我的模型更改更新回到我的viewmodel所以我可以显示.在这个例子中我有一个标签和一个按钮,当我按下按钮它将执行一些业务逻辑,并应更新屏幕上的标签.但是,当我的模型更改时,视图不会.我在这里做错了什么想法?

视图-

<Window.DataContext>
    <vm:ViewModel>
</Window.DataContext>
<Grid>
    <Label Content="{Binding Path=Name}"/>
    <Button Command={Binding UpdateBtnPressed}/>
</Grid>
Run Code Online (Sandbox Code Playgroud)

视图模型

public ViewModel()
{
    _Model = new Model();
}

public string Name
{
    get{return _Model.Name;}
    set
    {
        _Model.Name = value;
        OnPropertyChanged("Name");
    }
}

public ICommand UpdateBtnPressed
{
get{
_UpdateBtn = new RelayCommand(param => UpdateLabelValue());
return _UpdateBtn;
}

private void UpdateLabelValue()
{
    _Model.Name = "Value Updated";
}
Run Code Online (Sandbox Code Playgroud)

模型

private string name = "unmodified string";

public string Name
{
    get{return name;}
    set{name = value;}
}
Run Code Online (Sandbox Code Playgroud)

c# wpf mvvm

1
推荐指数
1
解决办法
3056
查看次数

JQuery发现可以在IE中使用,但不能在Firefox中使用

我试图使用jQuery中的find从xml字符串中提取值.它适用于IE,但不适用于Firefox.

我有下面的小提琴:

var xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<Template xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><templateId>90</templateId><CalendarColumn>MEASUREMENT_DATE</CalendarColumn><UOMColumn>undefined</UOMColumn><Type>dial</Type></Template>";

var catalogName = $(xmlString).find('CalendarColumn').text();

alert(catalogName);
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/zJCfy/

如果我在IE中运行它将正常工作,显示calendarColumn文本.如果我在Firefox中运行同样的小提琴,我会得到""返回.

JQuery不应该这样做.这是浏览器设置问题吗?

jquery

1
推荐指数
1
解决办法
297
查看次数

在C#中使用LinkedList <>

我希望使用C#链接列表类而不是创建我自己的,但我不知道如何粘贴多个项目LinkedList<>.

我想做点什么LinkedList<string, List>,让我有:

entry1->string

还有一个清单:

entry2->string, and list

我从教程中看到的所有内容都只允许LinkedList,

关于如何在链表中获得超过1个值的任何想法?谢谢.

c#

0
推荐指数
1
解决办法
778
查看次数

从列表中删除项目时的双向绑定

从列表数据结构中删除/添加项目时,如何设置双向绑定?
目前我的列表框中的每个项目都显示字符串值,如果我更新这些值中的任何一个,我通过propertyChanged notify设置了双向绑定.虽然如果我从列表中完全删除该项目,我该如何更新列表?

这是我想更新

Students.CompSciList.RemoveAt(listBox.SelectedIndex)的行.

c# wpf xaml

0
推荐指数
1
解决办法
64
查看次数

标签 统计

c# ×7

xaml ×4

wpf ×3

mvvm ×2

c ×1

c++ ×1

jquery ×1

sequence-points ×1

windows-8 ×1