我想要一个像VS 2008这样的布局.我想要两列和第二列再分成两列.
我在下面提到的xaml中做到了这一点,但是GridSplitter垂直不可见(分割两列).
我希望这两个GridSplitters都可以调整大小.一个GridSplitter调整左手窗格和右手窗格的GridSplitter大小,另一个调整子网格的顶部窗格和右窗格的大小.
第二个GridSplitter是通过这个XAML,但我无法生成拆分右手窗格和左手窗格的XAML代码..请帮助!!
<Window x:Class="AlarmUI_2.Window1"
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.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackPanel Background="Aqua" Grid.Column="0" >
<TextBlock FontSize="35" Foreground="#58290A"
TextWrapping="Wrap">Left Hand Side</TextBlock>
</StackPanel>
<GridSplitter Grid.Column="0" ResizeDirection="Auto"
Grid.RowSpan="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"/>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListBox Grid.Row="0" Background="Red">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
<GridSplitter Grid.Row="1" Height="5" Background="Gray"
VerticalAlignment="Top" HorizontalAlignment="Stretch" />
<ListBox Grid.Row="1" Background="Violet" Margin="0,5,0,0">
<ListBoxItem>Hello</ListBoxItem>
<ListBoxItem>World</ListBoxItem>
</ListBox>
</Grid>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud) 我想以下列方式使用ToggleButton:有5个不同的图像,每个图像应根据当前状态显示:
我发现一个简单的例子有两个影像在这里,但如何改变依赖于"选中"属性的形象呢?
第二个问题:如何避免为我的应用程序中的每个按钮创建不同的样式?我使用了大约20个不同的按钮,每个按钮都有不同的图标.
到目前为止,我只在我的代码下面使用了一个图标.是否可以使用公共代码(样式和模板)并在我想要创建按钮的部分中定义图像源(如我的代码的第3部分)?
<ControlTemplate x:Key="ToggleButtonTemplate" TargetType="{x:Type ToggleButton}">
<Grid>
<Border x:Name="ContentBorder" CornerRadius="4" BorderBrush="Transparent" BorderThickness="1" Background="{DynamicResource ButtonOff}">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ButtonOn}"/>
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ButtonOn}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ButtonDisabled}"/>
<Setter Property="Foreground" Value="{DynamicResource BorderDisabled}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Width" Value="64" />
<Setter Property="Height" Value="64" …Run Code Online (Sandbox Code Playgroud) 我已将默认菜单控件添加到用户控件中.我需要设置菜单样式以删除包含图标或复选框空间的左边距.我怎样才能做到这一点?
XAML:
<Menu>
<MenuItem Header="MyMenu" FontSize="10">
<MenuItem Header="Options..." />
<MenuItem Header="About" />
</MenuItem>
</Menu>
Run Code Online (Sandbox Code Playgroud)
它目前呈现与任何其他菜单控件开箱即用:

我不希望菜单项左边的边距或列.这通常用于图标等.
我有一个WPF组合框绑定到具有长描述的项目列表.
绑定到ComboBox的类型具有短和长描述作为属性.目前,我对完整描述具有约束力.
comboBox.DisplayMemberPath = "FullDescription";
Run Code Online (Sandbox Code Playgroud)
如何确保在选择项目并将其显示为组合框中的单个项目时,它将显示为ShortDescription属性值,同时显示下拉列表FullDescription?
我正在为WPF中的项目设置样式ListBox,并希望在每个项目周围添加边框.与BorderThickness设置为1,例如,相邻的项之间的上下边框都引出,并因此出现比侧边界"厚",如下所示:

生成这些的项模板ListBoxItems是:
<DataTemplate>
<Border BorderThickness="1" BorderBrush="DarkSlateGray" Background="DimGray" Padding="8 4 8 4">
<TextBlock Text="{Binding Name}" FontSize="16"/>
</Border>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
我想"折叠"这些相邻的边界,例如,可以通过CSS.我知道BorderThickness可以单独为左/右/上/下边框定义,但这也会影响第一个或最后一个项目的边框,这是不希望的.
有没有办法用WPF实现这一目标?Border我缺少的属性,还是需要不同的方法来创建边界?
我有 
我需要 
XAML:
<Image Height="500"
MouseLeftButtonDown="image_MouseLeftButtonDown"
MouseRightButtonDown="image_MouseRightButtonDown"
Name="image"
Stretch="Fill"
Width="500" />`
Run Code Online (Sandbox Code Playgroud)
C#:
wbmap = new WriteableBitmap(50, 50, 500, 500, PixelFormats.Indexed8, palette);
wbmap.WritePixels(new Int32Rect(0, 0, wbmap.PixelWidth, wbmap.PixelHeight), pixels, wbmap.PixelWidth * wbmap.Format.BitsPerPixel / 8, 0);
image.Source = wbmap;
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
<ListView Height="238"
HorizontalAlignment="Left"
Name="listView1"
VerticalAlignment="Top"
Width="503"
ItemsSource="{Binding}"
IsSynchronizedWithCurrentItem="True">
<ListView.View>
<GridView>
<GridView.Columns>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Tag="{Binding ID}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding ID}" Header="ID" />
<GridViewColumn DisplayMemberBinding="{Binding Name}" Header="Name" />
</GridView.Columns>
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)

我如何知道选中了多少个复选框,并获取所选复选框的值标签?
如何设置TabItem的背景?我尝试了以下代码:
<TabControl>
<TabItem Header="Test" Background="Blue" Foreground="Red" />
</TabControl>
Run Code Online (Sandbox Code Playgroud)
Foreground工作,但Background不起作用.

有任何想法吗?谢谢
我想让我的应用程序最大化到全屏幕意味着它隐藏了Windows任务栏和标题栏.它应该由一个按钮触发.
我正在尝试像这样开发我的应用程序窗口.
在下面添加我的代码段
<controls:MetroWindow x:Class="EDUI.MainWindow"
xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:local="clr-namespace:EDiscoveryCore;assembly=EDiscoveryCore"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="eDi" BorderBrush="SkyBlue" BorderThickness="2" Height="999" Width="1071" WindowState="Maximized" x:Name="MainWindows">
Run Code Online (Sandbox Code Playgroud) 我有一个带主窗口的WPF应用程序和从主窗口按钮打开的第二个窗口.我希望在Visual Studio中将第二个窗口打开为"关于"窗口时禁用主窗口.
wpf ×10
wpf-controls ×10
c# ×4
binding ×2
border ×1
combobox ×1
fullscreen ×1
gridsplitter ×1
styling ×1
tabitem ×1