I have a WPF WebBrowser control in a Window.
I want to remove the default window controls so I set AllowsTransparency="True" and WindowStyle="None".
<Window x:Class="InstallerToolkit.InteractiveDemosWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="870" Width="1110" WindowStyle="None" AllowsTransparency="True" WindowStartupLocation="CenterScreen">
<Grid>
<WebBrowser Name="WebBrowser" HorizontalAlignment="Left" Height="795" Margin="10,35,0,0" VerticalAlignment="Top" Width="1082" />
</Grid>
This results in me not being able to see my webbrowser contents. If I remove the AllowsTransparency="True" then I can see by webpage but I now have the default controls which I dont want.
How do I get around this?
If the functionality you are looking for is truly AllowTransparency, you can update to WPF 4.5 where they have added a fix to Airspace issues, read this for more details.
If you are unable to upgrade your version of WPF then you will need to disable resize as others have mentioned.
Adding ResizeMode = NoResize should get you rid of the controls. I should mention that AllowTransparency = True can reduce performance! Depending on the kind of software, try avoinding it!
Related
I will improve my skill to developp in C#. I used to developp in C++ and Python.
I already train my self with consol application and I found the implementation of the POO paradigme very strong.
So I will try to produce UI like I can do in C++ and Python.
I follow this tutoriel : http://avaloniaui.net/docs/advanced-tutorial/
But I haven't the expected result like in the chapter : create-a-modern-window.
My windows buttons close, minimize and maximize are behind the panel. So It's hard to see this buttons. voir image
Of course, if I had Margin on the panel or if I remove panel, buttons is correctly visible.
It seems to me logic, that if I put a panel in front of something, it gives this result.
But the tutorial give nothing more and I check on the github : https://github.com/AvaloniaUI/Avalonia.MusicStore/tree/master/Avalonia.MusicStore and I found no difference with my code.
So do you have an idear of the problem or how to solves them ?
I work on Windows 10 with Avalovia 0.10.0.
My main window :
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:Avalonia.MusicStore.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Avalonia.MusicStore.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="Avalonia.MusicStore"
TransparencyLevelHint="AcrylicBlur"
WindowStartupLocation="CenterScreen"
Background="Transparent"
ExtendClientAreaToDecorationsHint="True">
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<Panel>
<ExperimentalAcrylicBorder IsHitTestVisible="False">
<ExperimentalAcrylicBorder.Material>
<ExperimentalAcrylicMaterial
BackgroundSource="Digger"
TintColor="Black"
TintOpacity="1"
MaterialOpacity="0.65" />
</ExperimentalAcrylicBorder.Material>
</ExperimentalAcrylicBorder>
<Panel Margin="40">
<Button Content="Buy Music" Command="{Binding BuyMusicCommand}" HorizontalAlignment="Right" VerticalAlignment="Top">
<PathIcon Data="{StaticResource store_microsoft_regular}"/>
</Button>
</Panel>
</Panel>
</Window>
And my App.axaml
Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Avalonia.MusicStore"
x:Class="Avalonia.MusicStore.App">
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme Mode="Dark"/>
<StyleInclude Source="avares://Avalonia.MusicStore/Icons.axaml"/>
</Application.Styles>
</Application>
Thank you in advance for your help :)
Unfortunately there was a minor bug in 0.10 release.
Please set on your Window the following property:
ExtendClientAreaChromeHints="PreferSystemChrome"
My WPF App was working well. I then changed background colors for a button, which lies inside a transparent window, saved and compiled/run. Ever since, running my program throws
Windows.Markup.XamlParseException
with additional info
System.Windows.UI.Visibility threw an exception
I was unable to undo changes, and now I cannot solve this,unless I remove the "AllowTransparency = True" line. I need the window to be transparent, how can I fix this?
Here's the code for the troublesome block.
<Window
x:Class="WPF.OverlayButtonField"
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:local="clr-namespace:WPF"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="OverlayButtonField"
Width="175"
Height="139"
AllowsTransparency="True"
Loaded="Window_Loaded"
ShowActivated="False"
ShowInTaskbar="False"
Topmost="True"
Visibility="Visible"
WindowStyle="None">
You neglected to mention the InnerException, which clarifies the problem:
InvalidOperationException: WindowStyle.None is the only valid value for WindowStyle when AllowsTransparency is true.
The problem is that you're touching Visibility before setting WindowStyle to None. In principle, the order of attributes in XML doesn't matter. In XAML, in practice, it may sometimes matter. This is a case where it does.
Put Visibility="Visible" after WindowStyle="None", or put AllowsTransparency="True" after both of them -- or better yet, omit Visibility="Visible" entirely. It's redundant. Visible is the default.
Hi i just recently found out that you can use components from WPF and add into windows form just by creating them and later adding then into the form as element Host
So what i am trying to do is to create a video player using MediaElement and i also know that you can use Direct X or use Windows Media player for this put i want to custom make some controls in this so here is my question
when i try to add a the media element into my windows form it give me this error
here's my code for the mediaelement wpf
<UserControl x:Class="Videoplayer_2._0.MediaPlayer"
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"
xmlns:local="clr-namespace:Videoplayer_2._0"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<MediaElement x:Name="mediaElement" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</Grid>
</UserControl>
So is adding mediaElement just doesn't work or i did something wrong and also i added a WPF slider into the form also just saying because i have no idea if it will affect it or not
You just need to restart Visual Studio I think.
I'm in the process of starting a new project, using ReactiveUI and MahApps.Metro. The first hurdle I've hit is a problem of views not showing in their entirety. I have a Window, and in that Window I have a ViewModelViewHost from the RxUI library. It is a simple container for a nested view-model. The ActiveItem binding is properly binded to the view-model of the User Control, and the Button from the user control is visible on screen.
What I expect to see is a Window with a dark gray background and a button in the middle. What I see is the Window with its default background and a Button in the middle. This is not right. If I remove the button, I see nothing on the Window, only the default background.
It seems the ViewModelViewHost is only showing the actual contents of a UserControl and is disregarding what isn't considered a real Control, such as grids etc.
Has anyone come across this behaviour before?
<mah:MetroWindow x:Class="...MainWindow"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:rx="clr-namespace:ReactiveUI;assembly=ReactiveUI"
WindowStartupLocation="CenterScreen"
ShowTitleBar="False"
ShowCloseButton="False"
ShowMaxRestoreButton="False"
ShowMinButton="False"
Height="768"
Width="1024">
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<rx:ViewModelViewHost ViewModel="{Binding ActiveItem}" />
</Grid>
</mah:MetroWindow>
<UserControl x:Class="...NestedView"
Name="TheUserControl"
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"
TextOptions.TextHintingMode="Auto"
TextOptions.TextRenderingMode="Auto"
d:DesignHeight="768" d:DesignWidth="1024">
<Grid Background="DarkGray">
<Button Width="200" Height="100" />
</Grid>
</UserControl>
This won't be a ReactiveUI problem, just a simple WPF one.
The ViewModelViewHost is centered in your window. While your UserControl has a DesignHeight and DesignWidth set, when it's rendered at runtime it will automatically size itself to the height and width of its content - the Button.
Add VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" to your ViewModelViewHost declaration and remove the other two Alignment attributes (they default to Stretch) and it should stretch its contents to the size of the Window while centering any item that has a fixed size.
I have Popup window where dynamically attaching the UserControl. Here I need to set the focus for first control. If I use:
FocusManager.FocusedElement="{Binding ElementName=txtcode}"
on UserControl the cursor not coming. Could anyone help me to set focus on first element in the UserControl.
Thanks in advance.
I have just needed to do this, but not in a user control, so might not help. what I needed to do is to add the FocusManager bit in the Window tag:
<Window x:Class="xxxxx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" FocusManager.FocusedElement="{Binding ElementName=txtcode}">
And then make sure i correctly named the control:
<TextBox Name="txtcode" Text="" />
Although I'm new to wpf, and haven't worked with user controls yet.