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
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"
I have been working on a project (C# WPF .NET Framework) for a while now and have got a problem and I
have already tried multiple things to try fix the issue when I build it is successful however
when I try to start/run the wpf it shows in Break Mode:
Cannot locate resource 'mainwindow.xaml
(Full: System.IO.IOException: 'Cannot locate resource 'mainwindow.xaml'.')
For my wpf I renamed everything to MainScreen:
<Window x:Class="***************.MainScreen"
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:***************"
mc:Ignorable="d"
Title="MainScreen" Height="450" Width="800"
AllowsTransparency="True" Background="Transparent"
WindowStyle="None" ResizeMode="NoResize" FontSize="20"
>
If any of you need more information please add a comment with what you need.
Also I did the *'s because this project and name will be used officially, sorry and I hope you can understand.
In App.xaml, make sure StartupUri="MainScreen.xaml" is set up correctly.
I want to set the size for UserControl to design my app. But XAML Preview probably ignores the d:DesingHeight and d:DesingWidth properties. I can put the Height and Width properties but is uncomfortable because I will need removing them before running the app.
My XAML code:
<UserControl x:Class="CIevlev.ClinicApp.DesktopClient.ControlDoctorService"
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:CIevlev.ClinicApp.DesktopClient"
xmlns:viewModel="clr-namespace:SIevlev.ClinicApp.Interfaces.ViewModel;assembly=SIevlev.ClinicApp.Interfaces"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>
"d:" works in Visual Studio. I want to work in Visual Studio :(
How can I solve this problem?
I am creating a universal app in Visual Studio 2015. My universal app has a reference to a universal library called UIComponents.
In UIComponents I created a user control:
namespace MyProj.UIComponents {
public sealed partial class MyControl : UserControl
{
public MyControl()
{
this.InitializeComponent();
}
}
}
With the following xaml:
<UserControl
x:Class="MyProj.UIComponents.MyControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyProj.UIComponents"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid>
<Rectangle Fill="White" HorizontalAlignment="Left" Height="280" Stroke="Black" VerticalAlignment="Top" Width="380" Margin="10,10,0,0"/>
<TextBox x:Name="textBox" Margin="20,20,20,20" TextWrapping="Wrap" Text="TextBox"/>
</Grid>
</UserControl>
Inside my app project, which references UIComponents, I do this:
<Page
x:Class="MyProj.App.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyProj.App"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="using:MyProj.UIComponents"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ui:MyControl></ui:MyControl>
</Grid>
</Page>
But when I try to get the designer display the page I get:
The error list shows this:
The name "MyControl" does not exist in the namespace
"using:MyProj.UIComponents".
Funny thing is that the whole solution builds just fine, but the designer is not collaborating.
Attempt using clr-namespace
There are similar questions about this in WPF, so not strictly universal apps, and they are marked as solved on answers where the solution was to use:
xmlns:ui="clr-namespace:MyProj.UIComponents"
Bu that does not work:
Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace
'MyProj.UIComponents' that could not be found.
The error list shows this:
The name "MyControl" does not exist in the namespace "using:MyProj.UIComponents".
In my experience, this could probably be caused by
The UIComponents Library didn't got built.
After building the Library project, VS will add the following codes into YourProject.proj file, which will be detected by VS designer:
<ItemGroup>//The following lines will be added.
<Page Include="MyControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
So, please try building your library project and rereference it in your main project.After reloading, designer should load the contents correctly.
Notes: The architecture(x64,x86) when building your library should be identical to current architecture. (e.g. when you build your library with x86. Designer can't load correctly, when your current architure is x64).
The namespace is wrong, which seems not the main cause here.
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.