Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Updated to FsXaml 0.9.9 #808

Merged
merged 3 commits into from
Oct 30, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ NUGET
Microsoft.AspNet.Razor (2.0.30506.0)
RazorEngine (3.3.0)
FSharp.ViewModule.Core (0.9.9.1)
FsXaml.Wpf (0.9.8)
FsXaml.Wpf (0.9.9)
Expression.Blend.Sdk (>= 1.0.2)
Microsoft.AspNet.Razor (2.0.30506.0)
Microsoft.Bcl (1.1.9)
Expand Down
19 changes: 8 additions & 11 deletions src/FSharpVSPowerTools.Logic/FolderMenuUI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ open FSharpVSPowerTools
[<RequireQualifiedAccess>]
module FolderMenuUI =
let loadNewFolderDialog (viewModel: NewFolderNameDialogModel) =
let window = NewFolderNameDialog().CreateRoot()
window.DataContext <- viewModel
window
let window = NewFolderNameDialog()
window.Root.DataContext <- viewModel
window.Root

let loadMoveToFolderDialog (viewModel: MoveToFolderDialogModel) =
let window = MoveToFolderDialog().CreateRoot()
let window = MoveToFolderDialog()

// Provides access to "code behind" style work
let accessor = MoveToFolderDialog.Accessor(window)

accessor.FoldersTree.SelectedItemChanged.Add(fun _ ->
viewModel.SelectedFolder <- Some (accessor.FoldersTree.SelectedItem :?> Folder)
window.FoldersTree.SelectedItemChanged.Add(fun _ ->
viewModel.SelectedFolder <- Some (window.FoldersTree.SelectedItem :?> Folder)
)

window.DataContext <- viewModel
window
window.Root.DataContext <- viewModel
window.Root
2 changes: 1 addition & 1 deletion src/FSharpVSPowerTools.Logic/FolderNameDialog.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open FSharpVSPowerTools
open FSharp.ViewModule
open FSharp.ViewModule.Validation

type NewFolderNameDialog = FsXaml.XAML< "FolderNameDialog.xaml" >
type NewFolderNameDialog = FsXaml.XAML<"FolderNameDialog.xaml">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there no true here while the argument appears in MoveToFolderDialog :-)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed. The extra argument is only needed if you're doing "code behind" type of work, which (normally) can and should be avoided.


[<NoEquality; NoComparison>]
type NewFolderNameDialogResources =
Expand Down
2 changes: 1 addition & 1 deletion src/FSharpVSPowerTools.Logic/MoveToFolderDialog.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open FSharpVSPowerTools
open FSharp.ViewModule
open FSharp.ViewModule.Validation

type MoveToFolderDialog = FsXaml.XAML< "MoveToFolderDialog.xaml" >
type MoveToFolderDialog = FsXaml.XAML<"MoveToFolderDialog.xaml", true>

type Folder =
{ Name: string
Expand Down
16 changes: 7 additions & 9 deletions src/FSharpVSPowerTools.Logic/RenameDialog.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open FSharp.ViewModule.Progress
open FSharp.ViewModule.Validation
open System.Threading

type RenameDialog = FsXaml.XAML<"RenameDialog.xaml">
type RenameDialog = FsXaml.XAML<"RenameDialog.xaml", true>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does 'true' mean in this context? Could you add the argument name so that the purpose is clear?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It exposes the named properties in the XAML file as properties on the RenameDialog type.


[<NoComparison>]
type RenameContext =
Expand Down Expand Up @@ -164,10 +164,8 @@ type RenameDialogViewModel(originalName: string, initialContext: Async<RenameCon

// This handles "code behind", ie: pure view logic for our dialog
type RenameDialogViewController() =
interface FsXaml.IViewController with
member __.Attach fe =
// Use the TypeProvider's Accessor sub-type to gain access to named members
let window = RenameDialog.Accessor fe
inherit FsXaml.WindowViewController<RenameDialog>()
override __.OnLoaded window =
let model = window.Root.DataContext :?> INotifyPropertyChanged
// Once the model is initialized, focus and select txtName so the user can just type "F2 / new_name / Enter"
model.PropertyChanged.Add(fun e ->
Expand All @@ -181,7 +179,7 @@ type RenameDialogViewController() =
[<RequireQualifiedAccess>]
module UI =
let loadRenameDialog (viewModel: RenameDialogViewModel) owner =
let window = RenameDialog().CreateRoot()
window.Owner <- owner
window.DataContext <- viewModel
window
let window = RenameDialog()
window.Root.Owner <- owner
window.Root.DataContext <- viewModel
window.Root