如果terraform脚本使用具有输出的模块,则可以使用命令-module选项访问这些模块输出terraform output:
$ terraform output --help
Usage: terraform output [options] [NAME]
Reads an output variable from a Terraform state file and prints
the value. If NAME is not specified, all outputs are printed.
Options:
-state=path Path to the state file to read. Defaults to
"terraform.tfstate".
-no-color If specified, output won't contain any color.
-module=name If specified, returns the outputs for a
specific module
-json If specified, machine readable output will be
printed in JSON format
Run Code Online (Sandbox Code Playgroud)
如果我将该状态文件存储在S3或其他类似文件中,我可以使用 …
我有一组ViewModel,我绑定到TabControl的ItemsSource属性.让我们调用那些ViewModels AViewModel,BViewModel和CViewModel.其中每个都需要有不同的ItemTemplate(对于标题;因为它们每个都需要显示不同的图标)和不同的ContentTemplate(因为它们具有非常不同的交互模型).
我想要的是这样的:
在某处的Resource.xaml文件中定义:
<DataTemplate x:Key="ItemTemplate" DataType="{x:Type AViewModel}">
...
</DataTemplate>
<DataTemplate x:Key="ItemTemplate" DataType="{x:Type BViewModel}">
...
</DataTemplate>
<DataTemplate x:Key="ItemTemplate" DataType="{x:Type CViewModel}">
...
</DataTemplate>
<DataTemplate x:Key="ContentTemplate" DataType="{x:Type AViewModel}">
...
</DataTemplate>
<DataTemplate x:Key="ContentTemplate" DataType="{x:Type BViewModel}">
...
</DataTemplate>
<DataTemplate x:Key="ContentTemplate" DataType="{x:Type CViewModel}">
...
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
单独定义:
<TabControl ItemTemplate="[ Some way to select "ItemTemplate" based on the type ]"
ContentTemplate="[ Some way to select "ContentTemplate" based on the type ]"/>
Run Code Online (Sandbox Code Playgroud)
现在,我真实地知道,每次我使用相同的键定义DataTemplate时,系统就会抱怨.但是,有什么我可以做的类似于这将允许我将DataTemplate放入基于名称和数据类型的TabControl?
我在WinForms容器中托管WPF UserControl.现在,我希望能够主题/皮肤UserControl.为此,我有几个定义"皮肤"的资源字典.当我的应用程序启动时,我创建了一个"new System.Windows.Application()",以便Application.Current存在.要更改主题,将删除旧外观,并在运行时将新外观合并到应用程序级别资源字典中.但是,这不会更改UserControl中任何dyanamically引用的资源.我在一个直接的WPF应用程序中尝试了这个,它运行得很好.我错过了什么,或者根本不可能这样做?顺便说一句,如果我在UserControl初始化之前将一个皮肤添加到应用程序资源中,它将起作用,但之后我无法更改皮肤.
以最基本的方式回复这个:
创建一个新的WinForms应用程序.将WPF UserControl添加到应用程序.这很简单:
<UserControl ...>
<Grid>
<Button
Background="{DynamicResource ButtonBG}"/>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
使用具有相应颜色的键ButtonBG创建两个具有SolidColorBrush的ResourceDictionaries,White.xaml和Black.xaml(或其他).在Form1.cs中,添加两个按钮和一个ElementHost.将ElementHost的子项设置为我们刚刚创建的UserControl的实例.将按钮连接到交换皮肤的事件:
private void White_Click(object sender, EventArgs e)
{
Application.Current.Resources.MergedDictionaries[0] =
(ResourceDictionary)Application.LoadComponent(
new Uri(@"\WpfThemes;component\White.xaml", UriKind.Relative)));
}
private void Black_Click(object sender, EventArgs e)
{
Application.Current.Resources.MergedDictionaries[0] =
(ResourceDictionary)Application.LoadComponent(
new Uri(@"\WpfThemes;component\Black.xaml", UriKind.Relative)));
}
Run Code Online (Sandbox Code Playgroud)
在Program.cs中,确保Application.Current存在并设置初始外观:
[STAThread]
static void Main()
{
new System.Windows.Application();
Application.Current.Resources.MergedDictionaries[0] =
(ResourceDictionary)Application.LoadComponent(
new Uri(@"\WpfThemes;component\White.xaml", UriKind.Relative)));
...
}
Run Code Online (Sandbox Code Playgroud)
现在,当单击白色按钮时,我希望UserControl中的按钮变为白色,当单击黑色按钮时,我希望按钮变黑.但是,这不会发生.
有谁知道为什么?有解决方案吗?
编辑:想法:也许,如果有一种方法可以在主题发生变化时强制重新评估DynamicResources,那就行了.
谢谢,Dusty
我有一个C#WPF应用程序,我正在尝试使用resx文件进行全球化.它的工作非常出色.然而,我遇到了麻烦.我有一个相对简单的多元化解决方案,我有一个单数和复数形式的字符串我正在显示,我根据我正在谈论的任何事情的数量选择一个.
但是,我最近接受了一些文化有多种形式的事实.有没有人在C#中遇到过这个问题的好方法,更不用说WPF?
我在这个问题上看到的典型例子来自波兰语.波兰语有单数,paucal和复数形式.此示例用于翻译单词"file":