这是我的ItemsControl的代码,当鼠标移过时放大项目.
我没有设法增加当前缩放项目的ZIndex以将其放在其他项目上.
<ItemsControl ItemsSource="{Binding Path=Value}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name}"
RenderTransformOrigin="0.5 0.5">
<TextBlock.Style>
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1.5"
ScaleY="1.5" />
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
Run Code Online (Sandbox Code Playgroud)
我试图在触发器中直接更改ZIndex,但它不起作用.
我似乎需要更改ContentPresenter中的ZIndex,它是VisualTree中TextBlock的Parent,而不是直接在TextBlock中.
<Setter Property="Panel.ZIndex" Value="99" />
Run Code Online (Sandbox Code Playgroud)
所以我尝试在ContentPresenter中更改ZIndex,但它仍然不起作用
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type ContentPresenter}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Panel.ZIndex" Value="99" />
</Trigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud)
有谁知道它是如何工作的?
我需要在WPF"字体"中转换GDI字体.
myGdiFont As System.Drawing.Font
Run Code Online (Sandbox Code Playgroud)
在
_Family As Windows.Media.FontFamily
_Style As Windows.FontStyle
_Weight As Windows.FontWeight
_Size As Double
Run Code Online (Sandbox Code Playgroud)
特别是,我需要转换
_Size = myGdiFont.Size (???)
Run Code Online (Sandbox Code Playgroud)
WinForms字体的大小是单位或点...在WPF中是像素...如何从一个转换为另一个?
PS.
掌握克莱门斯的迹象,这是正确的吗?
Dim myDrawingFont As New System.Drawing.Font("Arial", 10)
Dim myWpfLabel As New Windows.Controls.Label
myWpfLabel.FontSize = myDrawingFont.SizeInPoints * 72 / 96
Run Code Online (Sandbox Code Playgroud)
固定:
myWpfLabel.FontSize = myDrawingFont.SizeInPoints * 96 / 72
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置DataGridCells的Validation.ErrorTemplate,这是xaml代码:
<Style x:Key="{x:Type DataGridCell}" x:Uid="dataGridCellErrorTemplate" TargetType="{x:Type DataGridCell}">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate >
<Border BorderBrush="Green" BorderThickness="2" ToolTip="Heidenei"></Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<!-- following line only for demonstration that the setter is working ... -->
<Setter Property="Background" Value="Aquamarine"></Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
当datagridcells的背景成功地变为绿色(与任何验证结果无关)时,使用的Validation.ErrorTemplate仍然是默认值,即红色边框。
我知道在stackoverflow中也有类似的问题,例如,设置 DataGridCell错误模板的样式, 但它们并不能真正解决我的问题。
任何帮助表示赞赏
坦率
我希望在WPF数据网格中有一个自定义列类型,其中一部分将是用户输入的文本框.不幸的是,它似乎没有继承数据网格本身的外观 - 它不显示交替颜色,当选择或编辑一行时,相关单元格不会以相同方式突出显示,依此类推.
<DataGridTemplateColumn Header="Name" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<TextBox Text="{Binding DisplayName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" IsReadOnly="False" BorderThickness="0" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)
看起来默认文本框的样式会覆盖数据网格的样式; 有没有办法只使用datagrids风格?我当然可以设置文本框的样式以模仿数据网格,但如果我想添加其他控件,我也必须为每个控件执行此操作.如果我沿着那条路走下去,我将如何根据celltemplate中的datagridrow属性更改样式? - 例如IsSelected.
当列表中有足够的对象时,我有一个ScrollViewer出现在右侧.如何让它出现在左侧?
<ListBox
x:Name="MessageListBox"
BorderThickness="0"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
HorizontalContentAlignment="Stretch"
AlternationCount="2"
ItemContainerStyle="{StaticResource AltStyle}"
SelectionMode="Extended"
>
<ListBox.ItemTemplate >
<DataTemplate>
<!-- button -->
<!-- closing tags -->
Run Code Online (Sandbox Code Playgroud) 我试图使用以下代码在WPF中运行时加载图像
_image = new Image();
BitmapImage src = new BitmapImage();
src.BeginInit();
src.UriSource = new Uri(@"pack://application:,,,/images/tagimages/placeholder.png", UriKind.Absolute);
src.CacheOption = BitmapCacheOption.OnLoad;
src.EndInit();
_image.Source = src;
_image.Stretch = Stretch.None;
Run Code Online (Sandbox Code Playgroud)
在我的项目中,我有一个名为images的文件夹和一个名为tagimages的文件夹的子文件夹,其中包含placeholder.png.当我运行此代码时,我收到以下错误
"无法找到资源'images/tagimages/placeholder.png'"
我究竟做错了什么?
我有一个非静态变量,INotifyPropertyChanged成功实现.然后我尝试将其设为全局,因此将其变为静态变量.但这一次,INotifyPropertyChanged不起作用.有解决方案吗

大家好,正如你在之前的画笔中看到的那样,中间有线条,
如何使它平滑是不是很顺利?(如何删除那些行)我用混合创建它
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="0.452,1.962" StartPoint="1.164,-0.352">
<GradientStop Color="#FF202020" Offset="0"/>
<GradientStop Color="#FF545454" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
</Grid>
Run Code Online (Sandbox Code Playgroud) 我已经列出了所有可以帮助改善具有大量控件的非常复杂的应用程序中的性能的列表.如果你想加你的,欢迎你!
我使用的工具:
当我单击导航栏上的按钮时,将打开一个新窗口.例如:
private void btFinanzen_Click(object sender, RoutedEventArgs e)
{
Finanz mw = new Finanz(login);
mw.Show();
}
Run Code Online (Sandbox Code Playgroud)
现在,我不想在新窗口中显示它.而不是那样,我想让它显示在同一个窗口.我尝试了以下内容:
private void btFinanzen_Click(object sender, RoutedEventArgs e)
{
Finanz mw = new Finanz(login);
//mw.Show();
this.Content = Finanz f;
}
Run Code Online (Sandbox Code Playgroud)
但它失败了.我应该说的是,我现在有很多不同的窗口,希望它们全部显示在一个窗口 - 每个窗口都可以点击一个不同的按钮.我该怎么办呢?
wpf ×10
c# ×3
blend ×2
datagrid ×2
xaml ×2
.net ×1
celltemplate ×1
font-size ×1
fonts ×1
itemscontrol ×1
performance ×1
static ×1
validation ×1
winforms ×1
z-index ×1