How make friendly Expression Blend and Caliburn.Micro WPF - wpf

I'm try to change my View Model for my Application. Use MVVM and Caliburn.Micro. But when I try open my project in Expression Blend for Visual Studio 2012 I get an error about my Caliburn.Micro dll. I don't see my view window in Expression Blend IDE and have many errors. How make friendly Expression Blend and Caliburn.Micro WPF.

there are directions on www.caliburnmicro.com about setting up design time support since you don't have it configuration at present. It also appears that you a reference issue Message.Attach doesn't appear to be recognized. Doesn't matter if you are using Window, Page, UserControl fyi
<Window
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:CaliburnDesignTimeData.ViewModels"
xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro.Platform"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=vm:MainPageViewModel, IsDesignTimeCreatable=True}"
cal:Bind.AtDesignTime="True">

Related

Is it possible to include custom C++\WinRT UWP controls in WPF with XAML Islands and WindowsXamlHost?

I have a WPF application that is too onerous to rewrite wholesale in UWP. Some of the UWP controls would utilize SwapChainPanel and thus have C++/WinRT to manage DirectX. To determine the feasibility of implementing portions of the application in UWP and including them in WPF, I made a minimal sample app following Microsoft documentation that attempts to compose UWP controls in a WPF application targeting .NET Core 3.1.
<Window x:Class="WpfAppCore3._1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xh="clr-namespace:Microsoft.Toolkit.Wpf.UI.XamlHost;assembly=Microsoft.Toolkit.Wpf.UI.XamlHost"
Title="WPF App"
Height="500"
Width="800">
<StackPanel>
<xh:WindowsXamlHost InitialTypeName="UwpLib.ManagedGrid"
Height="225" />
<xh:WindowsXamlHost InitialTypeName="UwpLibNative.NativeGrid"
Height="225" />
</StackPanel>
</Window>
This works great for a managed control like UwpLib.ManagedGrid but UwpLibNative.NativeGrid does not load:
The debugger shows an exception:
System.BadImageFormatException: 'Bad IL format.'
That exception indicated to me a build configuration issue, but I think the application is set up correctly in that regard. Is this just not possible with XAML Islands today or have I made some configuration mistake in the sample app?
Update 1:
I discovered the "Windows Desktop Compatible" option and made sure that was set to "Yes". No change.

XAML Designer shows error on custom behaviors in Visual Studio 2015

I am doing my first steps in Visual Studio 2015 and Blend for Visual Studio 2015. The XAML designer fails to show a preview of the UI and keeps marking all the behaviors with errors. To demonstrate the problem I have created a minimal solution that presents the problem. I have a solution that contains only a single WPF application called Test.Ui, (target .net framework is 4.5). The WPF application references the Blend Dlls: Microsoft.Expression.Interactions and System.Windows.Interactivity, both in version 4.5.
The behavior class implementation is minimal:
namespace Test.Ui
{
public class MyBehavior : Behavior<Grid>
{
protected override void OnAttached()
{
base.OnAttached();
}
}
}
The XAML that uses it is as follows:
<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"
xmlns:local="clr-namespace:Test.Ui"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
x:Class="Test.Ui.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<i:Interaction.Behaviors>
<local:MyBehavior/>
</i:Interaction.Behaviors>
</Grid>
</Window>
The designer both in Blend and in Visual Studio keep showing an error mark under the line with an error that says:
"The type 'MyBehavior' from assembly 'Test.Ui' is built with an older version of the Blend SDK, and is not supported in Windows Presentation Framework 4 project.
Note that it is not a WPF 4 project, but rather a WPF 4.5, and that the application runs fine. It only has errors in the designer.
I am using the latest version of Blend Dlls.

Adding a new IronPython WPF Window to complains "Window is not supported in a WPF project"

Immediately after adding a brand new, untouched WPF window to my IronPython 2.7 project in VS2013 (with Python Tools for VS 2.0.11016), it tells me "Invalid Markup" in the design window, and the error list shows:
Window is not supported in a Windows Presentation Foundation (WPF) project.
Grid is not supported in a Windows Presentation Foundation (WPF) project.
The XAML window has this innocuous looking code in it:
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
</Grid>
</Window>
Does Python tools for VS not really support form creation? Did I forget to configure something?
The project was started as an "IronPython Windows Forms Application" rather than an "IronPython WPF Application" so it was missing the relevant references:
PresentationCore
PresentationFramework
WindowsBase
Adding them makes WPF forms functional, or just recreating the project.
If all of those references appear to be in the project, removing/readding some might help. Another user reported he had to do so for 'PresentationFramework'; perhaps there's a couple that have the same name?

Design-Time Population of ListBox with Sample Data in WPF

I have a view (usercontrol) that contains a listbox.
At runtime the listbox will be populated with instances of another view (also a usercontrol).
How can I populate the listbox in design-time (in Blend and Cider) with sample views that are themselves populated with sample data?
Using VS2010 you can use Design-Time attributes (works for both SL and WPF). I usually have a mock data-source anyway so it's just a matter of:
Adding the namespace declaration
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
Adding the mock data context to window/control resources
<UserControl.Resources>
<ViewModels:MockXViewModel x:Key="DesignViewModel"/>
</UserControl.Resources>
Setting design-time data context
<Grid d:DataContext="{Binding Source={StaticResource DesignViewModel}}"> ...
Works well enough.
You might find the BookLibrary sample application of the WPF Application Framework (WAF) interesting. It uses the new design-time support of Visual Studio 2010 and Expression Blend 4. Please download the .Net4 version of WAF.

Windows Forms Host + System.Windows.Forms.DataVisualization.Chart

Good day all
I have the following question:
I would like to use Chart from Windows Forms due to the fact that it allows to build much more types of graphical visualisation that one from WPF Toolkit does.
So, I am adding Chart control for Windows Forms as a child element into the WindowsFormsHost. But, when I run the application I and all my clients see only white area. Though, any other Windows Forms Control works great in Windows Forms Host.
What is wrong with the Chart control?
Here is the XAML code
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:CHR="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
Title="Window1" Height="300" Width="300">
<Grid>
<wfi:WindowsFormsHost x:Name="mainFGrid" >
<CHR:Chart x:Name="mainChart" />
</wfi:WindowsFormsHost>
</Grid>
</Window>
Kind regards,
Anatoliy Sova
I found kind of Workaround, basically create the chart at runtime
http://support2.dundas.com/Default.aspx?article=1331
Thanks
Shaik

Resources