Coder Social home page Coder Social logo

Comments (2)

ReedCopsey avatar ReedCopsey commented on September 26, 2024

Would it be possible to get a reproduction of this? I'm not sure how to try to figure out how to correct the problem (or point you in the right direction) without something I can debug.

from fsharp.viewmodule.

yuyoyuppe avatar yuyoyuppe commented on September 26, 2024

It seems it got nothing to do with multibinding. I think I'm doing something wrong:) Minimized sample:

Mainwindow.xaml:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:local="clr-namespace:ViewModel;assembly=fsxamltest">
    <Window.DataContext>
        <local:MainViewModel/>
    </Window.DataContext>
    <WrapPanel>
        <Button Content="pass the grid" Command="{Binding GridReceiverCommand}" CommandParameter="{Binding ElementName=TheGrid,Mode=OneWay}"/>
        <DataGrid Name="TheGrid"/>
    </WrapPanel>
</Window>

App.xaml:

<Application
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml"/>

Program.fs:

open System
type App = FsXaml.XAML< "App.xaml">
[<STAThread;EntryPoint>]
let main _ = App().Root.Run()

VM.fs:

namespace ViewModel

open FSharp.ViewModule
open System.Windows.Controls
open System

type Command() =
  let canExecuteChanged = new Event<EventHandler, EventArgs>()
  interface INotifyCommand with
    member __.CanExecute _ = true
    [<CLIEvent>]
    member __.CanExecuteChanged = canExecuteChanged.Publish
    member __.Execute p =   
      let dg = p :?> DataGrid
      printfn "executed!"
    member __.RaiseCanExecuteChanged() = failwith "not implemented"   

type MainViewModel() as me = 
  inherit ViewModelBase()    
  let cmd1 = me.Factory.CommandSyncParamChecked((fun dg -> printfn "called!"), fun _ -> true)
  let cmd2 = Command()
  member __.GridReceiverCommand = 
    cmd1
//    cmd2

Note that it works with this minimal Command interface.

EDIT: this make it work again for some reason.

from fsharp.viewmodule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.