CCTV c# in WPF Forms exit button

46 Views Asked by At

I'm building an CCTV viewer using this tutorial. I'm trying to add exit and minimize buttons.

First I tried cleating a simple buttons using [Close()] but they hide behind my cameras. Second try was using WindowStyle="SingleBorderWindow", but Transparency breaks it. Any ideas how to do it?

[Here's my main]

 <Window x:Class="CCTVvideosoftwaredemo.VideoStreamWindow"
            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:CCTVvideosoftwaredemo"
            mc:Ignorable="d"
            Loaded="Window_Loaded"
            
            Title="CCTVMonitor" WindowStyle="None" ResizeMode="CanResize"  Height="450" Width="525" Background="Black" WindowState="Normal" Focusable="False" >
    
    
        <Grid Focusable="False">
            
    
                <Grid.RowDefinitions>
    
                <RowDefinition Height="*"/>
                
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
    
    
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
              
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
    
    
            <WindowsFormsHost Grid.Row="0" Grid.Column="0" Margin="5,5,5,6" Name="formsHost1" Focusable="False" />
            <WindowsFormsHost Grid.Row="0" Grid.Column="1" Margin="5,5,2,6" Name="formsHost2" Focusable="False" />
            <WindowsFormsHost Grid.Row="1" Grid.Column="0" Margin="5,4,5,2" Name="formsHost3" Focusable="False" />
            <WindowsFormsHost Grid.Row="1" Grid.Column="1" Margin="5,4,2,2" Name="formsHost4" Focusable="False" />
            
      </Grid>
    </Window>

and [Control window]

<Window x:Class="CCTVvideosoftwaredemo.ControlWindow"
        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:CCTVvideosoftwaredemo"
        mc:Ignorable="d"
        Loaded="Window_Loaded" Closing="Window_Closing"
        Background="Transparent" AllowsTransparency="True" ShowInTaskbar="False"
        Title="CCTV Monitor" ResizeMode="CanResize" WindowStyle ="None"  WindowState="Normal" Height="450" Width="800" FontFamily="Bahnschrift SemiBold Condensed" >
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Grid.Column="0" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Name ="errorLabel1" FontSize="20"  />
        <TextBlock Grid.Row="0" Background="#01000000" Grid.Column="0" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="White" MouseLeftButtonDown="nameLabel1_MouseLeftButtonDown" Name ="nameLabel1" FontSize="24" Text="Camera 1" />

        <TextBlock Grid.Row="0" Grid.Column="1" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Name ="errorLabel2" FontSize="20"  />
        <TextBlock Grid.Row="0" Background="#01000000" Grid.Column="1" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="White" MouseLeftButtonDown="nameLabel1_MouseLeftButtonDown" Name ="nameLabel2" FontSize="24" Text="Camera 2" />

        <TextBlock Grid.Row="1" Grid.Column="0" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Name ="errorLabel3" FontSize="20"  />
        <TextBlock Grid.Row="1" Background="#01000000" Grid.Column="0" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="White" MouseLeftButtonDown="nameLabel1_MouseLeftButtonDown" Name ="nameLabel3" FontSize="24" Text="Camera 3" />

        <TextBlock Grid.Row="1" Grid.Column="1" Margin="5" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="White" Name ="errorLabel4" FontSize="20"  />
        <TextBlock Grid.Row="1" Background="#01000000" Grid.Column="1" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Foreground="White" MouseLeftButtonDown="nameLabel1_MouseLeftButtonDown" Name ="nameLabel4" FontSize="24" Text="Camera 4" />

    </Grid>
</Window>
0

There are 0 best solutions below