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>
I have a button like so:
<StackPanel Orientation="Vertical" Width="200">
<DockPanel LastChildFill="False">
<Grid Width="81" Background="Blue" DockPanel.Dock="Right" />
<Button Width="120" DockPanel.Dock="Left">
<Grid>
<TextBlock Text="Button" ></TextBlock>
<Canvas Margin="120,0,0,0" >
<TextBlock Text="I want to break free" />
</Canvas>
</Grid>
</Button>
</DockPanel>
</StackPanel>
In this case the canvas content will not get rendered and it's content won't be visible.
If I however change the Grid lengths from 81 to 80 it works.
It will also work in this scenario:
<Grid Width="200">
<Grid Width="81" Background="Blue" DockPanel.Dock="Right" HorizontalAlignment="Right" Grid.Column="1" />
<Button Width="120" HorizontalAlignment="Left">
<Grid>
<TextBlock Text="Button" ></TextBlock>
<Canvas Margin="120,0,0,0" >
<TextBlock Text="I want to break free" />
</Canvas>
</Grid>
</Button>
</Grid>
The Canvas will also work if not inside a button:
<StackPanel Orientation="Vertical" Width="200">
<DockPanel LastChildFill="False" Height="42">
<Grid Width="81" Background="Blue" DockPanel.Dock="Right" />
<Canvas Margin="120,0,0,0" >
<TextBlock Text="I want to break free" />
</Canvas>
</DockPanel>
</StackPanel>
Why is it behaving like that inside a button? How can be this fixed to the wanted behavior of showing the canvas?
I have two stackpanel inside Dock Panel. When the window is resizing the top panel is overlapping the bottom one.
<Grid>
<DockPanel DockPanel.Dock="Left" LastChildFill="True" Width="{Binding ActualWidth, ElementName=characterLength}">
<!-- Batch information panel: Top -->
<ScrollViewer DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="6,0,0,0">
<StackPanel Orientation="Vertical" Margin="6,0,0,6" >
<TextBlock x:Name="ReadOnlyNoBatchesTextBlock"
DockPanel.Dock="Top"
Text="no batch"
FontSize="19" HorizontalAlignment="left" AutomationProperties.AutomationId="DipIn_BatchReviewView_NoBatches_Text"
FontWeight="Bold"
/>
<TextBlock HorizontalAlignment="Left" FontSize="19" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchNumber_Text" />
<TextBlock Text="status" HorizontalAlignment="Left" Margin="0,6,0,0" FontSize="16" FontWeight="Bold"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmissionStatus_Text">
</TextBlock>
<TextBlock Text="submitted" FontSize="14" HorizontalAlignment="Left"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedAt_Text">
</TextBlock>
<TextBlock Text="qeqweq" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedBy_Text" />
<TextBlock Text="ertert" FontSize="16" HorizontalAlignment="Left" Margin="0,6,0,0" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressed_Text">
</TextBlock>
<TextBlock Text="dsdfgfdg" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressedAt_Text" >
</TextBlock>
<!-- Must be last item in the stack panel otherwise you get a vertical gap-->
<TextBlock Grid.Column="0" x:Name="characterLength" Text="abcdefg" HorizontalAlignment="Left" Visibility="Hidden" FontWeight="Bold" FontSize="14" />
</StackPanel>
</ScrollViewer>
<!-- Button panel: Bottom -->
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SetMarkerStandardised_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3"
AutomationProperties.AutomationId="DipIn_BatchReviewView_AllocateNextStandardisationBatch_Button" />
<!-- Content, Automation Id & Command is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_AutoProgressBatches_Button" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchListFilter_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SubmitBatch_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_StartStop_Marker_Button">
<TextBlock FontSize="14" Text="a" />
</Button>
</StackPanel>
</DockPanel>
</Grid>
I need that when window is resizing bottom panel should always be visible and top panel will get scroll bar.
I have tried many ways but still getting the same issue from this code the top one will get the scroll bar but only when the bottom one will go invisible
<Grid>
<DockPanel>
<!--<ScrollViewer DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="6,0,0,0">-->
<StackPanel Orientation="Vertical" Margin="6,0,0,6" >
<TextBlock x:Name="ReadOnlyNoBatchesTextBlock"
DockPanel.Dock="Top"
Text="no batch"
FontSize="19" HorizontalAlignment="left" AutomationProperties.AutomationId="DipIn_BatchReviewView_NoBatches_Text"
FontWeight="Bold"
/>
<TextBlock HorizontalAlignment="Left" FontSize="19" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchNumber_Text" />
<TextBlock Text="status" HorizontalAlignment="Left" Margin="0,6,0,0" FontSize="16" FontWeight="Bold"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmissionStatus_Text">
</TextBlock>
<TextBlock Text="submitted" FontSize="14" HorizontalAlignment="Left"
AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedAt_Text">
</TextBlock>
<TextBlock Text="qeqweq" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchSubmittedBy_Text" />
<TextBlock Text="ertert" FontSize="16" HorizontalAlignment="Left" Margin="0,6,0,0" FontWeight="Bold" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressed_Text">
</TextBlock>
<TextBlock Text="dsdfgfdg" FontSize="14" HorizontalAlignment="Left" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchProgressedAt_Text" >
</TextBlock>
<!-- Must be last item in the stack panel otherwise you get a vertical gap-->
<TextBlock Grid.Column="0" x:Name="characterLength" Text="abcdefg" HorizontalAlignment="Left" Visibility="Hidden" FontWeight="Bold" FontSize="14" />
</StackPanel>
<!--</ScrollViewer>-->
<!-- Button panel: Bottom -->
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SetMarkerStandardised_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3"
AutomationProperties.AutomationId="DipIn_BatchReviewView_AllocateNextStandardisationBatch_Button" />
<!-- Content, Automation Id & Command is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_AutoProgressBatches_Button" />
<!-- Content is set by a Style Trigger -->
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_BatchListFilter_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,0,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_SubmitBatch_Button" />
<Button Height="40" HorizontalAlignment="Stretch" Margin="0,3,0,3" AutomationProperties.AutomationId="DipIn_BatchReviewView_StartStop_Marker_Button">
<TextBlock FontSize="14" Text="a" />
</Button>
</StackPanel>
</DockPanel>
</Grid>
Avoid using ScrollViewer it will Avoid the Overlapping of the Content .
You could use a Grid with two RowDefinitions:
<DockPanel DockPanel.Dock="Left" LastChildFill="True" Width="{Binding ActualWidth, ElementName=characterLength}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="6,0,0,0">
<StackPanel Orientation="Vertical" Margin="6,0,0,6" >
...
</StackPanel>
</ScrollViewer>
<StackPanel Grid.Row="1" Orientation="Vertical" VerticalAlignment="Bottom">
...
</StackPanel>
</Grid>
</DockPanel>
I have vertical navigation bar. Each button of the navigation has it's own image and text. For now the image has static height set to Height="50"and text has the default value. When I resize the window the buttons grow responsive but the content inside keeps the same size.
This is how it look right now:
https://gyazo.com/48cff48437b66f462dccd23639dd59ac (GIF)
My XAML code:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>
<UniformGrid Background="DodgerBlue" Grid.Column="1" Columns="1">
<Button BorderThickness="0" Background="DodgerBlue">
<StackPanel>
<Image Source="Icons/home-5-xxl.png" Height="50" Margin="0,0,0,10"/>
<TextBlock HorizontalAlignment="Center" Foreground="White" FontWeight="Bold">Home</TextBlock>
</StackPanel>
</Button>
<Button BorderThickness="0" Background="DodgerBlue">
<StackPanel>
<Image Source="Icons/search-3-xxl.png" Height="50" Margin="0,0,0,10"/>
<TextBlock HorizontalAlignment="Center" Foreground="White" FontWeight="Bold">Search</TextBlock>
</StackPanel>
</Button>
<Button BorderThickness="0" Background="DodgerBlue">
<StackPanel>
<Image Source="Icons/twitter-xxl.png" Height="50" Margin="0,0,0,10"/>
<TextBlock HorizontalAlignment="Center" Foreground="White" FontWeight="Bold">Twitter</TextBlock>
</StackPanel>
</Button>
<Button BorderThickness="0" Background="DodgerBlue">
<StackPanel>
<Image Source="Icons/chat-4-xxl.png" Height="50" Margin="0,0,0,10"/>
<TextBlock HorizontalAlignment="Center" Foreground="White" FontWeight="Bold">Chat</TextBlock>
</StackPanel>
</Button>
</UniformGrid>
</Grid>
How could i make content inside the Buttons responsive and grow when the button grows in XAML WPF?
Use Viewbox as shown here.
<Viewbox Stretch="Uniform">
<Button ... />
</Viewbox>
I have the following menu. I am trying to right align the content of the menu.
<Menu Grid.ColumnSpan="3">
<MenuItem Header="Items">
<MenuItem>
<MenuItem.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Item 1" Grid.Column="0" HorizontalAlignment="Stretch" />
<Button Grid.Column="1" Content="E" />
<Button Grid.Column="2" Content="D" />
</Grid>
</MenuItem.Header>
</MenuItem>
<MenuItem>
<MenuItem.Header>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Item 2" Grid.Column="0" HorizontalAlignment="Stretch" />
<Button Grid.Column="1" Content="E" />
<Button Grid.Column="2" Content="D" />
</Grid>
</MenuItem.Header>
</MenuItem>
</MenuItem>
</Menu>
What is displayed is as below:
------------------
Item 1 D E |
------------------
Item 2 D E |
------------------
There is still lot of space left after E.
What I am expecting is:
------------------
Item 1 D E |
------------------
Item 2 D E |
------------------
I want the D and E to be aligned to the right where as the Item 1 and Item 2 are aligned to the left.
I tried playing with HorizontalAlignment with no help to find the answer.
I'm more of a dockpanel type of guy. How about you try:
<MenuItem>
<MenuItem.Header>
<DockPanel LastChildFill="True">
<Button DockPanel.Dock="Right" Content="E" />
<Button DockPanel.Dock="Right" Content="D" />
<TextBlock DockPanel.Dock="Left" Text="Item 1" />
</DockPanel>
</MenuItem.Header>
</MenuItem>
You can use DockPanel instead of Grid for that purpose. Also try to set Width of your menu items explicitly. Like this:
<MenuItem>
<MenuItem.Header>
<DockPanel LastChildFill="False" Width="250">
<TextBlock Text="Item 1" DockPanel.Dock="Left" HorizontalAlignment="Stretch" />
<Button DockPanel.Dock="Right" Content="E" />
<Button DockPanel.Dock="Right" Content="D" />
</DockPanel>
</MenuItem.Header>
</MenuItem>