The xaml-editor in VS keeps giving me "Invalid Markup" messg.
I added a class CustomCommands.cs, added Windows.CommandBindings in xaml etc,
but output error in VS is:
[Failure] Could not find file 'c:\users\bart\documents\visual studio
2015\Projects\examentest200\examentest200\CustomCommands.cs'.
While, if i check the file in explorer, it's there.
Thanks in advance
"CustomCommands.cs"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace examentest200
{
public static class CustomCommands
{
public static readonly RoutedUICommand Change = new RoutedUICommand
(
"Change",
"Change",
typeof(CustomCommands),
new InputGestureCollection()
{
new KeyGesture(Key.F6, ModifierKeys.Alt)
}
);
}
}
XAML:
<Window x:Class="examentest200.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:examentest200"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommands.New"
Executed="NewCommand_Executed"
CanExecute="NewCommand_CanExecute"
/>
<CommandBinding Command="local:CustomCommands.Change"
Executed="ChangeCommand_Executed"
CanExecute="ChangeCommand_CanExecute" />
</Window.CommandBindings>
<Grid>
<Button x:Name="addButton" Command="ApplicationCommands.New" Content="Add" HorizontalAlignment="Left" Margin="10,24,0,0" VerticalAlignment="Top" Width="75"/>
<ListBox x:Name="eersteListBox" DisplayMemberPath="Model" SelectedIndex="0" Background="Aquamarine" HorizontalAlignment="Left" Height="100" Margin="110,24,0,0" VerticalAlignment="Top" Width="100"/>
<ComboBox x:Name="eersteComboBox" DisplayMemberPath="Make" SelectedIndex="0" HorizontalAlignment="Left" Margin="239,28,0,0" VerticalAlignment="Top" Width="100"/>
<Label x:Name="eersteLabel" DataContext="{Binding Path=SelectedItem, ElementName=eersteListBox, Mode=OneWay}" Content="{Binding Path=Make}" Background="CornflowerBlue" HorizontalAlignment="Left" Margin="376,28,0,0" VerticalAlignment="Top" Width="102"/>
<Label x:Name="tweedeLabel" DataContext="{Binding Path=SelectedItem, ElementName=eersteListBox, Mode=OneWay}" Content="{Binding Path=Model}" Background="CadetBlue" HorizontalAlignment="Left" Margin="376,70,0,0" VerticalAlignment="Top" Width="102"/>
<Label x:Name="derdeLabel" DataContext="{Binding Path=SelectedItem, ElementName=eersteListBox, Mode=OneWay}" Content="{Binding Path=Year}" Background="Gold" HorizontalAlignment="Left" Margin="376,114,0,0" VerticalAlignment="Top" Width="102" Height="28"/>
<ComboBox x:Name="countryComboBox" SelectedIndex="0" DisplayMemberPath="Land" HorizontalAlignment="Left" Margin="110,187,0,0" VerticalAlignment="Top" Width="120"/>
<Button x:Name="delButton" Content="Del" HorizontalAlignment="Left" Margin="10,70,0,0" VerticalAlignment="Top" Width="75"/>
<Button x:Name="changeButton" Command="local:CustomCommands.Change" Content="Change" HorizontalAlignment="Left" Margin="10,114,0,0" VerticalAlignment="Top" Width="75"/>
<TextBox x:Name="eersteTextBox" Background="LightGray" HorizontalAlignment="Left" Height="23" Margin="376,187,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/>
<TextBox x:Name="tweedeTextBox" Background="LightBlue" HorizontalAlignment="Left" Height="23" Margin="376,220,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/>
<TextBox x:Name="derdeTextBox" Background="LightCyan" HorizontalAlignment="Left" Height="23" Margin="376,254,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/>
<TextBox x:Name="vierdeTextBox" HorizontalAlignment="Left" Height="23" Margin="376,287,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="102"/>
</Grid>
If you get this error:
[Failure] Could not find file 'c:\users\bart\documents\visual studio
2015\Projects\examentest200\examentest200\CustomCommands.cs'.
...it likely indicates that CustomCommands.cs hasn't been compiled yet.
The XAML designer won't see your class until the project is built.
Related
I am trying to design a page in WPF that requires a scroll bar as there is a lot of contet on this particular page. Since there are different types of infomration that need to be inputted, I have put the different parts in different grids. I have then set the ScrollViewer and put all the grids inside this but when I run it it does not work. Here is my code:
<Page x:Class="uniFirstGo.AddStudent"
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:mosque"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="AddStudent">
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid Margin="0,0,0,-751">
<Grid.RowDefinitions>
<RowDefinition Height="593*"/>
<RowDefinition Height="154*"/>
<RowDefinition Height="46*"/>
<RowDefinition Height="44*"/>
</Grid.RowDefinitions>
<Label Name="ChildsDetails" Content="Childs Details" HorizontalAlignment="Left" Height="24" Margin="350,10,0,0" VerticalAlignment="Top" Width="91"/>
<Grid HorizontalAlignment="Left" Height="178" Margin="20,54,0,0" VerticalAlignment="Top" Width="770">
<Label x:Name="ChildsSurname" Content="Childs Surname" HorizontalAlignment="Left" Height="24" Margin="10,14,0,0" VerticalAlignment="Top" Width="97"/>
<TextBox x:Name="childsSurname" HorizontalAlignment="Left" Height="24" Margin="107,14,0,0" VerticalAlignment="Top" Width="145" SpellCheck.IsEnabled="True"/>
<Label x:Name="ChildsFirstName" Content="Childs First Name" HorizontalAlignment="Left" Height="24" Margin="276,14,0,0" VerticalAlignment="Top" Width="105"/>
<TextBox x:Name="childsFirstName" HorizontalAlignment="Left" Height="24" Margin="386,14,0,0" VerticalAlignment="Top" Width="155"/>
<Label Content="Address" HorizontalAlignment="Left" Margin="10,54,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.605,0.288" Width="97"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="107,54,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="468" Grid.ColumnSpan="2"/>
<Label Content="Date of Birth
" HorizontalAlignment="Left" Margin="10,92,0,0" VerticalAlignment="Top" Height="25" Width="83"/>
<DatePicker HorizontalAlignment="Left" Margin="107,93,0,0" VerticalAlignment="Top" Width="130"/>
<Label Content="Postcode" HorizontalAlignment="Left" Margin="600,54,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.368,-0.154"/>
<TextBox x:Name="childsGender_Copy" HorizontalAlignment="Left" Height="24" Margin="663,54,0,0" VerticalAlignment="Top" Width="97"/>
<Label Content="Age" HorizontalAlignment="Left" Margin="10,132,0,0" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="107,132,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="130"/>
<Label Content="Gender
" HorizontalAlignment="Left" Margin="578,10,0,0" VerticalAlignment="Top" Height="26"/>
<CheckBox Content="Male
" HorizontalAlignment="Left" Margin="651,16,0,0" VerticalAlignment="Top"/>
<CheckBox Content="Female" HorizontalAlignment="Left" Margin="702,16,0,0" VerticalAlignment="Top"/>
</Grid>
<Label Content="Parents Details" HorizontalAlignment="Left" Margin="350,249,0,0" VerticalAlignment="Top"/>
<Grid HorizontalAlignment="Left" Height="201" Margin="10,280,0,0" VerticalAlignment="Top" Width="780">
<Label Content="Fathers Full Name
" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="134" Height="28" RenderTransformOrigin="0.5,0.5"></Label>
<Label Content="Mothers Full Name" HorizontalAlignment="Left" Margin="10,46,0,0" VerticalAlignment="Top" Width="120" Height="29"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,15,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="138"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,52,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="138"/>
<Label Content="Fathers Address
" HorizontalAlignment="Left" Margin="10,80,0,0" VerticalAlignment="Top" Width="107" Height="28"/>
<Label Content="Mothers Address
" HorizontalAlignment="Left" Margin="10,113,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.132,-0.154" Width="107" Height="28"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,85,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="640"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,118,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="640"/>
<Label Content="Fathers Phone Number
" HorizontalAlignment="Left" Margin="283,12,0,0" VerticalAlignment="Top" Height="26"/>
<Label Content="Mothers Phone Number
" HorizontalAlignment="Left" Margin="283,46,0,0" VerticalAlignment="Top" Height="26"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="426,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="426,49,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Label Content="Mothers Date of Birth" HorizontalAlignment="Left" Margin="554,48,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.48,0.077"/>
<DatePicker HorizontalAlignment="Left" Margin="679,15,0,0" VerticalAlignment="Top" Width="101"/>
<DatePicker HorizontalAlignment="Left" Margin="679,48,0,0" VerticalAlignment="Top" Width="101"/>
<Label Content="Father Date of Birth
" HorizontalAlignment="Left" Margin="554,16,0,0" VerticalAlignment="Top" Height="25"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="130,153,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="253"/>
<Label Content="Fathers Email" HorizontalAlignment="Left" Margin="10,150,0,0" VerticalAlignment="Top" Width="107"/>
<Label Content="Mothers Email" HorizontalAlignment="Left" Margin="405,150,0,0" VerticalAlignment="Top" Width="107"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="517,153,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="253"/>
</Grid>
<Label Content="Emergency Contact Details
" HorizontalAlignment="Left" Margin="328,486,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.895,-2.308" Height="29"/>
<Grid HorizontalAlignment="Left" Height="82" Margin="10,520,0,0" VerticalAlignment="Top" Width="780" Grid.RowSpan="2">
<Label Content="Surname
" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="88" Height="29"/>
<Label Content="Surname
" HorizontalAlignment="Left" Margin="10,44,0,0" VerticalAlignment="Top" Width="88" Height="29"/>
<Label Content="First Name
" HorizontalAlignment="Left" Margin="258,44,0,0" VerticalAlignment="Top" Width="88" Height="29" RenderTransformOrigin="0.114,0.448"/>
<Label Content="First Name
" HorizontalAlignment="Left" Margin="258,10,0,0" VerticalAlignment="Top" Width="88" Height="29"/>
<Label Content="Contact Number
" HorizontalAlignment="Left" Margin="513,44,0,0" VerticalAlignment="Top" Width="98" Height="29"/>
<Label Content="Contact Number
" HorizontalAlignment="Left" Margin="513,10,0,0" VerticalAlignment="Top" Width="98" Height="29"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="618,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="74,50,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="336,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="74,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="618,44,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="336,50,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="152"/>
</Grid>
<Label Content="Medical, Disability and Special Needs
" HorizontalAlignment="Left" Margin="298,617,0,0" VerticalAlignment="Top" Height="26"/>
<Grid HorizontalAlignment="Left" Height="145" Margin="10,648,0,0" VerticalAlignment="Top" Width="780">
<Label Content="Name of Surgery
" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="34"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="116,12,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="175"/>
<Label Content="Surgery Telephone Number
" HorizontalAlignment="Left" Margin="337,10,0,0" VerticalAlignment="Top" Height="34"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="512,12,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="258"/>
<Label Content="Surgery Address" HorizontalAlignment="Left" Margin="10,44,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.289,-0.038" Width="100" Height="31"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="116,49,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="654"/>
</Grid>
</Grid>
</ScrollViewer>
</Page>
Can someone tell me whats going wrong here and why the scroll bar isnt working please?
Thanks.
I set your page as the Content of my WPF main window, which has dimensions of 300x400. And this is what I get:
As you can see the horizontal scroll bar is visible and working quite fine, but the vertical isn't.
But note that for some reason you've set your Grid.Margin to an unusual -751.
<Grid Margin="0,0,0,-751">
The four numbers in Margin are defined as follows:
<Grid Margin="left, top, right, bottom">
So let's take a simpler example. I have the following two Grid controls, one inside another, inside my main window.
<Window x:Class="StackOverflowWPF.MainWindow"
...
Title="MainWindow" Height="300" Width="400">
<Grid Margin="20" Background="LightSeaGreen">
<Grid Margin="5, 10, 15, 20" Background="LightGoldenrodYellow"/>
</Grid>
</Window>
And the designer is like below:
So the inner grid left is 5 pixels from it's container grid, top is 10 from it's container, etc. You get the drift. But see what happens when I set the bottom to a negative number.
<Grid Margin="20" Background="LightSeaGreen">
<Grid Margin="5, 10, 15, -20" Background="LightGoldenrodYellow"/>
</Grid>
Designer:
You're essentially telling XAML that the inner Grid can be outside the outer grid, which kind of defeats the purpose of a margin to begin with.
Now let's go back to your problem. A scroll bar lets you scroll contents in case content is larger than the container. But by speficying a negative margin, you're saying your grid can go 751 pixels below the bottom, essentially rendering the scroll bar useless.
Instead, look what happens you set the margin to a reasonable 0.
<Grid>
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid Margin="0,0,0,0">
The output:
Just remove the Margin="0,0,0,-751" in the main grid:
<Page x:Class="uniFirstGo.AddStudent"
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:mosque"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="AddStudent">
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid>
<Grid.RowDefinitions>....
I making program in wpf that use database and bind value to datagrid. I have two TabControl, and datagrid exist in second. I want to fill it after window loaded and make first column invisible. But although after fill there are items but no columns before select second tab. Why it so?
This is my xaml code
<Window x:Class="AdminControl.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:AdminControl"
mc:Ignorable="d"
Title="MainWindow" Height="513.5" Width="994" Loaded="MainWindowLoaded">
<Grid>
<TabControl>
<TabItem Header="First">
<Grid>
<TextBox x:Name="Product_BarCode" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Артикул" VerticalAlignment="Top" Width="120" Margin="32,28,0,0"/>
<TextBox x:Name="Product_Name" HorizontalAlignment="Left" TextWrapping="Wrap" Text="Название" Width="120" Margin="185,28,0,191"/>
<TextBox x:Name="Product_Price" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Цена" VerticalAlignment="Top" Width="120" Margin="185,114,0,0"/>
<TextBox x:Name="Product_Keywords" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Ключевые слова" VerticalAlignment="Top" Width="120" Margin="32,114,0,0"/>
<TextBox x:Name="Product_TabTitle" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Заголовок вкладки" VerticalAlignment="Top" Width="120" Margin="823,69,0,0"/>
<TextBox x:Name="Product_Description_Title" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Заголовок Описания" VerticalAlignment="Top" Width="120" Margin="658,69,0,0"/>
<TextBox x:Name="Product_Link" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="ССылка" VerticalAlignment="Top" Width="120" Margin="494,69,0,0"/>
<TextBox x:Name="Product_Length" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Длина" VerticalAlignment="Top" Width="120" Margin="32,69,0,0"/>
<TextBox x:Name="Product_Height" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Высота" VerticalAlignment="Top" Width="120" Margin="823,28,0,0"/>
<TextBox x:Name="Product_Width" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Ширина" VerticalAlignment="Top" Width="120" Margin="658,28,0,0"/>
<TextBox x:Name="Product_Weight" HorizontalAlignment="Left" TextWrapping="Wrap" Text="Вес" Width="120" Margin="494,28,0,433"/>
<TextBox x:Name="Product_Count" HorizontalAlignment="Left" TextWrapping="Wrap" Text="Количество" Width="120" Margin="337,28,0,191"/>
<TextBox x:Name="Product_Image" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Название изображения" VerticalAlignment="Top" Width="152" Margin="337,114,0,0"/>
<TextBox x:Name="Product_Description" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Описание" VerticalAlignment="Top" Width="120" Margin="185,69,0,0"/>
<TextBox x:Name="Product_SearchDescription" HorizontalAlignment="Left" Height="23" TextWrapping="Wrap" Text="Описание Поисковика" VerticalAlignment="Top" Width="120" Margin="337,69,0,0"/>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="134,17,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/>
</Grid>
</TabItem>
<TabItem Header="Second">
<Grid>
<DataGrid x:Name="categoryGrid" HorizontalAlignment="Left" Margin="875,10,0,0" VerticalAlignment="Top" Height="388" Width="91" InitializingNewItem="categoryGridAddRow" IsEnabled="True"/>
<DataGrid x:Name="dataGrid" HorizontalAlignment="Left" VerticalAlignment="Top" Height="464" Width="860" Margin="10,10,0,-22" Grid.Column="0" Initialized="sadfasd"/>
<Button x:Name="button1" Content="Button" Margin="903,422,-2,0" VerticalAlignment="Top" Click="button1_Click"/>
</Grid>
</TabItem>
</TabControl>
</Grid>
I'm starting with a development in WPF and C # I've learned some things since I come from Windows Forms but I've run into a case that is not how to solve, I thank my guide.
I get the following window menu through a call to a user control and paint it in a frame but looks like.
You see the User control is above the additional menu to maximize the form remains the same, you know as I can solve ??
This is the XAML of the main window.
<controls:MetroWindow x:Class="Laboratorio.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:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
mc:Ignorable="d"
Title="Sistema de Control y Gestion de Laboratorio"
Height="650" Width="825"
BorderThickness="0"
GlowBrush="Black"
ResizeMode="CanResizeWithGrip"
WindowTransitionsEnabled="False"
Loaded="MainWindow_OnLoaded"
WindowStartupLocation="CenterScreen">
<!-- Menu -->
<Grid>
<Menu Name="MenuPrincipal">
</Menu>
<Frame Name="Contenido"></Frame>
</Grid>
and this the the user control
<UserControl x:Class="Laboratorio.RegistroEquipo"
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"
Loaded="RegistroEquipo_OnLoaded"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="545">
<Grid>
<GroupBox Header="Registro de Equipo">
<Grid>
<Label x:Name="serialLbl" Content="Serial:" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="serialTxb" HorizontalAlignment="Left" Height="23" Margin="89,11,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
<Label x:Name="descripcionLbl" Content="Descripcion:" HorizontalAlignment="Left" Margin="263,11,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="descripcionTxb" HorizontalAlignment="Left" Height="23" Margin="362,10,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
<Label x:Name="marcaLbl" Content="Marca:" HorizontalAlignment="Left" Margin="10,49,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="marcaCbb" HorizontalAlignment="Left" VerticalAlignment="Top" Width="140" Margin="89,49,0,0"/>
<Label x:Name="claseLbl" Content="Clase:" HorizontalAlignment="Left" Margin="263,49,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="claseTxb" HorizontalAlignment="Left" Height="23" Margin="362,49,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
<CheckBox x:Name="externoChk" Content="Externo" HorizontalAlignment="Left" Margin="10,91,0,0" VerticalAlignment="Top"/>
<CheckBox x:Name="patronchk" Content="Patron" HorizontalAlignment="Left" Margin="171,91,0,0" VerticalAlignment="Top"/>
<Label x:Name="articuloLbl" Content="Articulo:" HorizontalAlignment="Left" Margin="263,87,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="articuloTxb" HorizontalAlignment="Left" Height="23" Margin="362,87,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
<Label x:Name="articuloLbl_Copy1" Content="Responsable:" HorizontalAlignment="Left" Margin="10,127,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="responsableTxb" HorizontalAlignment="Left" Height="23" Margin="89,127,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140"/>
<TextBox x:Name="nombreTxb" HorizontalAlignment="Left" Height="23" Margin="263,127,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="239"/>
<Label x:Name="observacionLbl" Content="Observacion:" HorizontalAlignment="Left" Margin="10,175,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="observacionTxb" HorizontalAlignment="Left" Height="79" Margin="10,223,0,0" TextWrapping="Wrap" AcceptsReturn="True" VerticalAlignment="Top" Width="503"/>
<Button x:Name="registrarBtn" Content="Registrar" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="154,338,0,0" Click="Registrar_OnClick"/>
<Button x:Name="salirBtn" Content="Salir" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="263,338,0,0"/>
</Grid>
</GroupBox>
</Grid>
Turn this;
<!-- Menu -->
<Grid>
<Menu Name="MenuPrincipal">
</Menu>
<Frame Name="Contenido"></Frame>
</Grid>
into this;
<!-- Menu -->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Menu Name="MenuPrincipal"/>
<Frame Grid.Row="1" Name="Contenido"/>
</Grid>
Or just swap Grid for StackPanel whichever you prefer.
It's not your application/xaml, it's a Visual Studio tool used for debugging.
When your application is running, go back to Visual Studio, go to the Live Visual Tree, and you can turn off "Show runtime tools in application" (the first button in the toolbar)
In Windows 10 Universal app development the ScrollViewer causes App crashes. In the Windows dev Center this was also mentioned but not solved (https://social.msdn.microsoft.com/Forums/windowsapps/en-US/a737f407-d59f-4b10-a7d0-de9ead6d4f5f/uwpscrollviewer-occasional-crash?forum=wpdevelop).
Now my Problem:
I put a second grid on the Standard one of the xaml file. Then I added the ScrollViewer to this grid. After that i put another grid on the scrollviewer and then i added some Buttons to this grid. When scrolling the app crashes very often.
Do you have any idea how to fix that or how it can be done different?
Here the Code:
<Page
x:Class="ProjectMoralsKite.Datenbank"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ProjectMoralsKite"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="grid">
<Grid.Background>
<ImageBrush Stretch="Fill"/>
</Grid.Background>
<Grid HorizontalAlignment="Left" Height="529" Margin="10,10,0,0" VerticalAlignment="Top" Width="340" BorderThickness="0,-1,0,0" Background="White" Opacity="0.6"/>
<TextBlock x:Name="textBlock" TextAlignment="Center" HorizontalAlignment="Left" Margin="6,70,0,0" TextWrapping="Wrap" Text="Verwaltung" VerticalAlignment="Top" Width="340" FontSize="29.333"/>
<Button x:Name="button" Content="Zurück" HorizontalAlignment="Left" Margin="10,507,0,0" VerticalAlignment="Top" Width="150" Click="button_Click"/>
<ScrollViewer HorizontalAlignment="Left" Height="380" Margin="10,109,0,0" VerticalAlignment="Top" Width="340">
<Grid HorizontalAlignment="Left" Height="655" VerticalAlignment="Top" Width="340">
<Button x:Name="button1" Content="Plan" HorizontalAlignment="Left" Margin="0,24,0,0" VerticalAlignment="Top" Height="54" Width="340"/>
<Button x:Name="button1_Copy" Content="Kunden" HorizontalAlignment="Left" Margin="0,83,0,0" VerticalAlignment="Top" Height="54" Width="340" Click="button1_Copy_Click"/>
<Button x:Name="button1_Copy1" Content="Baustellen" HorizontalAlignment="Left" Margin="0,142,0,0" VerticalAlignment="Top" Height="54" Width="340" Click="button1_Copy1_Click"/>
<Button x:Name="button1_Copy2" Content="Aufträge" HorizontalAlignment="Left" Margin="0,201,0,0" VerticalAlignment="Top" Height="54" Width="340" Background="#33000000" Click="button1_Copy2_Click"/>
<Button x:Name="button1_Copy3" Content="Zuweisung" HorizontalAlignment="Left" Margin="0,260,0,0" VerticalAlignment="Top" Height="54" Width="340" Background="#33FF0000"/>
<Button x:Name="button1_Copy4" Content="Rechteverwaltung" HorizontalAlignment="Left" Margin="0,319,0,0" VerticalAlignment="Top" Height="54" Width="340" Background="#33FF0000"/>
</Grid>
</ScrollViewer>
</Grid>
</Page>
I have seen many questions on the same topic here, and tried almost all solutions recommended, But still not getting it cleared. So please kindly let me know any new updates on this.
<UserControl x:Class="ClinicManagement_Forms.ClinicDetails"
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:view="clr-namespace:ClinicManagement_Forms"
mc:Ignorable="d" Background="White" HorizontalAlignment="Center" VerticalAlignment="Center" Width="875" Height="474">
<UserControl.DataContext>
<view:ClinicRegistrationViewModel/>
</UserControl.DataContext>
<Grid>
<Grid.Resources>
<ControlTemplate x:Key="LeftErrorTemplate">
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding AdornedElement.(Validation.Errors).[0].ErrorContent, ElementName=ErrorAdorner}" Background="LightCoral" Foreground="White" VerticalAlignment="Center"/>
<AdornedElementPlaceholder x:Name="ErrorAdorner">
<Border BorderBrush="LightCoral" BorderThickness="1" />
</AdornedElementPlaceholder>
</StackPanel>
</ControlTemplate>
</Grid.Resources>
<TextBlock HorizontalAlignment="Left" Margin="2,0,0,444" TextWrapping="Wrap" Text="Clinic Registration" VerticalAlignment="Bottom" Width="873" Height="30" TextAlignment="Center" FontSize="18" FontFamily="Showcard Gothic" />
<TextBlock HorizontalAlignment="Left" Margin="91,99,0,0" TextWrapping="Wrap" Text="Clinic Name" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,96,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.ClinicName , UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,136,0,0" TextWrapping="Wrap" Text="Address" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" VerticalScrollBarVisibility="Visible" Height="58" Margin="202,133,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="200" AcceptsReturn="True"/>
<TextBlock HorizontalAlignment="Left" Margin="91,210,0,0" TextWrapping="Wrap" Text="Place" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,207,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.Place, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,250,0,0" TextWrapping="Wrap" Text="Phone No" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,247,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.PhonNo , UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200" IsReadOnlyCaretVisible="True"/>
<TextBlock HorizontalAlignment="Left" Margin="91,289,0,0" TextWrapping="Wrap" Text="User Name" VerticalAlignment="Top"/>
<TextBox HorizontalAlignment="Left" Height="23" Margin="202,286,0,0" TextWrapping="Wrap" Text="{Binding CliicRegistation.UserName, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,329,0,0" TextWrapping="Wrap" Text="Password" VerticalAlignment="Top"/>
<PasswordBox HorizontalAlignment="Left" Height="23" Margin="202,329,0,0" Name="passwordBox1" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200"/>
<TextBlock HorizontalAlignment="Left" Margin="91,367,0,0" TextWrapping="Wrap" Text="Confirm Password" VerticalAlignment="Top"/>
<PasswordBox HorizontalAlignment="Left" Height="23" Margin="202,367,0,0" PasswordChar="{Binding CliicRegistation.ConformPassword, Mode=TwoWay ,UpdateSourceTrigger=PropertyChanged}" Validation.ErrorTemplate="{StaticResource LeftErrorTemplate}" VerticalAlignment="Top" Width="200"/>
<Button IsEnabled="{Binding CliicRegistation.AllPropertiesValid}" Content="Save" Command="{Binding SaveCommand}" HorizontalAlignment="Left" Margin="202,441,0,0" VerticalAlignment="Top" Width="75"/>
<Button IsEnabled="{Binding CliicRegistation.AllPropertiesValid}" Content="Delete" HorizontalAlignment="Left" Margin="299,441,0,0" VerticalAlignment="Top" Width="75"/>
<Button Content="Clear" HorizontalAlignment="Left" Margin="397,441,0,0" VerticalAlignment="Top" Width="75"/>
<Image HorizontalAlignment="Left" Height="100" Margin="536,89,0,0" VerticalAlignment="Top" Width="100"/>
<Image HorizontalAlignment="Left" Height="100" Margin="561,89,0,0" VerticalAlignment="Top" Width="148" OpacityMask="#FFD44949"/>
<Button Content="Select" HorizontalAlignment="Left" Margin="559,207,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="5.053,-10.4"/>
<Button Content="Clear" HorizontalAlignment="Left" Margin="647,208,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="5.053,-10.4"/>
</Grid>
It is the code I had tried, when i click on design mode, This error is shown.
Thanks in advance