小编Cof*_*ing的帖子

WPF - 棱镜7.1 - 导航 - 控制选项卡控件 - 模态/对话窗口

我正在使用Prism 7.1导航框架(WPF)来获取一个对话框窗口,使用下面的配置弹出.这很成功.但是,我希望这个弹出窗口有标签,我可以来回导航.当我单击弹出框上的按钮试图在其中显示ViewA时,没有任何反应.通过设置断点,我看到导航路径被命中,并显示正确的视图名称.请参阅PopUpWindow.cs.但是,当它解析视图时,视图不会显示.更糟糕的是,没有错误!我很困惑为什么会这样.

假设我的命名空间是正确的,我做错了什么?

PrismApplication.cs

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
    containerRegistry.RegisterForNavigation<ViewA>();
}

//Have tried register type, register type for navigation, etc etc.
Run Code Online (Sandbox Code Playgroud)

MainWindowViewModel.xaml

<Window 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:prism="http://prismlibrary.com/"
        prism:ViewModelLocator.AutoWireViewModel="True"
        Height="350" Width="525">
    <i:Interaction.Triggers>
        <prism:InteractionRequestTrigger SourceObject="{Binding NotificationRequest}">
            <prism:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True" />
        </prism:InteractionRequestTrigger>
    </i:Interaction.Triggers>
    <StackPanel>
        <Button Margin="5" Content="Raise Default Notification" Command="{Binding NotificationCommand}" />
    </StackPanel>
Run Code Online (Sandbox Code Playgroud)

MainWindowViewModel.cs

public MainWindowViewModel
{
    public InteractionRequest<INotification> NotificationRequest { get; set; }
    public DelegateCommand NotificationCommand { get; set; }

    public MainWindowViewModel()
    {
        NotificationRequest = new InteractionRequest<INotification>();
        NotificationCommand = new DelegateCommand(RaiseNotification); …
Run Code Online (Sandbox Code Playgroud)

c# navigation wpf xaml prism

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

为什么返回空集合被视为好习惯?

我已经阅读了几本书并看过几篇博客,讨论如何返回空集合比返回null更好.我完全理解试图避免检查,但我不明白为什么返回一个空集合比返回null更好.例如:

public class Dog{

   private List<String> bone;

   public List<String> get(){
       return bone;
   }

}
Run Code Online (Sandbox Code Playgroud)

VS

 public class Dog{

   private List<String> bone;

   public List<String> get(){
       if(bone == null){
        return Collections.emptyList();
       }
       return bone;
   }

}
Run Code Online (Sandbox Code Playgroud)

示例一将抛出NullPointerException,示例二将抛出UnsupportedOperation异常,但它们都是非常通用的异常.是什么让一个人比另一个好或坏?

另外一个选择是做这样的事情:

 public class Dog{

   private List<String> bone;

   public List<String> get(){
       if(bone == null){
        return new ArrayList<String>();
       }
       return bone;
   }

}
Run Code Online (Sandbox Code Playgroud)

但问题是,您正在为其他人可能必须维护的代码添加意外行为.

我真的在寻找解决这种困境的方法.博客上的许多人倾向于只是说没有详细解释为什么会更好.如果返回一个不可变列表是最好的做法,我可以这样做,但我想了解为什么它更好.

java collections null immutability nullpointerexception

7
推荐指数
2
解决办法
5930
查看次数

滚动条未拉伸以适合文本小部件

我能够Scrollbar使用Text小部件,但由于某种原因,它不适合文本框.

有没有人知道有什么方法可以改变滚动条小部件的高度或者那种效果?

txt = Text(frame, height=15, width=55)
scr = Scrollbar(frame)
scr.config(command=txt.yview)
txt.config(yscrollcommand=scr.set)
txt.pack(side=LEFT)
Run Code Online (Sandbox Code Playgroud)

python tkinter widget scrollbar

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

使用Multimap Collector收集线条

有没有办法将下面的内容转换为使用收藏家呢?

List<String[]> lines = getLines();

Multimap<String,String> multimap = ArrayListMultimap.create();

lines.forEach(line -> 
multimap.put(line[0],line[1]);
);
Run Code Online (Sandbox Code Playgroud)

functional-programming multimap guava java-8 collectors

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

Java 8-合并所有包含通用元素的子集

从一组集合“组”开始:

Set<Set<String>> groups = new HashSet<>();
Run Code Online (Sandbox Code Playgroud)

我想通过合并所有子集和公共元素来创建新的集合列表:

即从下面的集合开始:

A = {a, b, c}
B = {c, d, e, f}
C = {f, g, h, i, j}
D = {k, l, m}
E = {m, n, o}
F = {p, q, r}
Run Code Online (Sandbox Code Playgroud)

最终结果将是:

Set 1 = {a, b, c, d, e, f, g, h, i, j}
Set 2 = {k, l, m, n, o}
Set 3 = {p, q, r}
Run Code Online (Sandbox Code Playgroud)

任何有关如何完成此操作的建议将不胜感激。

编辑:如果设置不均匀,它将执行相同的操作。因此,如果它是一种方法,则它的伪形式将如下所示:

public void doStuff(){

  Set<Set<String>> groups = {{a,b,c}, {c,d,e,f}, {m, …
Run Code Online (Sandbox Code Playgroud)

java merge set java-8

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

二叉树实现C++

我一直在尝试用C++实现二进制搜索树以获得乐趣.我的问题是我的插入功能有问题.以下是我到目前为止:

class TreeNode{

public: 
    int data;          
    TreeNode *left;    
    TreeNode *right;  
    void Insert(int value, TreeNode *x);
    void TreeNode::Print(TreeNode *x);
    TreeNode();
};


TreeNode::TreeNode(){

left = NULL;
right = NULL;

}
Run Code Online (Sandbox Code Playgroud)

.

void TreeNode::Insert(int value, TreeNode *x){

    if(x->left == NULL && x->right == NULL){
           TreeNode *tree = new TreeNode();                        
           tree->datavalue;                               
           x->left = tree;                                  
    }

    else if(x->left == NULL && x->right != NULL){

           TreeNode *tree = new TreeNode();                
           tree->data = value;                          
           x->left = tree;                                 
    }

    else if(x->left != NULL && x->right == NULL){

           TreeNode …
Run Code Online (Sandbox Code Playgroud)

c++ tree binary-tree function insert

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

request.get()404响应后,requests_HTTPError未被捕获

我的请求库有点问题.

比方说,我在Python中有这样的声明:

try:
   request = requests.get('google.com/admin') #Should return 404

except requests.HTTPError, e:
   print 'HTTP ERROR %s occured' % e.code
Run Code Online (Sandbox Code Playgroud)

由于某种原因,异常没有被捕获.我已经检查了API文档中的请求,但它有点渺茫.是否有人对图书馆有更多经验可以帮助我?

python error-handling try-catch python-requests

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

如何手动调用viewDidLoad?

我的iOS有点问题.我使用协议和手动切换视图在两个视图控制器之间来回传递数据.我的问题是,当我关闭顶视图时,不再调用底视图的viewDidLoad.由于我从第二个视图向第一个视图发送信息,我需要调用viewDidLoad,以便我可以处理我传递的信息.如果您对如何执行此操作有任何想法,欢迎任何帮助.谢谢.

protocols objective-c uiviewcontroller viewdidload ios

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