How to customize tool tip window to have arrow in wpf - wpf

How to customize tooltip window to have a corner arrow like shown below in WPF(xaml).
I have my code like below
<Image x:Name="imgInfoTab">
<Image.ToolTip>
<ToolTip Background="WhiteSmoke" HasDropShadow="True"
Cursor="Hand">
<TextBlock Width="250" Height="250"
TextWrapping="WrapWithOverflow"
Cursor="Hand">
</TextBlock>
</ToolTip>
</Image.ToolTip>
</Image>
It looks as below with above code,

Try this:
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="CornflowerBlue">
<Grid.ToolTip>
<ToolTip Placement="MousePoint" HorizontalOffset="50">
<ToolTip.Template>
<ControlTemplate TargetType="ToolTip">
<Grid>
<Path Fill="White" Data="M 0,10 L 40,10 50,0 60,10 100,10 100,60 0,60" />
<TextBlock Text="Hello World!" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</ToolTip.Template>
</ToolTip>
</Grid.ToolTip>
</Grid>
If you want it auto-sizing then you'll need to do a bit more work, but that will get you started.

Related

Set the button on top of the video streaming[WPF]

I use LibVLCSharp.WPF in a WPF application.
I want to put some icons and buttons above the video.
But after the VideoView control has loaded, it overwrite everything.
<Canvas Width="325" Height="182">
<Image Source="/Resource/BgLoading_1.png"
Width="325"
Height="182"
Stretch="Fill"
StretchDirection="Both"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Panel.ZIndex="0"
Visibility="Visible" />
<fa:ImageAwesome Foreground="White"
Icon="Spinner"
Spin="True"
Height="48"
Width="48"
Visibility="{Binding LoadImageStatus}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Canvas.Left="139"
Canvas.Top="67" />
<Image x:Name="imgLeftIcon"
Width="30"
Height="30"
Source="{Binding LeftIconSource}"
Stretch="Fill"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="10,10,10,10"
Visibility="{Binding LeftIconStatus}"
Panel.ZIndex="2" />
<Image x:Name="imgRightIcon"
Width="30"
Height="30"
Source="{Binding RightIconSource}"
Stretch="Fill"
Margin="285,10,10,142"
Visibility="{Binding RightIconStatus}"
Panel.ZIndex="2" />
<!--Video-->
<vlc:VideoView Grid.Row="0"
Height="182"
Width="325"
Visibility="{Binding VideoPlayerStatus}"
Panel.ZIndex="1" />
</Canvas>
RTFM
The controls that must appear on top of the video should be placed as children of the VideoView element.
<Window ...
xmlns:vlc="clr-namespace:LibVLCSharp.WPF;assembly=LibVLCSharp.WPF"
...>
<Grid>
<vlc:VideoView x:Name="VideoView">
<Button x:Name="PlayButton"
Click="PlayButtonOnClick"
Content="Play"
Margin="8"
HorizontalAlignment="Right"
VerticalAlignment="Bottom" />
</vlc:VideoView>
</Grid>
</Window>
Avoid Canvas since they are pretty dumb.
Working example sources based on the manual.
I haven't used vlc, if it covers the icons, I think it should be a window drawn with a separate handle. just like WindowsFormHost. try use Popup control, it can be displayed on top of any control.
<Grid>
<!--video control-->
<Grid Name="video">
<!--Video-->
<vlc:VideoView Grid.Row="0"
Height="182"
Width="325"
Visibility="{Binding VideoPlayerStatus}"
Panel.ZIndex="1" />
</Grid>
<Popup PlacementTarget="{Binding ElementName=video}" Placement="Center">
<Grid>
<Image x:Name="imgLeftIcon"
Width="30"
Height="30"
Source="{Binding LeftIconSource}"
Stretch="Fill"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="10,10,10,10"
Visibility="{Binding LeftIconStatus}"
Panel.ZIndex="2" />
</Grid>
</Popup>
</Grid>

how to draw a certain shape and place it next to a text inside a textbox in wpf

I want used polygone to draw a form inside a button and then put it inside a stackpanel with a text but the result is deceiving...
this is my code:
<Button x:Name="button2" HorizontalAlignment="Left" Margin="27,164,0,0" VerticalAlignment="Top" Height="30" Width="75">
<Grid>
<StackPanel Orientation="Vertical">
<Canvas>
<Polygon
Points="0,-10 16,-10 20,-6 20,10 0,10 0,-10"
Stroke="Black"
StrokeThickness="1"
Fill="#4C87B3"/>
<Polygon
Points="2,-10 14,-10 14,-3 2,-3 2,-10"
Stroke="#d6d6c2"
StrokeThickness="1"
Fill="#d6d6c2"/>
<Polygon
Points="4,-9 6,-9 6,-4 4,-4 4,-9"
Stroke="#4C87B3"
StrokeThickness="1"
Fill="#4C87B3"/>
</Canvas>
<TextBlock Text="Save" FontSize="12" Foreground="White"/>
</StackPanel>
</Grid>
</Button>
the result:
and then in adition to that i want to give this figure some effect like the shadow shown in this picture below:
Since you only want to stack the Polygon elements on top of each other, it is sufficient to add them to a Grid. When wrap this Grid into a Viewbox, the icon will automatically scale, when setting e.g. Viewbox.Width. To prevent the icon from overlapping due to its negative positions, you have to add some Margin to the Grid that hosts the shapes.
To add a drop shadow simply add a DropShadowEffect to the outer Polygon.Effect.
<Button x:Name="button2" HorizontalAlignment="Left" Margin="27,164,0,0" VerticalAlignment="Stretch" Width="75"
Height="30">
<StackPanel>
<Viewbox Width="12" Stretch="Uniform">
<Grid Margin="0,10,0,0">
<Polygon
Points="0,-10 16,-10 20,-6 20,10 0,10 0,-10"
Stroke="Black"
StrokeThickness="1"
Fill="#4C87B3">
<Polygon.Effect>
<DropShadowEffect Opacity="0.9"
ShadowDepth="5"
Direction="315"
Color="Black"
BlurRadius="10" />
</Polygon.Effect>
</Polygon>
<Polygon
Points="2,-10 14,-10 14,-3 2,-3 2,-10"
Stroke="#d6d6c2"
StrokeThickness="1"
Fill="#d6d6c2" />
<Polygon
Points="4,-9 6,-9 6,-4 4,-4 4,-9"
Stroke="#4C87B3"
StrokeThickness="1"
Fill="#4C87B3" />
</Grid>
</Viewbox>
<TextBlock Text="Save" FontSize="12" Foreground="White" HorizontalAlignment="Center" />
</StackPanel>
</Button>

how I put image on progress bar?

i put progress bar but its not look proper
<ProgressBar Height="30" Width="300" VerticalAlignment="Center" BorderThickness="0" HorizontalAlignment="Center" Foreground="#0A8098" BorderBrush="Transparent" Name="pbProcessing" >
<ProgressBar.Background>
<ImageBrush ImageSource="/ClientApplication;component/Images/ProgressBackground.png"/>
</ProgressBar.Background>
<ProgressBar.Clip>
<RectangleGeometry RadiusX="20.5" RadiusY="20.5" Rect="0,0,300,19"/>
</ProgressBar.Clip>
</ProgressBar>
but i shown
Any idea how to put image on progress bar perfrectly? Thanks.
Try this
<ProgressBar Value="30" Height="30" Width="300" VerticalAlignment="Center" BorderThickness="0" HorizontalAlignment="Center" Foreground="#0A8098" BorderBrush="Transparent" Name="pbProcessing" >
<ProgressBar.Template>
<ControlTemplate>
<Grid>
<Image Name="PART_Track" Source="bird1.jpg" Stretch="Fill"/>
<Rectangle Name="PART_Indicator"
Fill="BlanchedAlmond"
HorizontalAlignment="Left"/>
</Grid>
</ControlTemplate>
</ProgressBar.Template>
</ProgressBar>

How do i design a shape (like in picture) in WPF XAML?

i just want to make with WPF using the XAML such a shape :
the shape is in red, kind of box with rectangle like quotation.
can you help ?
thanks alot.
Here's an attempt at something similar to your diagram. Is it of help to you?
<Grid Width="602">
<Path Stroke="Black" StrokeThickness="2" Fill="#FFFFCC" Data="M 0,50 400,50 450,0 500,50 600,50 600,150 0,150 0,50" />
<Grid Margin="0,50,0,0">
<TextBlock Text="Blah blah blah - blah blah?" TextWrapping="Wrap" FontSize="16" FontWeight="Bold" Margin="10" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="10">
<Button Width="100" Content="Yes" />
<Button Width="100" Content="No" Margin="50,0,0,0" />
</StackPanel>
</Grid>
</Grid>

Alignment of Rotated Progress Bar

I'm having some trouble displaying a rotated progress bar. Ideally I would like to have no gap between the progress bar and textblock. Any suggestions?
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<ProgressBar Height="20" Width="430">
<ProgressBar.RenderTransform>
<RotateTransform Angle="-90" />
</ProgressBar.RenderTransform>
</ProgressBar>
<TextBlock Width="100" Height="500" Text="test" />
</StackPanel>
Try LayoutTransofrm instead of RenderTransform:
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<ProgressBar Height="20" Width="430">
<ProgressBar.LayoutTransform>
<RotateTransform Angle="-90" />
</ProgressBar.LayoutTransform>
</ProgressBar>
<TextBlock Width="100" Height="500" Text="test" />
</StackPanel>

Resources