Setting HasDropShadow has no effect on WPF tool tip - c#

Setting HasDropShadow on a ToolTip seems to have no effect. I am using Dev Studio 2015 on Windows 10. I tried pasting a screen shot in Paint and enlarging it and I couldn't see any shadow effect. I checked the value of SystemParameters.DropShadow and it was true.
<Window x:Class="WpfApplication5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication5"
mc:Ignorable="d"
Title="MainWindow" Height="222.911" Width="412.032">
<Grid>
<TextBlock Text="Hover the mouse over me" Margin="10,10,229.6,156.6">
<TextBlock.ToolTip>
<ToolTip HasDropShadow="True">Iam a tool tip</ToolTip>
</TextBlock.ToolTip>
</TextBlock>
</Grid>
</Window>

Related

WPF: Can't change property of custom control inside other control template (+Pictures)

Let's create an empty WPF project.
Add a very simple UserControl (i named it MyUserControl):
<UserControl x:Class="Delete_This_Test.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
Background="Red"
Height="100">
<Grid>
</Grid>
</UserControl>
As you can see, i have changed only 2 properties: Background and Height to "Red" and "100".
Put our created control in MainWindow:
<Window x:Class="Delete_This_Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Delete_This_Test"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<local:MyUserControl Width="100"
Height="200"
Background="Blue">
</local:MyUserControl>
</Grid>
</Window>
Here, i have changed Width, Height and Background to "100", "200" and "Blue".
And it works: Without ControlTemplate Picture
But if we put MyUserControl in some ControlTemplate, for example of Button:
<Window x:Class="Delete_This_Test.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Delete_This_Test"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button>
<Button.Template>
<ControlTemplate TargetType="Button">
<local:MyUserControl Width="100"
Height="200"
Background="Blue">
</local:MyUserControl>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</Window>
This will not work. Only Width property will changed, because we didn't set it in MyUserControl xaml.
Height and Background will be the same as "100" and "Red":
With ControlTemplate Picture
So my question is: Is it bug of WPF, or i'm missing something obvious?
*
Because i need to use one custom control in different templates, and change some properties, e.g. Background of control

WPF window with WindowChrome resizing issue

Have this simple XAML for a custom window. It works fine except during a resize (from the left, top, top-left and bottom-left) it looks awful. The window flashes like crazy. Doesn't seem like an OS issue as Microsoft's glass Windows app resize smooth as butter.
I'm trying to customize the window frame, but unless I use WindowChrome, I lose all the resizing, dragging, etc.
<Window x:Class="WpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp2"
WindowStyle="None"
mc:Ignorable="d"
WindowStartupLocation="CenterScreen"
Title="MainWindow" Height="450" Width="600">
<WindowChrome.WindowChrome>
<WindowChrome GlassFrameThickness="1,1,1,1" />
</WindowChrome.WindowChrome>
<Border BorderBrush="Red" BorderThickness="1">
<Button Content="Test" Height="25" Width="75" />
</Border>
</Window>

Zoombox from Xceed WPF Toolkit not working

I am experimenting with the Zoombox control from Xceed, but I am having trouble getting it to respond to mouse wheel or pan events. Nothing happens when I use these inputs. Am I missing something in my code or configuration?
https://github.com/xceedsoftware/wpftoolkit
<Window x:Class="UI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="MainWindow" Height="800" Width="700">
<Grid>
<xctk:Zoombox MinScale="0.5" MaxScale="100" >
<Grid Width="600" Height="400" Background="Yellow">
<Ellipse Fill="Blue" />
</Grid>
</xctk:Zoombox>
</Grid>
</Window>
You have to define DragModifiers and ZoomModifiers. Default values are Ctrl and Shift keys. So use the combination Shift+MouseWheel for zooming and use Ctrl+LeftButton for panning.

Images being stretched in WPF RibbonRadioButton

I've already posted a message about this, but I've lost it! And I can paste code now too...
I have a RibbonRadioButton whose image is being stretched, XAML below (I haven't changed the code-behind from its default). I have checked that the PNG is at 96dpi but the problem remains.
XAML:
<Window x:Class="DashboardTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ribbon:Ribbon x:Name="Ribbon">
<ribbon:RibbonGroup x:Name="LiveStatusGroup"
Header="RibbonGroup Header">
<ribbon:RibbonRadioButton x:Name="Dashboard"
LargeImageSource="images\LiveStatus_Dashboard.png"
HorizontalContentAlignment="Center"
HorizontalAlignment="Center"
VerticalContentAlignment="Center"
VerticalAlignment="Center"
Label="RibbonRadioButton Label"
ToolTip="RibbonRadioButton ToolTip"/>
</ribbon:RibbonGroup>
</ribbon:Ribbon>
</Grid>
</Window>
Can anyone shed light on why this is happening? I am running Windows 7 with text size set to medium (125%).
J

Hide the default resizegrip in wpf

Is it possible to hide the default resize grip in wpf, I have a custom window without handles on the sides and are currently using:
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="100" Width="200" ResizeMode="CanResizeWithGrip">
<Grid></Grid>
</Window>
I know it's possible to just change ResizeMode="CanResize" but this is the only way to resize the window that I can think of.
Yes you can take out the default resize grip from the Window. You need to override the WindowTemplate. Here is how you would do in XAML:
<Window x:Class="MyNamespace.MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None"
ResizeMode="CanResizeWithGrip"
AllowsTransparency="True">
<Window.Template>
<ControlTemplate>
<Border>
</Border>
</ControlTemplate>
</Window.Template>
</Window>
Within the "Border" will go everything that you need to display in the Window (e.g. a TextBox). Then if you want your custom ResizeGrip you can define that as well. Hope this helps.

Categories

Resources