小编Mir*_*rko的帖子

如何直接调用ReactiveUI 7中的ReactiveCommand.Execute()是否正确?

我正在尝试将我的项目从ReactiveUI 6.5转换为版本7.在旧版本中我调用了

// var command = ReactiveCommand.Create...;
// ...
if(command.CanExecute(null))
    command.Execute(null);
Run Code Online (Sandbox Code Playgroud)

为了从我的代码后面执行命令.

现在,CanExecute方法不再可用,并替换为属性IObservable<bool>.如果我只是打电话Execute().Subscribe()或者我必须明确地调用它,是否会自动调用CanExecute Observable ?

现在我用上面的代码替换了

command.Execute().Subscribe();
Run Code Online (Sandbox Code Playgroud)

c# reactiveui

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

如何使用代码隐藏将ReactiveList绑定到WPF ListBox或ListView?

我有一个问题是在我的视图中显示控件中的ReactiveList的内容ListBox.当我尝试通过代码隐藏绑定(使用this.OneWayBind(...))绑定它时,列表保持为空.我正在使用最新的ReactiveUI版本(6.1.0).如果我将绑定更改为XAML-Binding并删除调用OneWayBind(...),则列表将显示五个String元素.

我不知道为什么这不起作用,一个简单的TextBlock.Text-Binding按预期工作(参见代码).


MainWindow.xaml:

<Window x:Class="View_Location_Test.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:View_Location_Test"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<StackPanel>
    <ListBox x:Name="ToasterList">
    <!-- This is working if you uncomment the above line and remove the OneWayBind call in the view-code: -->
    <!--<ListBox x:Name="ToasterList" ItemsSource="{Binding ToasterList}">-->
        <ListBox.Resources>
            <DataTemplate DataType="{x:Type System:String}">
                <TextBlock Text="{Binding}" />
            </DataTemplate>
        </ListBox.Resources>
    </ListBox>
    <TextBlock x:Name="ToasterName" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

MainWindow.xaml.cs:

public partial class MainWindow : Window, IViewFor<ViewModel>
{
    public MainWindow()
    {
        ViewModel = …
Run Code Online (Sandbox Code Playgroud)

c# wpf reactiveui

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

Mahapps Metro:在窗口底部显示非模态自动关闭消息对话框

是否可以在Mahapps Metro中显示标准消息对话框,MetroWindow就像Github for Windows应用程序一样?我想通知用户有关异常的信息,但无需在他/她继续使用该应用程序之前关闭此对话框.

到目前为止,我使用以下代码打开消息对话框,但这是一种阻止方式,它出现在以下位置的中心MetroWindow:

await this.ShowMessageAsync("My title", "My error message");
Run Code Online (Sandbox Code Playgroud)

我想创建一个Github for Windows类似的对话框.你可以在这里看到截图:

截图

Github for Windows您可以撤消任何操作,但此消息只出现几秒钟,比自动皮.

c# wpf github-for-windows mahapps.metro

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

标签 统计

c# ×3

reactiveui ×2

wpf ×2

github-for-windows ×1

mahapps.metro ×1