3
Я использую Caliburn.Microкак использовать DesignInstance с Caliburn.Micro
У меня есть этот WPF вид, что в дизайне время успешно использует выборочные данные об основных свойствах, как Firstname и т.д., но не может не найти вид для свойств и коллекций сложных типов
<UserControl x:Class="NonRepositoryItems.Reviewer.ReviewerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:Controls="clr-namespace:MyFramework.Controls.BusyIndicator.Implementation;assembly=App.Framework"
xmlns:cal="http://www.caliburnproject.org"
xmlns:FormPanel="clr-namespace:MyFramework.Controls.FormPanel;assembly=App.Framework"
xmlns:SampleData="clr-namespace:NonRepositoryItems.SampleData"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance SampleData:SampleReviewerViewModel, IsDesignTimeCreatable=True}"
>
<Grid>
<Border>
<DockPanel>
<DockPanel.Resources>
<Style TargetType="Label" >
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="12" />
</Style>
<Style TargetType="TextBlock" >
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</DockPanel.Resources>
<FormPanel:FormPanel Columns="2" Margin="5" DockPanel.Dock="Top">
<Label Content="Job Title"/>
<TextBlock Text="{Binding JobTitle}" />
<Label Content="Honorific"/>
<TextBlock Text="{Binding Honorific}" />
<Label Content="First Name"/>
<TextBlock Text="{Binding FirstName}" />
<Label Content="Last Name"/>
<TextBlock Text="{Binding LastName}" />
<Label Content="Gender"/>
<TextBlock Text="{Binding Gender}" />
</FormPanel:FormPanel>
<FormPanel:FormPanel Columns="1" Margin="5" DockPanel.Dock="Top">
<Label Content="Postal Address"/>
<ContentControl cal:View.Model="{Binding PostalAddress}" />
<Label Content="Courier Address"/>
<ContentControl cal:View.Model="{Binding CourierAddress}" />
</FormPanel:FormPanel>
<ListView ItemsSource="{Binding RepositoryItems}"></ListView>
</DockPanel>
</Border>
<Controls:BusyIndicator IsBusy="{Binding IsBusy}" BusyContent="Busy..." Grid.ColumnSpan="2"></Controls:BusyIndicator>
<ContentControl x:Name="Dialogs"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"/>
</Grid>
</UserControl>
Вот SampleData
public class SampleReviewerViewModel : ReviewerViewModel
{
public SampleReviewerViewModel()
{
Honorific = "Mr";
FirstName = "John";
LastName = "Smith";
ReviewerId = "125634";
Gender = "Male";
JobTitle = "REC Chair";
ReviewerTaskCount = "10";
ReviewerRequestedTaskCount = "20";
ReviewerDispatchedTaskCount = "33";
ReviewerRequestedReturnedCount = "50";
PostalAddress = new AddressViewModel();
CourierAddress = new AddressViewModel();
IsBusy = false;
RepositoryItems = new ObservableCollection<RepositoryItemViewModel>
{
new RepositoryItemViewModel() {Title = "Red" },
new RepositoryItemViewModel() {Title = "Orange" },
new RepositoryItemViewModel() {Title = "Yellow" },
new RepositoryItemViewModel() {Title = "Green" },
new RepositoryItemViewModel() {Title = "Blue" },
new RepositoryItemViewModel() {Title = "Indigo" },
new RepositoryItemViewModel() {Title = "Violet" }
};
}
}
Вот мой взгляд адрес
<UserControl x:Class="NonRepositoryItems.Reviewer.AddressView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:SampleData="clr-namespace:NonRepositoryItems.SampleData" mc:Ignorable="d"
d:DataContext="{d:DesignInstance SampleData:SampleAddressViewModel, IsDesignTimeCreatable=True}"
>
<Border>
<Grid Margin="4">
<StackPanel>
<TextBlock Text="{Binding AddressLine1}" Visibility="{Binding IsAddressLine1Visible, Converter={StaticResource booleanToVisibility}}"/>
<TextBlock Text="{Binding AddressLine2}" Visibility="{Binding IsAddressLine2Visible, Converter={StaticResource booleanToVisibility}}" />
<TextBlock Text="{Binding AddressLine3}" Visibility="{Binding IsAddressLine3Visible, Converter={StaticResource booleanToVisibility}}" />
<TextBlock Text="{Binding City}" Visibility="{Binding IsCityVisible, Converter={StaticResource booleanToVisibility}}"/>
<TextBlock Text="{Binding PostCode}" Visibility="{Binding IsPostCodeVisible, Converter={StaticResource booleanToVisibility}}"/>
<TextBlock Text="{Binding Country}" Visibility="{Binding IsCountryVisible, Converter={StaticResource booleanToVisibility}}"/>
</StackPanel>
</Grid>
</Border>
</UserControl>
и это выборочные данные
public class SampleAddressViewModel : AddressViewModel
{
public SampleAddressViewModel()
{
Type = "Mail Address";
AddressLine1 = "350 Fifth Avenue";
AddressLine2 = "";
AddressLine3 = "";
City = "New York, NY ";
PostCode = "10118";
Country = "United States of America";
}
}
У меня нет этого имущества. cal: Привязать только к свойству Model. Есть ли другая сборка, которую я должен использовать. Эта статья кажется тем, что мне нужно, но если есть более интегрированный способ, мне было бы интересно узнать http://mnajder.blogspot.com.au/2011/09/design-time-support-for-caliburnmicro .html – Peter
Какая версия CM вы? Материал из этого сообщения в блоге теперь встроен. Вот пример SL: https://bitbucket.org/dbeattie/designdata/src –
Я использую тот, который приходит через NuGet v 1.2.0 – Peter