F# Tools for working with XAML Projects
The default maintainer account for projects under "fsprojects" is @fsprojectsgit - F# Community Project Incubation Space (repo management)
F# Tools for working with XAML Projects
Home Page: http://fsprojects.github.io/FsXaml/
License: MIT License
F# Tools for working with XAML Projects
The default maintainer account for projects under "fsprojects" is @fsprojectsgit - F# Community Project Incubation Space (repo management)
HI Reed,
I'm using a third party C# charting library to create a sample app with F#. I get a runtime exception (at App.Root.Run() ) if I use the lib's schema definition from its AssemblyInfo, for the XAML namespace declaration . However, if I separately declare 4 library namespaces with xmlns, the sample runs fine. Are you aware of why this could occur?
Would be similar to FunctionExtension
but enable binding to functions in the viewmodel.
Thinking something like:
MouseLeftButtonDown="{fsxaml:Handler {fsxaml:FunctionBinding onMouseLeftDown},
{fsxaml:Function local:Map.mouseEventArgsToPoint}}"
Not sure about it, perhaps it is just api bloat.
It would rid us of the need for an IObserver<'t>
/ICommand
in the viewmodel.
An attempt to build an existing application that works with v.3.1.2 fails when upgraded to v.3.1.3. Using the demo application WpfMvvmAgent as an example, the compiler error messages are:
WpfMvvmAgent\MainWindow.xaml.fs(7,23): error FS3033: The type provider 'FsXaml.XamlTypeProvider' reported an error: The type initializer for 'FsXaml.EventToMailbox' threw an exception.
WpfMvvmAgent\MainWindow.xaml.fs(7,23): error FS3033: The type provider 'FsXaml.XamlTypeProvider' reported an error: The type initializer for 'FsXaml.EventToMailbox' threw an exception.
WpfMvvmAgent\MainWindow.xaml.fs(11,5): error FS0945: Cannot inherit a sealed type
using "F# Empty Windows App (WPF)" template (version 2.0) :
I create an new project and update all nuget packages.
I then get the error "A strongly-named assembly is required" on the type provider.
see images.
Is this a problem with my setup ? Is this something I can fix directly?
Let's say I have
type MyUserControl = XAML<"MyUserControl.xaml",true>
UserControl
has one constructor that takes no parameters. The new type, MyUserControl
, will only have one visible constructor as far as Intellisense is concerned, but if you go through the type's ConstructorInfo
, you will find another constructor that takes a single FrameworkElement
as a parameter. Creating the element with this second constructor will cause the control to fail to render properly. I happened to find this issue because I was creating the control using Unity's resolve. It used the second constructor by default and the control failed to render.
Hello,
maybe I'm misunderstanding something, but it seems that the OnUnloaded callback is never called in ViewControllerBase.
I'm using FsXaml.Wpf 0.9.9.
I have a XAML like so (MainWindow.xaml):
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MainWindow;assembly=MyApp"
xmlns:viewmodel="clr-namespace:ViewModels;assembly=MyApp"
xmlns:fsxaml="http://github.com/fsprojects/FsXaml"
fsxaml:ViewController.Custom="{x:Type local:MainWindowController}"
WindowStyle="None" ResizeMode="NoResize" Background="Black">
...
and a ViewController like so:
/// Top-level container for all XAML elements.
type MainWindow = XAML<"MainWindow.xaml", true>
type MainWindowController() =
inherit WindowViewController<MainWindow> ()
override __.OnInitialized _ =
base.DisposeOnUnload(someDisposable)
override __.OnLoaded view =
// do something
override __.OnUnloaded view =
// do something
OnInitialized and OnLoaded are called when the window is created, but OnUnloaded is not called on exit, which means that disposeble objects added to DisposeOnUnload are never disposed.
In which case should OnUnloaded be called?
Thanks
It'd be nice to move from Blend SDK behaviors to markup extensions to avoid the dependency on the Blend SDK.
Will need to investigate if this works in Windows Store or not, however, from my recollection, this isn't supported there. That would mean either using behaviors (as we are now) or attached properties for Windows Store apps.
These belong there.
It should give a nicer exception
Application.LoadComponent doesn't work when hosted in Visual Studio. Need to switch to using XamlReader instead.
Right now, if you put in an event handler, you get a runtime error parsing the xaml.
We could, in theory, handle this. I think I could make the type provider handle everything, but I'm not sure how to get the proper event info out of the xaml schema context while parsing the sample.
For example, given <Button Click="HandleClick" />
, I'm not sure how to determine during the xml parsing that Click
is an event, and know it's specific type. If somebody wanted to try to figure that out, I think we could get the type provider to route that into a virtual method, allowing for xaml-defined, type safe event handlers to be written.
This would allow users to support some of the binding scenarios without having the Blend SDK dependency.
For many F# users, I think this would be preferable to using the behaviors. A simple markup extension for events that binds to a command with the same converter infrastructure would probably suffice.
See the picture:
(I am using the newest 2.0.0, but it is report 0.9.9. I have no idea about this.)
However, Hit F5, everything is working fine.
I should get type intellisense from VS.
VS is complaining some error, no type intellisense. ๐
No idea.
Using FsXaml over a long period of time causes a large number of files to accumulate in the user's temporary directory (c:\users\you\appdata\local\temp). These files occur in pairs, such as tmp2733.tmp and tmp2733.dll, where the .tmp file is 0 bytes and the dll is an assembly created by FsXaml. These files are not cleaned up by Visual Studio, and eventually cause slowness in the editor and errors. I recently found over 100,000 such files on a single machine.
This is a requirement for the F# Power Tools, one of the consumers of this library. It would be nice to support this.
Binding in XAML to SelectedItem or SelectedValue or SelectedIndex of a Combobox throws XamlDuplicateMemberException.
Create XAML with a ComboBox in which ItemSource and SelectedItem are bound to some model properties. E.g.
<ComboBox ItemsSource="{Binding AllItems}" SelectedItem="{Binding CurrentItem}" / >
ViewModel has properties defined as:
let items = [|"One"; "Two"|]
member this.AllItems with get() = items
member this.CurrentItem with get() = items.[1]
No exceptions thrown. The combobox has two items with second item selected.
Exception on creating instance of the view type defined as XAML<"View.xaml">:
System.Xaml.XamlDuplicateMemberException was unhandled
Message: An unhandled exception of type 'System.Xaml.XamlDuplicateMemberException' occurred in System.Xaml.dll
Additional information: 'SelectedItem' property has already been set on 'ComboBox'.
Setting selected item using code-behind works as expected.
Please consider testing out the new prerelease of FsXaml 2.0, and leaving comments and ideas below.
NuGet package published at https://www.nuget.org/packages/FsXaml.Wpf/2.0.0-beta1
This release includes significant improvements to the generated code related to all XAML types. The containers and factories no longer exist - loading XAML files into a generated type is much more aligned with the results from C# code generation (with some differences, described below).
UserControl
types no longer are wrapped within a ContentControl
when loaded from XAML. The "root" of the visual tree is the control itself, which means better efficiency, but also eliminates some of the bugs present in the previous version of FsXaml.Application
and ResourceDictionary
no longer use factories. The XAML<>
provider creates the Application or Resource Dictionary subclass directly. This is a breaking change from previous version - for example, instead of App().Root.Run()
you just do App().Run()
.IViewController
and specific view controller classes have been removed. The ViewController
types in previous versions were intended as a way to duplicate "code behind" style functionality. Since we now create types directly, and have flagged them as inheritable, you can write code behind directly in a subclass. Detailed examples exists in the demos. For an example, see: https://github.com/fsprojects/FsXaml/blob/master/demos/WpfSimpleMvvmApplication/MainView.xaml.fs#L5-L18FrameworkElement
types automatically load all named elements. The 2nd static parameter to the type provider has been removed, and is automatically treated as if it were true
. Types without named elements do not create the accessors or incur extra overhead, as the type provider handles the checking internally.ResourceDictionary
types (and Application
) no longer create elements for items by x:Key
. You can create a resource dictionary, but need to access it as a dictionary (which is more aligned with C#).Wpf
module with utilites which allow for installation of synchronization context prior to creating the application. This is required if doing asynchronous work within types that are generated directly from the main windows.Root
from application and resource dictionaries.Please try the new package, and let me know of any issues, ideas, or improvements that need to happen prior to 2.0.
Thank you!
Reed
Hi,
I have the following app.xaml
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Telerik.Windows.Controls.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
The Telerik,Windows.Controls.xaml is at the root folder and above the app.xaml. (The same app.xaml file has no problem in a C# project). however in Fsharp project fails with
System.Windows.Markup.XamlParseException occurred
Message: A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in FsXaml.Wpf.dll
Additional information: 'Set property 'System.Windows.ResourceDictionary.Source' threw an exception.' Line number '10' and line position '37'.
at App().Root.Run()
Am i missing something here? also tried to use the applicationreources.xaml from the the demo as a test. same error is produced.
environment
F#3.0
VS2013
When compiling against an X64 cpu architecture library fsXaml fails with the following error.
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
Title="MainWindow" Height="414" Width="535">
<Grid x:Name="MainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="247*"/>
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="270*"/>
</Grid.ColumnDefinitions>
<StackPanel HorizontalAlignment="Left" Height="25" Margin="0,359,0,0" VerticalAlignment="Top" Width="527" Grid.ColumnSpan="3" Orientation="Horizontal">
<Button Content="Order Send" x:Name="OrderSend" Width="191" Height="25" VerticalAlignment="Bottom"/>
<Button Content="Order Update" x:Name="OrderUpdate" Width="194"/>
<Button Content="Order Cancel" x:Name="OrderCancel" Width="141"/>
</StackPanel>
<DataGrid x:Name="OrderGrid" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="-3.7,-3.231" Grid.ColumnSpan="3" Height="164" Width="517">
<DataGrid.Columns>
<DataGridTextColumn Header="id" Binding="{Binding id}"/>
<DataGridTextColumn Header="qty" Binding="{Binding qty}"/>
<DataGridTextColumn Header="status" Binding="{Binding status}"/>
<DataGridTextColumn Header="execqty" Binding="{Binding execqty}"/>
</DataGrid.Columns>
</DataGrid>
<Label Content="Symbol" HorizontalAlignment="Left" Margin="0,169,0,0" VerticalAlignment="Top" Height="30" Width="58"/>
<TextBox x:Name="Symbol" HorizontalAlignment="Left" Height="23" Margin="101,169,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="141"/>
<RadioButton x:Name="Buy" Content="Buy" HorizontalAlignment="Left" Margin="10,204,0,0" VerticalAlignment="Top" GroupName="buysell"/>
<RadioButton x:Name="Sell" Content="Sell" HorizontalAlignment="Left" Margin="101,204,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.296,0.312" GroupName="buysell"/>
<Label Content="Quantity" Grid.Column="2" HorizontalAlignment="Left" Margin="7,169,0,0" VerticalAlignment="Top" RenderTransformOrigin="-1,0.5"/>
<TextBox x:Name="Quantity" Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="84,169,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="181"/>
<TextBox x:Name="Account" Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="84,204,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="181"/>
<Label Content="Account" Grid.Column="2" HorizontalAlignment="Left" Margin="10,202,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.553,-0.346" Width="53"/>
<RadioButton x:Name="Market" Content="Market" HorizontalAlignment="Left" Margin="10,243,0,0" VerticalAlignment="Top" GroupName="ordertype"/>
<RadioButton x:Name="Limit" Content="Limit" HorizontalAlignment="Left" Margin="101,243,0,0" VerticalAlignment="Top" d:IsHidden="True" GroupName="ordertype"/>
<Label Content="Price" Grid.Column="2" HorizontalAlignment="Left" Margin="10,241,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="Price" Grid.Column="2" HorizontalAlignment="Left" Height="23" Margin="84,243,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="181"/>
<Label Content="XML Config" HorizontalAlignment="Left" Margin="0,273,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="Config" HorizontalAlignment="Left" Height="23" Margin="101,273,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="322" Grid.ColumnSpan="3"/>
<Button x:Name="Init" Content="Init Fmwk" Grid.Column="2" HorizontalAlignment="Left" Margin="176,271,0,0" VerticalAlignment="Top" Width="89"/>
</Grid>
</Window>
open System
open System.Windows
open System.Windows.Controls
open FsXaml
open System.Xml
open System.Collections.Generic
type Mainwindow = XAML<"gui.xaml">
[<STAThread>]
try
Application().Run( new Mainwindow() ) |> ignore
C:\Program Files (x86)\Microsoft SDKs\F#\3.1\Framework\v4.0\fsc.exe
-o:obj\Debug\atfgui.exe -g --debug:full --noframework --define:DEBUG
--define:TRACE --doc:bin\Debug\atfgui.XML --optimize- --tailcalls-
--platform:x64 -r:C:\Dev\ATF\assembly\Debug\frameworkevents.dll
-r:C:\Dev\ATF\tp\FsXaml\Debug\FsXaml.Wpf.dll
-r:C:\Dev\ATF\tp\FsXaml\Debug\FsXaml.Wpf.TypeProvider.dll
-r:C:\Dev\ATF\assembly\Debug\hostengine.dll
-r:C:\Dev\ATF\assembly\Debug\mktdataservices.dll
-r:C:\Dev\ATF\assembly\Debug\mktdatastructs.dll -r:"C:\Program Files
(x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll"
-r:C:\Dev\ATF\assembly\Debug\persistence.dll -r:"C:\Program Files
(x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\PresentationCore.dll"
-r:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\PresentationFramework.dll"
-r:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Core.dll"
-r:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.dll"
-r:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Numerics.dll"
-r:C:\Dev\ATF\framework\examples\atfgui\packages\Expression.Blend.Sdk.1.0.2\lib\net45\System.Windows.Interactivity.dll
-r:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Xaml.dll"
-r:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Xml.dll"
-r:C:\Dev\ATF\assembly\Debug\tradingclasses.dll -r:"C:\Program Files
(x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\WindowsBase.dll"
--target:exe --warn:3 --warnaserror:76 --vserrors
--validate-type-providers --LCID:1033 --utf8output --fullpaths
--flaterrors --subsystemversion:6.00 --highentropyva+
--sqmsessionguid:ed3396d7-c111-4f7c-91a2-bf3691c7001c
"c:\temp.NETFramework,Version=v4.5.AssemblyAttributes.fs" atfgui.fs
FSC: error FS3031: The type provider
'C:\Dev\ATF\tp\FsXaml\Debug\FsXaml.Wpf.TypeProvider.dll' reported an
error: Assembly attribute 'TypeProviderAssemblyAttribute' refers to a
designer assembly 'FsXaml.Wpf.TypeProvider' which cannot be loaded or
doesn't exist. Could not load file or assembly
'file:///C:\Dev\ATF\tp\FsXaml\Debug\FsXaml.Wpf.TypeProvider.dll'; or
one of its dependencies. An attempt was made to load a program with an
incorrect format.
FSC: warning FS3005: Referenced assembly
'C:\Dev\ATF\tp\FsXaml\Debug\FsXaml.Wpf.TypeProvider.dll' has assembly
level attribute
'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute'
but no public type provider classes were found
Done building project "atfgui.fsproj" -- FAILED.
Build FAILED.
Object reference not set to instance of object when assigning Name or x:Name to a UserControl used from a separate Window.
If I can provide any further information, please let me know! I'm happy to help.
Edit demos/WpfSimpleMvvmApplication/MainWindow.xaml line 12 to read as follows:
<local:MainView Grid.Row="1" IsTabStop="False" x:Name="MyMainView" />
or
<local:MainView Grid.Row="1" IsTabStop="False" Name="MyMainView" />
Compile
Assignment of a name+property for the UserControl so that it can be referenced from code. This does appears to work for tbFullName
and FirstName
in MainView.xaml
.
error FS3033: The type provider 'FsXaml.XamlTypeProvider' reported an error: Object reference not set to an instance of an object.
FsXaml (3.1.2) and head of master (commit 9fc1da3)
If the target XAML file is located in a sub-folder, it can be accessed at compile-time, but not at run-time.
type MyView = FsXaml.XAML<"Views\MyView.xaml">
Error message: The specified resource name "views\myview.xaml" does not exist in the resource file.
Binding the DataContext of a UserControl using an ElementName binding worked in 0.9.9, does not work in 2.0.0
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local="clr-namespace:ViewModels;assembly=FsEmptyWindowsApp1">
<StackPanel>
<TextBox Name="Foo"/>
<local:TestControl DataContext="{Binding ElementName=Foo, Path=Text}"/>
</StackPanel>
</Window>
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<TextBox Text="{Binding .}"/>
</UserControl>
Typing into the TextBox Foo results in the same text in the TestControl.
TestControl is blank. Binding error in Debug Output is
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=Foo'. BindingExpression:Path=Text; DataItem=null; target element is 'TestControl' (Name=''); target property is 'DataContext' (type 'Object')
None.
I'd like to implement a "rename suggestion list" for https://github.com/fsprojects/VisualFSharpPowerTools/blob/master/src/FSharpVSPowerTools.Logic/RenameDialog.fs#L16 but don't really know how to do something like this with FsXaml. I'd like to provide a list with suggestions to the new name textbox (https://github.com/fsprojects/VisualFSharpPowerTools/blob/master/src/FSharpVSPowerTools.Logic/RenameDialog.xaml#L52) and if the user selects one of these the I want to have it in the textbox.
Can you give me a hint?
There was no handler to override when the XAML looked like this.
<MenuItem Header="{Binding Source={x:Static lang:Resources.Exit}}" Click="MnExitClick"/>
The error message from the compiler was: "No abstract or interface member was found that corresponds to this override."
type MainWindowXaml = XAML<"Xaml/MainWindow.xaml">
type MainWindow() =
inherit MainWindowXaml()
override x.MnExitClick (o, e) = x.Close()
I moved the handler declaration to the front, like this, and then it compiled and ran successfully.
<MenuItem Click="MnExitClick" Header="{Binding Source={x:Static lang:Resources.Exit}}"/>
Windows 10. VS 2015 with Update 3. NET Framework 4.5.2. FsXaml 3.1.6.
I try to build a XamlProvider on a ResourceDictionary file: type MyResourceDictionary = XAML<"MyResourceDictionary.xaml", true>
After I compile the project, the following error appears:
The type provider 'FsXaml.XamlTypeProvider' reported an error: Type mismatch when splicing expression into quotation literal. The type of the expression tree being inserted doesn't match the type expected by the splicing operation. Expected 'FsXaml.XamlResourceAccessor', but received type 'FsXaml.XamlResourceAccessor'. Consider type-annotating with the expected expression type, e.g., (%% x : string) or (%x : string).
If I remove the true
parameter, it compiles, but the whole point of creating a provider gets lost. Here is a sample project.
P.S. Win7 x64 + VS 2013 Community SP4 + F# 3.1
Creating a new Window which has a PNG image in it - I've tried as both Icon of the window or as a background image on a child control. The image is a content resource and shows in the WPF designer - but when I run the application, as soon as I create the window, I get: -
An unhandled exception of type 'System.Xaml.XamlObjectWriterException' occurred in System.Xaml.dll Additional information: XAML Node Stream: Missing CurrentObject before EndObject.
Any way I can get around this?
When I try to open a XAML file in VS 2017 on this particular machine, it won't open. If I double click the file in Solution Explorer, nothing at all happens. If I left-click and select Open, then this dialog box appears with the message "Visual Studio has encountered an unexpected error.", and that's all.
It happens with any XAML file in any project, and it only happens on this one machine. For this reason I don't see much use in supplying a repro, but I'll do that on request. I have another machine with what should be exactly the same setup, and there's no problem there. I also have other machines, and there's no problem with them either.
I am quite certain it used to work several weeks back, and I think the problem occurred now and then for some weeks, and now it's not possible at all to open XAML files.
Is this a problem with FsXaml, VS, F#, or ... ?
I do anticipate a reinstall of something will fix the problem, but first I'd rather contribute to fixing the bug if possible. With so little to go on, and the problem only on this machine, maybe I should just ignore and reinstall.
I have to use VS 2015 or another machine to edit XAML.
FsXaml.Wpf 3.1.6 and 3.1.2
.NET Framework 4.5.2
Visual Studio 2017, v 15.2 (26430.14)
F# 4.0 (4.4.0.0)
F# Nightly builds 15.4.1.17062201
Windows 10
I was trying to use the EventToMailbox trigger so that I could process an item associated with the button in a mailbox. I used databinding to link the MailboxParameter to the DataContext of the current item of the ItemsControl.
After wiring everything up, nothing happened on the button click. I noticed every time I clicked the button, debug output would show a System.ArgumentException had occurred. I set the debugger to break on said exception, and I saw the details of the exception was that (paraphrasing) a Tuple<object,bool> cannot be applied to a method which takes a ChildViewModel parameter. I also saw on the call stack FsXaml.Wpf.Blend.dll!FsXaml.EventToMailbox.Invoke(object param), so I looked at the code and found
FsXaml/src/FsXaml.Wpf.Blend/EventToMailbox.fs
Lines 16 to 19 in e1278f8
| param -> param :> obj
, as this wraps the MailboxParameter with the status of whether to pass EventArgs to the mailbox as a tuple, rather than just the MailboxParameter itself. Rather, the code should either be | param, _ -> param :> obj
or | _ -> this.MailboxParameter
.If you create a Xaml app using FsXaml, referencing a separate library, and set their build configurations and flags to x64, then building the solution fails with these errors:
parse error FS3053: error : The type provider constructor has thrown an exception: Could not load file or assembly 'Testx64Library, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. This assembly was compiled for a different processor.
FSC: warning FS3005: Referenced assembly '
...\Projects\FsXamlx64Test\packages\FsXaml.Wpf.0.9.9\lib\net45\FsXaml.Wpf.TypeProvider.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found
I've developed my own XAML wrapper in F#. It makes implementing User Control in F# more easier (is there a way to do it with FsXaml
type provider?). My wrapper looks like this:
// instead of type MainWindow = XAML<"Sample.xaml">
type MainWindow() as me =
inherit Window()
do me.InitializeCodeBehind("Sample.xaml")
(For full example, see https://github.com/ruxo/WpfFs/blob/master/README.md )
Is this feature interested enough to put in FsXaml library?
(Sorry if this style has been discussed before, I'm new to FsXaml library)
Which would allow us to write "real" docs for FsXaml.
It would be nice to build this in...
When using the current FsXaml version (both from the NuGet package as well as source-built assemblies) in a project, I get an error on the line
type App = FsXaml.XAML<"App.xaml">
saying
The type provider 'FsXaml.XamlTypeProvider' reported an error: Could not load type 'FsXaml.XamlResourceFactory' from assembly 'FsXaml.Wpf, Version 0.9.8.0, Culture=neutral, PublicKeyToken=null'.
I can't imagine how it would get the idea to look for 0.9.8 when both assemblies are 0.9.9. For lack of any better ideas, I have tried adding a binding redirect to 0.9.9, but to no avail.
All projects use the 4.5 runtime and F# 3.1. The demo project for FSharp.Desktop.UI in the FsXaml repository works fine.
Any ideas? Am I missing something?
Hello. Sorry for my question, but i can't figure out how it works, I need to load (mahapp) and it gives me
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in FsXaml.Wpf.dll
I've been attempting to find a way to use FsXaml to access a UserControl that's defined in its own individual XAML file, but I've been unable to find a method that works.
For example when "ListBoxQuery.xaml" defines a UserControl
type ListBoxQueryXaml = XAML<"ListBoxQuery.xaml">
let queryUI = new ListBoxQueryXaml()
let usercontrol = ListBoxQueryXaml.Accessor(xamlui)
is the only way I've been able to access the elements defined in the XAML file, but this method fails because at runtime attempting to use the elements throws a null object exception.
When these types like ListBoxQueryXaml are compiled to a class library and that .dll is loaded into the XAML Designer by adding it to the toolbox it does create XAML elements that can be embedded into other windows and panels. Although this isn't particularly useful as I haven't been able to give them any functionality using F# code beyond the default behavior of their standard control subcomponents.
I've had great success using FsXaml for individual WPF GUI windows, but perhaps I have a fundamental misunderstanding of how it should be applied in the creation of custom controls?
Hi,
On your presentation you mentioned you started also on a Windows Store version.
Can you publish that on github also?
I'd like to change this project from Apache to MIT licensing, in order to be the least restrictive possible.
I've tried to go through the commit list, and checked for all contributors who have contributed code to the project itself, which still exists in some form or another.
Would you all please comment here that you either agree, or let me know why you object, so we can re-license this in a future release?
Thank you,
Reed
People who have contributed code which still exists in some form:
Move the Behaviors and Blend SDK dependencies into a separate project, so the core nuget package doesn't need that dependency.
I would be nice to include a set of item and project templates in a vsix which could be installed.
This would replace the community templates (which are horribly out of date) with FsXaml specific templates.
If you create a Xaml app using FsXaml, referencing a separate library, and set their build configurations and flags to x64, then building the solution fails with this error:
parse error FS3053: error : The type provider constructor has thrown an exception: Could not load file or assembly 'Testx64Library, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. This assembly was compiled for a different processor.
Build the x64 configuration of the project at https://github.com/marklam/bugrepro-fsxaml-19
This includes a ViewModel assembly set to x64, and an app set to x64
A working (but empty) app, as seen when building 'Any CPU'
parse error FS3053: error : The type provider constructor has thrown an exception: Could not load file or assembly 'Testx64Library, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. This assembly was compiled for a different processor.
From this comment thread , there is a mention of a desire to use FsXaml with .NET Universal apps, which I would echo. Is this difficult to support?
Build error: FSC: error FS2024: Static linking may not use assembly that targets different profile with OxyPlot example and FsXaml when using VS2015 Update 2. .NET 4.6.x. I attached the VS project.
SimpleDemoFsharp (2).zip
Program.fs:
open System
open System.Windows
open FsXaml
// Comment out to build:
type MainWin = XAML<"MainWindow.xaml">
[<STAThread>]
[<EntryPoint>]
let main argv =
// Comment out to build:
let app = Application()
let win = MainWin()
app.Run win
MainViewModel.fs:
namespace SimpleDemoFsharp
open OxyPlot
open OxyPlot.Series
type MainViewModel() =
let myModel = PlotModel()
//comment below to build an empty window with FSXAML:
do
myModel.Series.Add(FunctionSeries(cos, 0.0, 10.0, 0.1, "cos(x)"))
member mainWindow.MyModel with get() = myModel
XAML:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
xmlns:local="clr-namespace:SimpleDemoFsharp;assembly=SimpleDemoFsharp"
Title="OxyPlot in F# and WPF" Height="480" Width="640">
<Window.DataContext>
<local:MainViewModel/>
</Window.DataContext>
<Grid>
<oxy:PlotView Model="{Binding MyModel}"/>
</Grid>
</Window>
Show oxyplot plotmodel when using FSXAML.
When loading the XAML directly, oxyplot creates the chart.
When loading the XAML via FSXAML, the project won't build.
When uncommenting the myModel.Series.Add(FunctionSeries(cos, 0.0, 10.0, 0.1, "cos(x)")) line the project compiles.
On a WPF project. I have a ValueConverter that is bound to a TextBlock. It takes in the object (lets say of type Thing) that is bound to TextBlock and returns a decimal figure. The TextBlock binds to a String, but my converter returns a Decimal value.
If I create a Converter<Thing, Decimal>, the converter will always fail because the return types are not compatible i.e. Decimal and String (inside the fWrapped function). I have to change my converter to return a string and explicitly ToString() the decimals.
In another case I also had a converter that returns a SolidColorBrush, yet the destination control expected just a Brush. So again I had to cast them to that.
I don't want to have to worry about the output type to be honest - I want to be able to return decimals and let WPF decide how to render it.
Hi,
Thanks for the awesome library!
Unable to load FsXaml.Wpf assembly from signed VSIX project.
This is the message from the original exception:
"Could not load file or assembly 'FsXaml.Wpf, Version=3.1.2.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)"
Do not sign VSIX project. In this case everything works fine, exception is gone.
Would it be possible to sign the assembly?
--
Kirill
UserControls created via the provider are focusable whereas normal UserControls are not. This is not desired behavior in my current project so I've worked around it by adding a Blend behavior to each of my UserControls, but it would be nice if this wasn't necessary. A little troubleshooting: the provided type for UserControls is inheriting from ContentControl which seems to default its Focusable property to true. UserControl also inherits from ContentControl, but seems to default Focusable to false.
As the title says. As a newbie to this, it was not immediately obvious what those 50 build errors meant. I had to compare it with the F# WPF template to figure out what is wrong. In addition to that the FSharpDesktopUINumericUpDown
demo needs Fsharp.Desktop.UI as well. It might be good to have the necessary packages be automatically downloaded.
The FsXaml project in general needs some documentation for it.
"Input String was not in correct format" when creating a new project with FsXaml template.
Creates new, empty F# WPF project
Creates the solution folder and sub-folder, but does not create any files. Displays alert message "Input String was not in correct format".
I got this error:
Could not load type 'FsXaml.XamlContainer' from assembly 'FsXaml.Wpf, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'.
I used the yo fsharp
generator to start my project as a standalone project.
FsXaml supports only loading the XAML files from a resource. It would be good if we could just load directly a XAML file from the current directory so we could use it on FSI
Why XAML Type Provider cannot generate a root type that erases to System.Windows.Window and for every visual element has provided property of appropriate type (Button, TextBox etc)?
Design with CreateRoot`` factory method and nested
Accessor``` seems non-intuitive and redundantly complex.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.