如何将 DesignInstance 与 Caliburn.Micro 结合使用

2023-11-29

我正在使用 Caliburn.Micro

我有这个 WPF 视图,在设计时在名字等基本属性上成功使用示例数据,但找不到复杂类型的属性和集合的视图

<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>

这是示例数据

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:Bind.AtDesignTime="True"在您的用户控制上。

<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}"
         cal:Bind.AtDesignTime="True">
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将 DesignInstance 与 Caliburn.Micro 结合使用 的相关文章

  • pthread_cond_timedwait() 和 pthread_cond_broadcast() 解释

    因此 我在堆栈溢出和其他资源上进行了大量搜索 但我无法理解有关上述函数的一些内容 具体来说 1 当pthread cond timedwait 因为定时器值用完而返回时 它如何自动重新获取互斥锁 互斥锁可能被锁定在其他地方 例如 在生产者
  • C++ 子字符串返回错误结果

    我有这个字符串 std string date 20121020 我正在做 std cout lt lt Date lt lt date lt lt n std cout lt lt Year lt lt date substr 0 4 l
  • C - 找到极限之间的所有友好数字

    首先是定义 一对友好的数字由两个不同的整数组成 其中 第一个整数的除数之和等于第二个整数 并且 第二个整数的除数之和等于第一个整数 完美数是等于其自身约数之和的数 我想做的是制作一个程序 询问用户一个下限和一个上限 然后向他 她提供这两个限
  • C 预处理器库

    我的任务是开发源分析工具C程序 并且我需要在分析本身之前预处理代码 我想知道什么是最好的图书馆 我需要一些重量轻 便于携带的东西 与其推出自己的 为什么不使用cpp这是的一部分gcc suite http gcc gnu org onlin
  • Qt moc 在头文件中实现?

    是否可以告诉 Qt MOC 我想声明该类并在单个文件中实现它 而不是将它们拆分为 h 和 cpp 文件 如果要在 cpp 文件中声明并实现 QObject 子类 则必须手动包含 moc 文件 例如 文件main cpp struct Sub
  • 指针减法混乱

    当我们从另一个指针中减去一个指针时 差值不等于它们相距多少字节 而是等于它们相距多少个整数 如果指向整数 为什么这样 这个想法是你指向内存块 06 07 08 09 10 11 mem 18 24 17 53 7 14 data 如果你有i
  • 如何将图像路径保存到Live Tile的WP8本地文件夹

    我正在更新我的 Windows Phone 应用程序以使用新的 WP8 文件存储 API 本地文件夹 而不是 WP7 API 隔离存储文件 旧的工作方法 这是我如何成功地将图像保存到 共享 ShellContent文件夹使用隔离存储文件方法
  • vector 超出范围后不清除内存

    我遇到了以下问题 我不确定我是否错了或者它是一个非常奇怪的错误 我填充了一个巨大的字符串数组 并希望在某个点将其清除 这是一个最小的例子 include
  • C# 中的递归自定义配置

    我正在尝试创建一个遵循以下递归结构的自定义配置部分
  • 从路径中获取文件夹名称

    我有一些路c server folderName1 another name something another folder 我如何从那里提取最后一个文件夹名称 我尝试了几件事 但没有成功 我只是不想寻找最后的 然后就去休息了 Thank
  • for循环中计数器变量的范围是多少?

    我在 Visual Studio 2008 中收到以下错误 Error 1 A local variable named i cannot be declared in this scope because it would give a
  • 将 xml 反序列化为类,list<> 出现问题

    我有以下 XML
  • 插入记录后如何从SQL Server获取Identity值

    我在数据库中添加一条记录identity价值 我想在插入后获取身份值 我不想通过存储过程来做到这一点 这是我的代码 SQLString INSERT INTO myTable SQLString Cal1 Cal2 Cal3 Cal4 SQ
  • C++ fmt 库,仅使用格式说明符格式化单个参数

    使用 C fmt 库 并给定一个裸格式说明符 有没有办法使用它来格式化单个参数 example std string str magic format 2f 1 23 current method template
  • 在 Dynamics CRM 插件中访问电子邮件发件人地址

    我正在编写一个 Dynamics CRM 2011 插件 该插件挂钩到电子邮件实体的更新后事件 阶段 40 pipeline http msdn microsoft com en us library gg327941 aspx 并且在此阶
  • 32 位到 64 位内联汇编移植

    我有一段 C 代码 在 GNU Linux 环境下用 g 编译 它加载一个函数指针 它如何执行并不重要 使用一些内联汇编将一些参数推送到堆栈上 然后调用该函数 代码如下 unsigned long stack 1 23 33 43 save
  • mysql-connector-c++ - “get_driver_instance”不是“sql::mysql”的成员

    我是 C 的初学者 我认为学习的唯一方法就是接触一些代码 我正在尝试构建一个连接到 mysql 数据库的程序 我在 Linux 上使用 g 没有想法 我运行 make 这是我的错误 hello cpp 38 error get driver
  • ASP.NET MVC 6 (ASP.NET 5) 中的 Application_PreSendRequestHeaders 和 Application_BeginRequest

    如何在 ASP NET 5 MVC6 中使用这些方法 在 MVC5 中 我在 Global asax 中使用了它 现在呢 也许是入门班 protected void Application PreSendRequestHeaders obj
  • C 中的异或运算符

    在进行按位操作时 我在确定何时使用 XOR 运算符时遇到一些困难 按位与和或非常简单 当您想要屏蔽位时 请使用按位 AND 常见用例是 IP 寻址和子网掩码 当您想要打开位时 请使用包含或 然而 XOR 总是让我明白 我觉得如果在面试中被问
  • 如何在 C++ BOOST 中像图形一样加载 TIFF 图像

    我想要加载一个 tiff 图像 带有带有浮点值的像素的 GEOTIFF 例如 boost C 中的图形 我是 C 的新手 我的目标是使用从源 A 到目标 B 的双向 Dijkstra 来获得更高的性能 Boost GIL load tiif

随机推荐

  • 使用 Mule 发送格式化邮件

    我正在使用 Mule 发送电子邮件 我需要为发送的文本添加格式 邮件的内容是有效负载 其中包含我在 Java 方法中形成的字符串 并使用表达式转换器发送到流程 我需要向该字符串添加格式 粗体 下划线 颜色 我该怎么做 这是我的流程的摘录
  • 如何使用 PHP GD 显示动态生成的内嵌图像

    我正在尝试使用 PHP GD 合并图像来动态生成图像 我想知道是否有一种方法可以在我的网页中显示图像 而不需要将其存储在服务器上的某个位置 例如 我创建了以下代码来合并图像 function create image main image
  • 乘客安装时出现转换错误。对 nginx 模块有影响吗?

    在OS X 10 6 8下安装passenger 首先在rbenv下 然后卸载rbenv后 也在rvm下 Mini user gem install passenger 正在生成转换错误 unable to convert xE4 to U
  • Pygame 需要“for event in pygame.event.get()”以免崩溃

    该程序像这样工作正常 但是 我不明白为什么它需要无用的for event in pygame event get None in the gameOverwhile 语句里面game loop 如果您能找到一种方法来删除它或解释为什么没有它
  • 使用内置 Python 模块填写 Web 表单数据

    好吧 我已经在我的冒险中使用了 mechanize requests beautiful soup 甚至 selenium 来做这样的事情 我得出的结论是 urllib 和其他默认模块是最好的方法 唯一的问题是我根本不知道如何使用它 那么有
  • aspnet core 应用程序中的 Autofac.Multitenant 似乎无法正确解析租户范围的依赖项

    我正在升级利用 Autofac Multitenant 框架的多租户 dotnet 核心解决方案 我没有太多运气让租赁解决方案正常工作 我在这里创建了一个简单的问题演示 https github com SaltyDH AutofacMul
  • 在 python 中使用绘制数据的微型版本作为图例句柄

    有没有办法使用 matplotlib 中的图形中绘制的线作为图例中的句柄 例如 我在想 在这个基本代码中 而不是图例中的直线 有一个我绘制为手柄的正弦波的小版本 import matplotlib pyplot as plt import
  • 在 RDLC 报告中添加数据集时 Visual Studio 2013 崩溃

    当我尝试将数据集添加到 asp net 项目中的任何 RDLC 报告时 Visual Studio 停止工作并重新启动 我尝试使用 VS 2012 和 2015 添加数据集 两次尝试都产生了与您相同的错误 这种情况只发生在我的 VS 项目之
  • Windows 8.1 64 位中的 IBM MobileFirst Platform 安装

    我正在使用我的办公室笔记本电脑 Lenovo vV310 8GB RAM 64 位操作系统 Windows 8 1 过去几天我一直在尝试修复 IBM Mobile First Platform 的安装问题 我从链接下载了 IBM Mobil
  • HTML5 直播

    对于学校 我需要建立一个 HTML5 直播网站 他们有一个一直在使用的 Flash 流播放器 但现在希望它改用 HTML5 我怎样才能做到这一点 我尝试使用视频标签 但无法正常工作 下面是我的代码 有人能指出我正确的方向吗
  • 将两个同名的 .swift 文件添加到项目中

    我正在尝试将 swagger 客户端集成到我的项目中 我能够从 swagger 生成类 Swagger for swift 3 使用 Alamofire 进行 newtork 操作 问题是生成的类名称之一是 Response Alamofi
  • 无法打开该文件,因为您无权查看该文件

    imageData NSData dataWithContentsOfURL self pdfFileUrl options NSDataReadingMappedAlways error error NSLog error localiz
  • sublime 3 制表符和空格不匹配

    我已经浏览网页3次了 但仍然没有解决方案 我有一个简单的 js 文件 我希望我的制表符是 4 个空格而不是 2 个 我将首选项设置更改为选项卡大小为 4 更改了语法特定设置 一切 但仍然是同样的问题 有任何想法吗 Click On状态栏上的
  • 如何将图片保存到localStorage并在下一页显示?

    所以 基本上 我需要上传单个图像 将其保存到 localStorage 然后将其显示在下一页上 目前 我上传了 HTML 文件
  • Jquery ui 选项卡的不同动画

    我正在使用 jquery ui 选项卡小部件 我没有使用 jquery 主题 因为我更喜欢做我自己的 css 和东西 我已经让它工作了 但我想要的是当单击不同的选项卡时 选项卡内容具有不同的动画效果 我想要的是新的选项卡内容从左侧滑入 目前
  • 软删除实体的导航属性

    我有 2 个实体 我是我的数据库 它们看起来像 Vehicles Id VehicleNumber IsDeleted WorkerId Workers Id Name Address 在我的 edmx 中 VehicleId Id Veh
  • 将 Azure 文件服务 CloudFileShare 映射为云服务每个实例上的虚拟目录

    我有一个天蓝色的云服务 我正在尝试升级该服务以实现高可用性 并且我已订阅了已在预览门户中启用的 Microsoft Azure 文件服务预览版 我已经创建了一个新的存储帐户 并且可以看到该存储帐户现在有一个文件端点位于 https
  • 序列化 Collat​​or 实例

    我正在尝试序列化InstitutionResultView类的一些对象 它基本上是包装器番石榴的 TreeMultimap import java io Serializable import java text Collator impo
  • R 数据表中的最小值不等于特定值

    如何从 R 数据表中找到除特定值之外的最小值 例如 数据表中可能存在零 目标是找到最小非零值 我尝试使用sapply with min 但不确定如何指定我们拥有的额外标准 以使最小值不等于某个值 更一般地说 我们如何从数据表中找到不等于可能
  • 如何将 DesignInstance 与 Caliburn.Micro 结合使用

    我正在使用 Caliburn Micro 我有这个 WPF 视图 在设计时在名字等基本属性上成功使用示例数据 但找不到复杂类型的属性和集合的视图