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"
Related
I'm sorry if this comes off as a rookie question, but I have spent more time on this than I care to admit.
I'm trying to have a video autoplay on the program's startup. The main window preview shows that the video has been found; however, when I start the program I get a white screen. If someone could help me that would be much appreciated. Thank you and have a wonderful day!
Below is the entirety of the program's xaml code. I have tried running it in other builds of visual studios with no success - so I don't think it's vs.
<Window x:Class="SUP.MainWindow"
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:SUP"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<MediaElement Name="VidPlayer" HorizontalAlignment="Left" Height="321" VerticalAlignment="Top" Width="518" Source="Videos\Vid.mp4" LoadedBehavior="Play"></MediaElement>
</Grid>
</Window>
Make sure your video file has Copy To Ouput Directory set to Copy always or Copy if newer.
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 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!
I have the following WPF window definition but the focus/lost focus events are not firing when I click away from the application, any ideas?
<Window x:Class="BevaClient.windowMain"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:l="clr-namespace:BevaClient"
xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
Title="VPN Tool" Height="500" Width="370"
Focusable="True"
WindowStyle="None"
ResizeMode="NoResize"
Topmost="True"
Style="{StaticResource defaultWindow}"
Loaded="Window_Loaded"
GotFocus="Window_GotFocus"
LostFocus="Window_LostFocus">
I have tried setting topmost to false to see if this was the issue but it makes no difference.
Any advice on this issue would be very much appreciated.
Thanks,
David
Hook to Activated and Deactivated events instead.
I can create UserControl and add TextBox very easily in Surface environment. Here is a sample code:
<UserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
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:ScatterViewSizingSample"
mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
<TextBox HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top"/>
</Grid>
</UserControl>
I tried to add SurfaceUserControl and SurfaceTextBox, but I cannot find to add SurfaceUserControl from the menu. I changed UserControl to s:SurfaceUserControl and Texbox to s:SurfaceTextbox as follows:
<s:SurfaceUserControl x:Class="ScatterViewSizingSample.FixedSizeChild"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="http://schemas.microsoft.com/surface/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ScatterViewSizingSample"
mc:Ignorable="d" local:PopupWindow.InitialSizeRequest="300,250"
d:DesignHeight="300" d:DesignWidth="250">
<Grid Background="MediumSeaGreen">
<s:SurfaceTextBox HorizontalAlignment="Left" Name="textBox1"/>
</Grid>
</s:SurfaceUserControl>
But the system shows error that 'the type s:SurfaceWindows does not found'. I added Microsoft.Surface.Presentation and Microsoft.Surface.Presentation.Generic assembly reference. But it still shows error.
How can I fix it? Why the system does not show SurfaceUserControl as UserControl?
An application using Surface controls needs to use SurfaceWindow as it's root visual in order to do all of the custom touch handling. I suspect that since you're trying to convert this you are probably still using a standard Window which is giving you this error.
If you're developing for 2.0, SurfaceUserControl no longer exists, as per MSDN:
The SurfaceUserControl class has been removed in Surface 2.0. The SurfaceUserControl class was needed in Surface 1.0 SP1 to add touch support to user controls. However, touch support has been added to the UserControl class in .NET Framework 4. To convert your code, remove "s:Surface" from the front of "s:SurfaceUserControl", or use the Surface Migration PowerToy.
Source