Following codes are okey.
<DockPanel>
<Canvas>
<Button Name="Button6" Canvas.Left="60" Canvas.Top="10" Height="100" Width="100" Panel.ZIndex="1"/>
<Button Name="Button5" Canvas.Left="60" Canvas.Top="10" Height="100" Width="100" Panel.ZIndex="2"/>
<Button Name="Button4" Canvas.Left="60" Canvas.Top="10" Height="100" Width="100" Panel.ZIndex="3"/>
<Button Name="Button3" Canvas.Left="60" Canvas.Top="10" Height="100" Width="100" Panel.ZIndex="4"/>
<Button Name="Button2" Canvas.Left="60" Canvas.Top="10" Height="100" Width="100" Panel.ZIndex="5"/>
<Button Name="Button1" Canvas.Left="60" Canvas.Top="10" Height="100" Width="100" Panel.ZIndex="6"/>
</Canvas>
</DockPanel>
.
Panel.SetZIndex(Button2, Panel.GetZIndex(Button1) + Panel.GetZIndex(Button3) + Panel.GetZIndex(Button4) + Panel.GetZIndex(Button5) + +Panel.GetZIndex(Button6))
But I want to use more professional code instead of the second code above.
Following coding looks okey. But following code is C#. I need vb.net code.
https://stackoverflow.com/a/6044491
Related
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 am trying to add icon inside small Button but it doesn't enters as desired,
here my xaml:
<Button x:Name="eye_button" BorderBrush="{x:Null}" Margin="234,0,0,0" Height="15" Width="15">
<materialDesign:PackIcon Kind="Eye" Foreground="Black" />
</Button>
Here how it's looks like:
The left squre it's the button, in the right it's the icon
Try this:
<Button x:Name="eye_button" BorderBrush="{x:Null}" Margin="234,0,0,0" HorizontalAlignment="Left">
<materialDesign:PackIcon Kind="Eye" Foreground="Black" Width="15" Height="15" />
</Button>
It should look like this at runtime:
<Button
Width="15"
Height="15"
Padding="0"
HorizontalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Background="Transparent"
BorderThickness="0"
Foreground="Red">
<materialDesign:PackIcon
Width="15"
Height="15"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Foreground="Black"
Kind="ArrowBack" />
</Button>
Make sure you put padding to 0
How to access the Buttons inside the stackpanel(Control Template)?? Means i have to make those buttons as single button object.
<Window.Resources>
<ControlTemplate TargetType="Button" x:Key="temp" x:Name="hotel">
<StackPanel x:Name="service">
<Button Content="1" Width="30" Height="30" Name="tempbtn1"/>
<Button Content="2" Width="30" Height="30" Name="tempbtn2"/>
<Button Content="3" Width="30" Height="30" Name="tempbtn3"/>
<Button Content="4" Width="30" Height="30" Name="tempbtn4"/>
</StackPanel>
</ControlTemplate>
</Window.Resources>
<Grid>
<TextBox x:Name="txttype" TextWrapping="Wrap" Text="Room Type" Width="120" Height="30" Margin="10 0 0 0"/>
<Button x:Name="button" Content="Submit" HorizontalAlignment="Left" Margin="9,0,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
<StackPanel Orientation="Horizontal" x:Name="Deluxe">
<Button x:Name="btn1" Content="1" Width="60" Height="60" Template="{StaticResource temp}"/>
<Button Margin="10 0 0 0" Content="2" x:Name="btn2" Width="60" Height="60" Template="{StaticResource temp}"/>
</StackPanel>
</Grid>
I don't understand the exact requirement of you.But i hope following information will be useful to you.
General syntax to get the elements that are declared inside the control template is:
var template = controlName.Template;
var myControl = (typeofthecontrol)template.FindName("MyControlName",controlName);
In your sample,
var template = btn1.Template;
var myControl = (Button)template.FindName("tempbtn1", MyList);
In this code I added an image before the button text I'd like to have a space between the image and text but the code I have isn't working.
<Button Height="25"
Width="80"
Margin="5,10,5,10"
Command="{Binding PreviewTemplateCommand}">
<StackPanel Orientation="Horizontal" Height="15" Width="63">
<Image Source="/UILibrary;component/Themes/Default/Images/preview.PNG"
Height="15" Width="15" Margin="0,0,0,0" />
<TextBlock >Preview</TextBlock>
</StackPanel>
</Button>
Hi you have to set the left margin of the textblock. Try this:
<StackPanel Orientation="Horizontal" Height="15" Width="63">
<Image Source="..." Height="15" Width="15" Margin="0,0,0,0" />
<TextBlock Margin="25,0,0,0">Preview</TextBlock>
</StackPanel>
originally i have just a pure grid control with buttons, checkboxes and textboxes. I wish to implement a tab control in my application, i added a tab control and added a stack panel for the children. What i see at the output is nothing but blank. Please advice me.. thanks!
example of original code:
<Grid Width="1185" Height="945" Background="Snow">
<Button Height="23" HorizontalAlignment="Right" Margin="0,133,56,0" Name="commonssnamemodifyButton" VerticalAlignment="Top" Visibility="Hidden" Width="67" Click="commonssnamemodifyButton_Click">Modify</Button>
<Button Height="23" HorizontalAlignment="Right" Margin="0,72,56,0" Name="mobilessnamemodifyButton" VerticalAlignment="Top" Width="67" Visibility="Hidden" Click="mobilessnamemodifyButton_Click">Modify</Button>
<Label Margin="588,205,497,0" Name="resultLabel" Visibility="Hidden" Height="23" VerticalAlignment="Top"></Label>
</Grid>
modified code:
<Grid Width="1185" Height="945" Background="Snow">
<TabControl Margin=" 5">
<TabItem Header="Properties">
<StackPanel>
<Button Height="23" HorizontalAlignment="Right" Margin="0,133,56,0" Name="commonssnamemodifyButton" VerticalAlignment="Top" Visibility="Hidden" Width="67" Click="commonssnamemodifyButton_Click">Modify</Button>
<Button Height="23" HorizontalAlignment="Right" Margin="0,72,56,0" Name="mobilessnamemodifyButton" VerticalAlignment="Top" Width="67" Visibility="Hidden" Click="mobilessnamemodifyButton_Click">Modify</Button>
<Label Margin="588,205,497,0" Name="resultLabel" Visibility="Hidden" Height="23" VerticalAlignment="Top"></Label>
</StackPanel>
</TabItem>
<TabItem Header ="Output">
</TabItem>
</TabControl>
</Grid>
Oh i tried it, i placed grid control under TabItem, something like this and it worked:
<TabControl Margin=" 5">
<TabItem Header="Properties">
<Grid Width="1185" Height="945" Background="Snow">
<Button Height="23" HorizontalAlignment="Right" Margin="0,133,56,0" Name="commonssnamemodifyButton" VerticalAlignment="Top" Visibility="Hidden" Width="67" Click="commonssnamemodifyButton_Click">Modify</Button>
<Button Height="23" HorizontalAlignment="Right" Margin="0,72,56,0" Name="mobilessnamemodifyButton" VerticalAlignment="Top" Width="67" Visibility="Hidden" Click="mobilessnamemodifyButton_Click">Modify</Button>
<Label Margin="588,205,497,0" Name="resultLabel" Visibility="Hidden" Height="23" VerticalAlignment="Top"></Label>
</Grid>
</TabItem>
<TabItem Header ="Output">
</TabItem>
</TabControl>