Caliburn.Micro - 将组合框项目传递给按钮

Caliburn.Micro - Passing combobox items to a button

我正在尝试将项目从我的组合框(绑定到我的模型对象的列表)传递到我的按钮。我的问题是我是 Caliburn.Micro + WPF 的新手,不太确定如何 subscribe/pass 我的按钮所需的值(比如将 PropetyName 的字符串发送到 Button(string propetyName))。

视图模型代码:

class ShellViewModel : Screen
{
    private DataModel _fileInFolder;
    private BindableCollection<DataModel> _data;

    public ShellViewModel()
    {
       // .GetData() preforms the objects'  initialization
        DataModel dataOutput = new DataModel();
        Data = new BindableCollection<DataModel>(dataOutput.GetData());
    }


    public BindableCollection<DataModel> Data 
    {
        get
        {
            return _data;
        }

        set
        {
            _data = value;
            NotifyOfPropertyChange(() => Data);
        }
    } 

    public DataModel FileInFolder
    {
        get { return _fileInFolder; }
        set 
        { 
            _fileInFolder = value;

            NotifyOfPropertyChange(() => FileInFolder);

        }
    }

   //This is where the items will be passed to.
  
  public void OpenFile()
  {
       
  }

}

XAML代码:

<Grid>
    <!-- Folders -->
    <ComboBox ItemsSource="{Binding Data}" SelectedItem="{Binding FileInFolder}"
     HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="250">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding Folders}"/>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>
    <!-- Files -->
    <ComboBox x:Name="FileInFolder_Files"
    HorizontalAlignment="Left" Margin="280,10,0,0" VerticalAlignment="Top" Width="250"/>
    <!-- Open File -->
    <Button x:Name="OpenFile" 
    Content="Open File" HorizontalAlignment="Left" Margin="560,10,0,0" VerticalAlignment="Top" Width="90">
       
    </Button>

</Grid>

对不起,如果我的描述是vague/missing更多的说明,我是这里的新用户!

FileInFolder 是组合中的选定项。

OpenFile 在同一个 class 中,因此可以引用 FileInFolder。

public void OpenFile()
{
     var whatever = FileInFolder.SomeProperty;
   // etc
}

您可能需要在其中进行一些空值检查。