按钮出现在错误的地方

时间:2015-09-29 15:38:09

标签: c# wpf button

我有一个左侧出现一个按钮的按钮,如何让它出现在我所处的位置?这可能是一件非常简单的事情,但我今天真的很挣扎,今天我今天过得很糟糕。有人请帮帮我

        public class CognitiveTreeBuilderViewModel : INotifyPropertyChanged
{
    private CognitiveTreeRoot root;
    private readonly IDiagramBuilder diagramBuilder;

    public CognitiveTreeBuilderViewModel(IDiagramBuilder diagramBuilder)
    {
        this.diagramBuilder = diagramBuilder;
    }

    public void Bind(CognitiveTreeRoot treeRoot)
    {
        root = treeRoot;
        this.diagramBuilder.BuildDiagram(root);
    }

    public void Rebuild()
    {
        this.diagramBuilder.BuildDiagram(root);
    }

    public void Expand(PropertyNode propertyNode)
    {
        if (!propertyNode.ScenarioNodes.Any())
        {
            return;
        }

        propertyNode.IsExpanded = true;

        diagramBuilder.Hide(propertyNode.DiagramId);
        foreach (var scenarioNode in propertyNode.ScenarioNodes)
        {
            diagramBuilder.Show(scenarioNode.DiagramId);
        }
    }

    public void DisplayAddScenarioButton(double p)
    {
        int propertyNodeIndex = Convert.ToInt32(p/210);

        foreach (var property in root.Nodes)
        {
            property.IsAddButtonVisible = false;
        }
        if (propertyNodeIndex < root.Nodes.Count)
        {
            root.Nodes[propertyNodeIndex - 1].IsAddButtonVisible = true;
        }
    }

    public void Collapse(PropertyNode propertyNode)
    {
        propertyNode.IsExpanded = false;
        foreach (var scenarioNode in propertyNode.ScenarioNodes)
        {
            diagramBuilder.Hide(scenarioNode.DiagramId);
        }
        diagramBuilder.Show(propertyNode.DiagramId);
    }

    public void CreateScenario(PropertyNode propertyNode)
    {
        propertyNode.IsExpanded = true;
        propertyNode.AddScenario();
        this.diagramBuilder.BuildDiagram(root);
    }

    public void RenameScenario(ScenarioNode scenarioNode)
    {
        var shouldEdit = scenarioNode.IsEditing == false;
        if (!shouldEdit)
        {
            scenarioNode.IsEditing = false;
            return;
        }

        foreach (var node in scenarioNode.Parent.ScenarioNodes)
        {
            node.IsEditing = false;
        }
        scenarioNode.IsEditing = true;
    }

    public void ToggleExpanded(PropertyNode propertyNode)
    {
        if (propertyNode.IsExpanded == true)
        {
            Collapse(propertyNode);
        }
        else
        {
            Expand(propertyNode);
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    [NotifyPropertyChangedInvocator]
    protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
        var handler = PropertyChanged;
        if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    }
}

0 个答案:

没有答案