这个xaml都没有出现在设计师中,我对wpf一般都不太熟悉,但我确信至少其中一些可以在设计师中出现。
<UserControl x:Class="Company.EDIS.Electronic.Physician.DifferentialDiagnosisTab"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:COmpany.EDIS.Electronic.Physician"
xmlns:ui="clr-namespace:Company.UI.Controls;assembly=Company.UI"
xmlns:extensions="clr-namespace:Company.UI.Controls.Extensions;assembly=Company.UI"
xmlns:dataModels="clr-namespace:Company.Foundation.DataModels;assembly=Company.Foundation"
xmlns:lang="clr-namespace:Company.UI.Localization.TranslationByMarkupExtension;assembly=Company.UI.Localization"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/ecompanyion/blend/2008"
Background="{DynamicResource WindowBackgroundLightBrush}"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="600"
x:Name="ThisWindow">
<UserControl.Resources>
<Style TargetType="ToolTip">
<Setter Property = "HorizontalOffset" Value="10"/>
<Setter Property = "VerticalOffset" Value="10"/>
<Setter Property = "Background" Value="LightBlue"/>
<Setter Property = "Foreground" Value="Black"/>
<Setter Property = "FontSize" Value="14"/>
<Setter Property="Margin" Value="3" />
<Setter Property="Padding" Value="6" />
</Style>
<Style x:Key="QuestionSectionStyle" TargetType="{x:Type Border}">
<Setter Property="Background" Value="{StaticResource QuestionSectionBackgroundBrush}" />
<Setter Property="BorderBrush" Value="{StaticResource QuestionSectionBorderBrush}" />
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Margin" Value="3,0,3,10" />
<Setter Property="Padding" Value="3" />
</Style>
<!--DeleteButtonCard-->
<Style x:Key="DeleteButtonCard" TargetType="{x:Type Button}">
<Setter Property="Background" Value="LightYellow" />
<Setter Property="Foreground" Value="Black" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Margin" Value="3" />
<Setter Property="Padding" Value="6" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid Margin="{TemplateBinding Margin}">
<Border Margin="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
<Grid>
<ContentControl HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Content="{TemplateBinding Content}"
Cursor="Hand"/>
<Image HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="IMAGE" Visibility="Hidden" Opacity=".2" Height="75" Width="100"
Source="pack://application:,,,/Company.UI.Images;component/CommonImages/Delete.png" />
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="IMAGE" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--AddButtonCard-->
<Style x:Key="AddButtonCard" TargetType="{x:Type Button}">
<Setter Property="Background" Value="Gray" />
<Setter Property="Foreground" Value="White" />
<Setter Property="FontSize" Value="16" />
<Setter Property="Padding" Value="2" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Border BorderBrush="White" BorderThickness=".5" Margin="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
<Grid>
<TextBlock HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
FontSize="{TemplateBinding FontSize}"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Content}"
Cursor="Hand" TextWrapping="Wrap"/>
<Image HorizontalAlignment="Right"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="IMAGE" Visibility="Hidden" Height="25" Width="25"
Source="pack://application:,,,/Company.UI.Images;component/CommonImages/Add.png" />
</Grid>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="IMAGE" Property="Visibility" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--AvailableDiagnosisDataModel-->
<DataTemplate DataType="{x:Type dataModels:DiagnosisDataModel}" x:Key="AvailableDiagnosisDataModel">
<Button Style="{StaticResource AddButtonCard}" Height="35" HorizontalAlignment="Stretch"
Content="{Binding ShortDescription}" ToolTip="{Binding LongDescription}" HorizontalContentAlignment="Left" Margin="5,0,0,0"
Command="{Binding Content.DiagnosisClickedCommand, ElementName=ThisWindow}"
CommandParameter="{Binding}"/>
</DataTemplate>
<!--SelectedDiagnosisDataModel-->
<DataTemplate DataType="{x:Type dataModels:DiagnosisDataModel}" x:Key="SelectedDiagnosisDataModel">
<Button Style="{StaticResource DeleteButtonCard}" Height="150" Width="180"
Command="{Binding Content.SelectedDiagnosisClickedCommand, ElementName=ThisWindow}"
CommandParameter="{Binding}" ToolTip="{Binding LongDescription}" >
<Button.Content>
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1" Foreground="Black" FontSize="14" FontWeight="Bold" Text="{Binding ShortDescription}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
<Label Grid.Row="2" Foreground="Red" FontSize="10" Content="{Binding IcdCode}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Bottom"/>
</Grid>
</Button.Content>
</Button>
</DataTemplate>
<!--DifferentialTabViewModel-->
<DataTemplate DataType="{x:Type local:DifferentialDiagnosisTabViewModel}">
<Grid Grid.Row="0" ShowGridLines="False">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<Border Style="{StaticResource QuestionSectionStyle}" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="100" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" FontSize="16" Foreground="White" Margin="5,0,0,0" FontWeight="Bold" Text="{lang:TranslateLocal DifferentialDiagnoses, DefaultValue=Differential Diagnoses}" VerticalAlignment="Center"></TextBlock>
<TextBlock Grid.Column="2" FontSize="16" Foreground="White" Margin="5,0,0,0" Text="{lang:TranslateLocal Note, DefaultValue=Note:}"></TextBlock>
<TextBox Grid.Column="3" Grid.ColumnSpan="2" MaxHeight="100" FontSize="12"
HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto" TextAlignment="Left"
TextWrapping="Wrap" AcceptsReturn="True" AcceptsTab="True" Margin="5,0"
Text="{Binding Note.Comment}"/>
</Grid>
</Border>
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Center" Margin="5">
<ui:TextBoxPlus x:Name="txtSearch"
Text="{Binding Path=SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ClearButtonVisibility="Visible"
BackgroundText="{lang:TranslateLocal Search, DefaultValue=Search}"
Margin="4,0,5,0"
Height="{DynamicResource TouchableMinHeight}" Width="300"
VerticalAlignment="Center" Loaded="txtSearch_Loaded" />
<Button x:Name="SearchButton" Content="{lang:TranslateLocal Search1, DefaultValue=Search}" IsDefault="True"
Click="SearchButton_Click" Loaded="SearchButton_Loaded"
Width="100"
Command="{Binding SearchCommand}"
CommandParameter=""/>
<Button x:Name="AddButton" Content="{lang:TranslateLocal Add, DefaultValue=Add}"
Click="AddButton_Click" Loaded="AddButton_Loaded"
Width="100"
Command="{Binding AddCommand}"
CommandParameter=""/>
<Button x:Name="CommonButton" Content="{lang:TranslateLocal Common, DefaultValue=Common}"
Click="CommonButton_Click" Loaded="CommonButton_Loaded"
Width="100"
Command="{Binding CommonCommand}"
CommandParameter=""/>
<Button x:Name="InfoButton" Content="{lang:TranslateLocal InfoButton,DefaultValue=InfoButton}"
Click="InfoButton_Click" />
</StackPanel>
<ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<ItemsControl x:Name="DiagnosesList"
ItemTemplate="{StaticResource AvailableDiagnosisDataModel}"
ItemsSource="{Binding Diagnoses}"
BorderBrush="Transparent"
Background="Transparent"/>
</ScrollViewer>
<ScrollViewer Grid.Row="2" Grid.Column="1" VerticalScrollBarVisibility="Auto">
<ItemsControl x:Name="SelectedDiagnosesList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
ItemTemplate="{StaticResource SelectedDiagnosisDataModel}"
ItemsSource="{Binding SelectedDiagnoses}"
Margin="0"
BorderBrush="Transparent"
Background="Transparent">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</ScrollViewer>
</Grid>
</DataTemplate>
</UserControl.Resources>
</UserControl>
这是传统/棕色代码。我觉得我对Wpf Windows非常可靠,但还没有想出DataTemplate
或Style
s
所以我似乎错过了这个家伙如何解决或重新清理它的重要部分,初始化后的代码:
private void DifferentialDiagnosisTab_Loaded(object sender, RoutedEventArgs e)
{
vm = new DifferentialDiagnosisTabViewModel();
this.Content = vm;
}
答案 0 :(得分:2)
它没有出现在设计师中,因为as Johan Larsson noted,没有什么可以展示的。您已完成的任务是定义一组控件可能使用的资源 - Style
和DataTemplate
资源,即。
获取整个<Grid>
代码(移除其现在为空的父代<DataTemplate>
)并将其移出<UserControl.Resources>
代码(在</UserControl>
结束代码之前)。不确定这会给你什么你想要的(我只是只看了一下标记),但是你已经拥有了那个&#34;啊-HA&#34;时刻; - )
在典型的 Model-View-ViewModel 设置中,ViewModel不是内容(您的代码正在设置控件{{1}在运行时,这就是设计时没有出现的原因),它是Content
,而XAML使用绑定到ViewModel的属性。
你不应该有这样的代码隐藏。