HI,我正在开发一个RichTextBox在WPF中使用的编辑器,我必须实现一个功能,Text如果选择了某些文本,用户可以设置所选字体,如果没有选择,则应为新文本设置字体.如果我在以后的情况下设置RTB 的字体属性(如FontStyle,FontSize),它将设置整个文本的属性,如何设置新文本的字体属性(即如果用户输入文本,它将带有新的字体设置).
有没有办法在那里设置复选框的样式?iv尝试为复选框定义样式但不起作用.
使用鼹鼠之后,似乎复选框控件中没有ToggleButton,而是使用BulleDecorator,我不确定第一次使用鼹鼠..
我想要实现的是,我想要一个红色或绿色圆圈,而不是一个复选框.
<Style TargetType="{x:Type CheckBox}">
<Setter Property="IsHitTestVisible" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border x:Name="innerBorder">
<Ellipse Fill="#FFFF0000" Stroke="#FF000000" Stretch="Fill" x:Name="statusLight" Width="15" Height="15" Margin="2" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="statusLight" Property="Fill" Value="#FF00FF00" />
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter TargetName="statusLight" Property="Fill" Value="#FFFF0000" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud) 我有一个ListBox显示一些绑定到我的问题的用户控件.这工作正常,但我不希望其中的每个项ListBox都可以选择,因此我创建了一个空白样式并将其应用于ItemContainerStyle.这导致我的内容消失,每个项目显示为空白.有任何想法吗?
--Xaml--
<ListBox ItemContainerStyle="{StaticResource noSelect}" Name="lbTasks" Height="180"
BorderBrush="#E6E6E6" >
<ListBox.ItemTemplate>
<DataTemplate>
<my:TaskQuestion Question="{Binding Test}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
- 样式 -
<Style x:Key="noSelect" TargetType="{x:Type ListBoxItem}">
<Setter Property="Margin" Value="2, 2, 2, 0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我是否错误地使用了内容演示者?
Tia,Kohan
我有一个2行*2列的网格,并将一个TextBlock放在左上角的单元格中(row = 0,column = 0).然后我在XAML中设置Grid.Cursor ="Hand".仅当鼠标悬停在TextBlock上时,才会显示手形光标.但我想在整个网格中显示手形光标.
怎么做?
我希望我的前三项ListView具有特殊风格.我怎样才能实现这一目标?
我试过这个但是item总是为null:
if (tracklistQueue.Items.Count > 0) {
ListViewItem item = (ListViewItem)tracklistQueue.ItemContainerGenerator.ContainerFromIndex(0);
item.Style = (Style)FindResource("StyleName");
}
Run Code Online (Sandbox Code Playgroud) 在以下方案中如何在WPF中生成缩略图图像?
using (MemoryStream mem = new MemoryStream(imgbytes))
{
BitmapImage jpgimage = new BitmapImage();
jpgimage.BeginInit();
jpgimage.CacheOption = BitmapCacheOption.OnLoad;
jpgimage.StreamSource = mem;
jpgimage.EndInit();
Image wpfimage = new Image();
wpfimage.Source = jpgimage.Clone();
lbx.Items.Add(wpfimage);
lbx.UpdateLayout();
Thread.Sleep(1000);
}
Run Code Online (Sandbox Code Playgroud) 鉴于以下两个选项:
<ContentControl>Content</ContentControl>
Run Code Online (Sandbox Code Playgroud)
与
<ContentControl Content="Content"/>
Run Code Online (Sandbox Code Playgroud)
我很害怕这个问题可能听起来有点幼稚,但我怎么知道我不会问,所以我决定拍它.
如果我选择了错误的决定,请评论我;)
我有一个类来读取和输出图像内容,如果设置了$ width,它将调整图像大小,然后输出它.
如果我像这样调用函数$ image-> readImage('123.jpg'); ,它可以正确输出图像文件,但是当我调用$ image-> readImage('123.jpg',300)时; 要调整大小,它只显示一个调整宽度和高度的黑色图像.
我试图替换代码
@imagejpeg($thumb, null, 100);
Run Code Online (Sandbox Code Playgroud)
至
@imagejpeg($image, null, 100);
Run Code Online (Sandbox Code Playgroud)
会工作〜
-
protected function readImage($fileName, $width = 0)
{
if ($width <= 0) {
return @file_get_contents($this->destination . '/' . $fileName);
} else {
$imageSize = @getimagesize($this->destination . '/' . $fileName);
$actualWidth = $imageSize[0];
$actualHeigth = $imageSize[1];
if ($actualWidth <= $width) {
return @file_get_contents($this->destination . '/' . $fileName);
}
$height = (100 / ($actualWidth / $width)) * .01;
$height = @round($actualHeigth * $height);
$image …Run Code Online (Sandbox Code Playgroud) 嗨,我想找到一些方法,当点击一个按钮更改其他控件的可见性,如在XAML中具有触发器的DataGrid.
该按钮仅将DataGrid的可见性更改为Visible,它在Code Behind中执行其他操作,但我认为这可以在带触发器的样式中完成.
我试图找到一个解决方案,似乎有可能做但我无法理解如何.
提前致谢.
wpf ×9
styles ×4
c# ×2
datagrid ×2
image ×2
wpf-controls ×2
cursor ×1
fonts ×1
grid ×1
listview ×1
performance ×1
php ×1
resize ×1
richtextbox ×1
thumbnails ×1
xaml ×1