WPF Scrollview UserControl - c#

I'm trying to add an ScrollBar for my UserControl, I have a left Menu a Top bar and under the top bar is the Content where I put my UserControl so only the content need to have a ScrollBar.
I did this by Wrapping my the Code in my UserControl in <ScrollView></ScrollView>
Everything is working fine only not the Full hight not, When I set hight to Auto the content is not scrollable anymore... If I set it to 500px it works but this makes no sense why should I make my content 500px I want that the ScrollBar goes with my Windows size and be always so big like my Window.
It could be so easy microsoft (<StackPanel Scrollbar="Auto" />)...
...but why easy...
(Yes I found some Posts here with same problem but no one is resolving my problem)
<UserControl x:Class="mausys.telegram"
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:mausys"
mc:Ignorable="d" Width="Auto" Height="500">
<Grid Background="Aqua">
<ScrollViewer VerticalScrollBarVisibility="auto" >
<StackPanel Grid.Column="0" >
<TextBox x:Name="telegramtextBox" HorizontalAlignment="Left" Height="23" Margin="48,78,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBox x:Name="telegramtextBox1" HorizontalAlignment="Left" Height="23" Margin="48,153,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<Label x:Name="telegramlabel" Content="Phone Number:" HorizontalAlignment="Left" Margin="48,52,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.219,-0.282" Width="106" Height="26"/>
<Label x:Name="telegramlabel1" Content="Verifycation Code:" HorizontalAlignment="Left" Margin="48,122,0,0" VerticalAlignment="Top" RenderTransformOrigin="-0.506,-4.269"/>
<Button x:Name="telegrambutton" Content="Verify" HorizontalAlignment="Left" Margin="173,156,0,0" VerticalAlignment="Top" Width="75" RenderTransformOrigin="-0.234,0.571"/>
<Button x:Name="Telegrambutton1" Content="Login" HorizontalAlignment="Left" Margin="173,78,0,0" VerticalAlignment="Top" Width="75" Click="Phone_Click" />
<Button x:Name="tglogin" Click="tglogin_Click" Content="TG LogIn" HorizontalAlignment="Left" Background="BlanchedAlmond" Width="120" Margin="277,52,323,928" />
<Button x:Name="feedy" Click="feedy_Click" Content="feedy" HorizontalAlignment="Left" Background="BlanchedAlmond" Width="120" Margin="277,13,323,967" />
<Button x:Name="tbrowser" Content="Open Browser" HorizontalAlignment="Left" Background="BlanchedAlmond" Width="120" Margin="277,86,323,894" />
<Label x:Name="telegramlabel2" Content="Telegram Account Login" HorizontalAlignment="Left" FontWeight="Bold" Margin="48,10,0,0" VerticalAlignment="Top"/>
<TabControl x:Name="tabControl" HorizontalAlignment="Left" Height="343" Margin="48,181,0,0" VerticalAlignment="Top" Width="215">
<TabItem Header="TabItem">
<Grid Background="#FFE5E5E5"/>
</TabItem>
<TabItem Header="TabItem">
<Grid Background="#FFE5E5E5"/>
</TabItem>
<ListBox x:Name="listBox" Height="100" Width="100"/>
</TabControl>
<ListView x:Name="listView" HorizontalAlignment="Left" Height="151" Margin="277,122,0,0" VerticalAlignment="Top" Width="134">
<ListView.View>
<GridView>
<GridViewColumn/>
</GridView>
</ListView.View>
</ListView>
<Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="10,529,0,0" VerticalAlignment="Top" Width="300" Height="126"/>
<Button x:Name="button2" Content="Button" HorizontalAlignment="Left" Margin="10,660,0,0" VerticalAlignment="Top" Width="75" Height="330"/>
</StackPanel>
</ScrollViewer>
</Grid>
<Window x:Class="xyz.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:fa="http://schemas.fontawesome.io/icons/"
xmlns:local="clr-namespace:mausys"
xmlns:local1="clr-namespace:mausys.UserControls"
mc:Ignorable="d"
Title="mausys" Height="Auto" Width="1596" WindowStyle="SingleBorderWindow" >
<!--Status and Revisions-->
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="85" />
</WindowChrome.WindowChrome>
<Border>
<DockPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!--Menu Left-->
<!--Hover effect-->
<StackPanel Grid.Column="0" Background="#23282D" >
<Label Foreground="#9EA3A8" FontWeight="Bold" FontSize="18" HorizontalAlignment="Left" Margin="15 0 0 5" >
<StackPanel Orientation="Horizontal">
<Image Source="img/logomausys.png" Width="35" Height="32" />
<TextBlock Text="MAUSYS" />
</StackPanel>
</Label>
<Button Background="#23282D" WindowChrome.IsHitTestVisibleInChrome="True" Foreground="#F1F1F1" FontSize="14" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="Dashboard" Foreground="#9EA3A8" Height="15" Width="15" Margin="10 0 6 0" />
<TextBlock Text="Dashboard" />
</StackPanel>
</Button>
<Button Background="#23282D" Foreground="#F1F1F1" FontSize="14" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="MLink" Foreground="#9EA3A8" Height="15" Width="15" Margin="10 0 6 0" />
<TextBlock Text="MLink" />
</StackPanel>
</Button>
<Button Background="#23282D" Foreground="#F1F1F1" FontSize="14" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="MLink" Foreground="#9EA3A8" Height="15" Width="15" Margin="10 0 6 0" />
<TextBlock Text="MLink" />
</StackPanel>
</Button>
<Button Background="#23282D" Foreground="#F1F1F1" FontSize="14" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="Angellist" Foreground="#9EA3A8" Height="15" Width="15" Margin="10 0 6 0" />
<TextBlock Text="MLink" />
</StackPanel>
</Button>
<Button Background="#23282D" Foreground="#F1F1F1" FontSize="14" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="Anchor" Foreground="#9EA3A8" Height="15" Width="15" Margin="10 0 6 0" />
<TextBlock Text="MLink" />
</StackPanel>
</Button>
<!--SEPARATOR-->
<Separator Background="#9EA3A8" Margin="0 10 0 10 " />
<Button Background="#23282D" Foreground="#F1F1F1" FontSize="14" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="AddressBook" Foreground="#9EA3A8" Height="15" Width="15" Margin="10 0 6 0" />
<TextBlock Text="MLinks" />
</StackPanel>
</Button>
<Button Background="#23282D" Foreground="#F1F1F1" FontSize="14" HorizontalContentAlignment="Left" Padding="10" BorderThickness="0" Height="44" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="CalendarPlusOutline" Foreground="#9EA3A8" Height="15" Width="15" Margin="10 0 6 0" />
<TextBlock Text="MLink" />
</StackPanel>
</Button>
<Label Foreground="#9EA3A8" FontSize="12" HorizontalAlignment="Left" Margin="5 30 0 5" >
<StackPanel Orientation="Horizontal">
<fa:ImageAwesome Icon="ArrowCircleLeft" Foreground="#9EA3A8" Height="15" Margin="10 0 6 0" />
<TextBlock Text="MLink" />
</StackPanel>
</Label>
</StackPanel>
<!--APP Content-->
<StackPanel Grid.Column="1" Background="#F1F1F1" >
<!--Top Bar-->
<Grid VerticalAlignment="Top" Background="#23282D" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" >
<TextBlock Text="hhh" FontWeight="Bold" Foreground="#9EA3A8" Margin="6 0 0 0" />
</StackPanel>
<StackPanel Grid.Column="1" >
</StackPanel>
<StackPanel Height="31" Grid.Column="2" VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right" >
</StackPanel>
</Grid>
<!--Window Controls & Console -->
<Grid VerticalAlignment="Top" Background="#0073AA" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="0" VerticalAlignment="Center" >
<Button Content="ADD NEW" Width="70" Height="50" HorizontalAlignment="Left" Margin="10 0 0 0" />
</StackPanel>
<StackPanel Grid.Column="1" >
</StackPanel>
<StackPanel Grid.Column="2" WindowChrome.IsHitTestVisibleInChrome="True" Height="60" VerticalAlignment="Center" Orientation="Horizontal" HorizontalAlignment="Right" >
<Button fa:Awesome.Content="WindowMinimize" Foreground="#0073AA" Background="White" Content="_" Height="31" Width="31" Margin="3" Name="MinimizeButton" Click="MinimizeButton_Click" />
<Button fa:Awesome.Content="WindowMaximize" Foreground="#0073AA" Background="White" Content="[]" Height="31" Width="31" Margin="3" Name="MaximizeButton" Click="MaximizeButton_Click" />
<Button fa:Awesome.Content="Close" Foreground="#0073AA" Background="White" Content="X" Height="31" Width="31" Margin="3 3 20 3" Name="CloseButton" Click="CloseButton_Click" />
</StackPanel>
</Grid>
<!--Window Controls & Console -->
<Grid VerticalAlignment="Top" Background="Beige">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" VerticalAlignment="Center" >
<!--local:telegram />-->
</StackPanel>
</Grid>
<!--User Controls HERE ARE THE USER CONTROLS-->
<local:telegram />
</StackPanel>
</Grid>
</DockPanel>
</Border>

Related

keydown no longer working after adding a ribbon control to a wpf window

I have a strange problem, I had a WPF (with C# code behind) page with some buttons and some keydown events. Recently I've added a ribbon control to group the buttons and the keydown events aren't working any more.
The strangest thing is that if I add back any of the old buttons (outside of the ribbon) and click on it then the keydown events start working.
Thanks
<Page x:Class="Ab3d.PowerToys.Samples.SceneEditor.SceneEditor"
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:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cameras="clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys"
xmlns:ab3d="clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys"
xmlns:visuals="clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys"
xmlns:local="clr-namespace:Ab3d.PowerToys.Samples.SceneEditor"
mc:Ignorable="d"
d:DesignHeight="550" d:DesignWidth="800"
Title="SceneEditor" KeyDown="MainViewport_KeyDown" PreviewKeyDown="Window_PreviewKeyDown"
ShowsNavigationUI="False" >
<Page.Resources>
<BooleanToVisibilityConverter x:Key="VisibilityOfBool" />
<DiffuseMaterial x:Key="Material1" Brush ="Coral" />
</Page.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Name="OptionsGrid" Grid.Row="0" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- THE RIBBON -->
<ribbon:Ribbon SelectedIndex="0" KeyDown="MainViewport_KeyDown">
<!-- Tab -->
<RibbonTab Header="Model" HorizontalAlignment="Left" Height="88" VerticalAlignment="Top" Width="1000">
<!-- Draw -->
<RibbonGroup Header="Draw" Height="88" Margin="0" VerticalAlignment="Top" Width="280">
<RibbonButton x:Name="Point"
Label="Point"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\PointRo.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="NewLine"
Label="Line"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\NewLine2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewLineButton_Click"/>
<RibbonButton x:Name="Arc"
Label="Arc"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Arc2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Surface"
Label="Surface"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Surface2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Volume"
Label="Volume"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Volume2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<StackPanel>
<RibbonButton x:Name="Clothoid"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Clothoid2.png"
HorizontalAlignment="Left"
Height="20"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="22"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Spline"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Spline2.png"
HorizontalAlignment="Left"
Height="25"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="22"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Ellipse"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Ellipse2.png"
HorizontalAlignment="Left"
Height="24"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="22"
Click="NewPointButton_Click"/>
</StackPanel>
</RibbonGroup>
<!-- Transform -->
<RibbonGroup Header="Transform" Height="88" Margin="0" VerticalAlignment="Top" Width="140">
<StackPanel>
<RibbonButton x:Name="Move"
Label="Move"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Move.png"
HorizontalAlignment="Left"
Height="20"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Copy"
Label="Copy"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Copy3.png"
HorizontalAlignment="Left"
Height="30"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Rotate"
Label="Rotate"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Rotate2.png"
HorizontalAlignment="Left"
Height="20"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
</StackPanel>
<StackPanel>
<RibbonButton x:Name="Mirror"
Label="Mirror"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Mirror.png"
HorizontalAlignment="Left"
Height="20"
Margin="10,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Scale"
Label="Scale"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Scale.png"
HorizontalAlignment="Left"
Height="30"
Margin="10,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Array"
Label="Array"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Array.png"
HorizontalAlignment="Left"
Height="20"
Margin="10,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
</StackPanel>
</RibbonGroup>
<!-- Loads -->
<RibbonGroup Header="Loads" Height="88" Margin="0" VerticalAlignment="Top" Width="160">
<RibbonButton x:Name="Nodal"
Label="Nodal"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\NoadalLoads.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="50"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="UDL"
Label="UDL"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\UDL.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="50"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Face"
Label="Face"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Face.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="45"
Click="NewPointButton_Click"/>
</RibbonGroup>
<RibbonGroup Header="Analysis" Height="88" Margin="0" VerticalAlignment="Top" Width="100"/>
<RibbonGroup Header="Results" Height="88" Margin="0" VerticalAlignment="Top" Width="100"/>
<RibbonGroup Header="View" Height="88" Margin="0" VerticalAlignment="Top" Width="100"/>
</RibbonTab>
<RibbonTab Header="Prop" HorizontalAlignment="Left" Height="88" VerticalAlignment="Top" Width="798"/>
</ribbon:Ribbon>
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="10 0 0 0">
<!-- <StackPanel Orientation="Vertical">
<Button Name="ResetCameraCenterButton" Content="Reset camera" ToolTip="Sets camera TargetPosition to (0,0,0)" VerticalAlignment="Center" Click="ResetCameraCenterButton_Click" Margin="0 0 5 0"/>
<Button Name="FitViewButton" Content="Fit to view" Click="FitViewButton_Click" VerticalAlignment="Center" Margin="0 5 5 0" />
</StackPanel> -->
</StackPanel>
<!-- <StackPanel Grid.Column="1" Orientation="Vertical" Margin="10 0 0 0">
<Button Name="newPoint" Content="Point" ToolTip="New Point" VerticalAlignment="Center" Click="NewPointButton_Click" Margin="0 0 5 0"/>
<Button Name="newLine" Content="Line" ToolTip="New Line (L)" VerticalAlignment="Center" Click="NewLineButton_Click" Margin="0 5 5 0"/>
</StackPanel> -->
</Grid>
<Border Name="ViewportBorder" Grid.Row="1" Background="White"
MouseMove="ViewportBorder_MouseMove" >
<Viewport3D Name="MainViewport">
<ModelVisual3D x:Name="VisualSpace" />
<visuals:WireGridVisual3D x:Name="MainWireGrid"
CenterPosition="0 0 0"
Size="200 200"
WidthCellsCount="25"
HeightCellsCount="25"
LineColor="#555555"
LineThickness="1"
MajorLinesFrequency="5"
MajorLineThickness="2"
MajorLineColor="#333333"
IsVisible="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowWireGrid}" />
<ModelVisual3D x:Name="ObjectsVisual" />
</Viewport3D>
</Border>
<cameras:TargetPositionCamera Name="Camera1" Grid.Row="1"
TargetPosition="0 0 0"
Heading="30" Attitude="-30" Bank="0"
Distance="300"
ShowCameraLight="Always"
TargetViewport3D="{Binding ElementName=MainViewport}"/>
<ab3d:MouseCameraController Name="MouseCameraController1" Grid.Row="1"
ShowRotationCenterMarker="True"
ZoomMode="MousePosition"
RotateCameraConditions="RightMouseButtonPressed"
MoveCameraConditions="MiddleMouseButtonPressed"
EventsSourceElement="{Binding ElementName=ViewportBorder}"
TargetCamera="{Binding ElementName=Camera1}" />
<ab3d:CameraAxisPanel Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Left"
TargetCamera="{Binding ElementName=Camera1}"
Visibility="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowCameraAxis, Converter={StaticResource VisibilityOfBool}}"/>
<ab3d:ViewCubeCameraController Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"
TargetCamera="{Binding ElementName=Camera1}"
Visibility="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowViewCubeCameraController, Converter={StaticResource VisibilityOfBool}}" />
<ab3d:MouseCameraControllerInfo Name="MouseCameraControllerInfo1" Grid.Row="1" Margin="0 5 0 0"
VerticalAlignment="Top" HorizontalAlignment="Right"
MouseCameraController="{Binding ElementName=MouseCameraController1}"
Visibility="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowMouseCameraControllerInfo, Converter={StaticResource VisibilityOfBool}}" />
<!-- Selection canvas -->
<Canvas Name="SelectionOverlayCanvas" Grid.Column="0" IsHitTestVisible="False">
<Rectangle Name="SelectionRectangle" Fill="#555FD3FF" Stroke="#AA5FD3FF" StrokeThickness="1" Visibility="Collapsed" />
</Canvas>
<!-- Point data tooltip -->
<Canvas Name="DataToolTipCanvas" Grid.Column="0" IsHitTestVisible="False">
<Border Name="DataToolTipBorder" BorderThickness="2" BorderBrush="Black" Background="LightGray" Visibility="Collapsed">
<StackPanel Orientation="Vertical">
<TextBlock Text="Coordinates:" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding X, StringFormat={}X:{0:N}}"/>
<TextBlock Text="{Binding Y, StringFormat={} Y:{0:N}}"/>
<TextBlock Text="{Binding Z, StringFormat={} Z:{0:N}}"/>
</StackPanel>
</StackPanel>
</Border>
</Canvas>
</Grid>
</Page>
private void MainViewport_KeyDown(object sender, KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine("KeyDown");
// ESC deselects all
if (e.Key == Key.Escape)
{
for (var i = 0; i < spheres.Count; i++)
{
spheres[i].Material = material;
spheres[i].Radius = originalRadius;
}
for (var i = 0; i < lines.Count; i++)
{
lines[i].LineColor = originalLineColor;
}
DataToolTipBorder.Visibility = Visibility.Collapsed;
this.DataContext = null;
}
The problem has been solved, by:
Loaded="Page_Loaded" Focusable="True"
and
private void Page_Loaded(object sender, RoutedEventArgs e)
{
this.Focus();
}
It seems it was a focus issue.
Thanks.

UWP group has weird behavior during RunTime

I am new to XAML for UWP. So I am trying to make 4 group boxes using .XAML. When I attempt to run the code it stretches the group box that makes the GUI look terrible. What in the .XAML could cause something like this?
During design time it looks like:
When I run the code in the Simulator it looks like:
.XAML Code:
<Grid>
<ComboBox HorizontalAlignment="Center" Margin="0,48,0,0" VerticalAlignment="Top" Height="42" Width="232"/>
<ListView x:Name="DatabaseInfo" Header="Database Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" Margin="212,130,551,276" FontFamily="Tahoma" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="ServerNameDisplay" HorizontalAlignment="Left" Text="Server" Width="115" Height="25" />
<TextBox Name="Server" HorizontalAlignment="Right" Text="" Height="25" Width="115" />
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="DatabaseNameDisplay" HorizontalAlignment="Left" Text="Database" Width="115" Height="25" />
<TextBox Name="Database" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="UserNameDisplay" HorizontalAlignment="Left" Text="UserName" Width="115" Height="25" />
<TextBox Name="UserName" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="PasswordDisplay" HorizontalAlignment="Left" Text="Password" Width="115" Height="25" />
<TextBox Name="Password" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<ListView x:Name="RabbitMQInfo" Header="Rabbit MQ Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" Margin="564,130,199,350" FontFamily="Tahoma" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="RabbitMQUserDisplay" HorizontalAlignment="Left" Text="UserName" Width="115" Height="25" />
<TextBox Name="RabbitMQUser" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="RabbitMQPassDisplay" HorizontalAlignment="Left" Text="Password" Width="115" Height="25" />
<TextBox Name="RabbitMQPass" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<ListView x:Name="MachineInfo" Header="Name Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" Margin="212,398,551,125" FontFamily="Tahoma" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="NameDisplay" HorizontalAlignment="Left" Text="Name" Width="115" Height="25" />
<TextBox Name="Name" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<ListView x:Name="IPAddressInfo" Header="IP Address Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" Margin="564,332,199,156" FontFamily="Tahoma" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="IPAddressDisplay" HorizontalAlignment="Left" Text="IPAddress" Width="115" Height="25" />
<TextBox Name="IPAddress" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal">
<TextBlock Name="PortDisplay" HorizontalAlignment="Left" Text="Port" Width="115" Height="25" />
<TextBox Name="Port" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<Button x:Name="btnSave" Content="Save" Click="btnSave_Click" HorizontalAlignment="Center" Margin="0,539,0,0" VerticalAlignment="Top" Width="100" Height="50"/>
Another question I have about UWP applications is do you have to have something special to run the .exe that gets outputted in the Bin folder? When trying to run the .exe as Admin it just crashes and with an unhandled win32 exception.
When I attempt to run the code it stretches the group box that makes the GUI look terrible. What in the .XAML could cause something like this?
You used Margin property to control your XAML control's position, it will lead to the messy layout you see.
Please see Layout document to learn how to make a good layouts with XAML in UWP.
For example, you could simply use a Grid control to put these controls on different row and column.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="4*"></RowDefinition>
<RowDefinition Height="4*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<ComboBox HorizontalAlignment="Center" Grid.Row="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Height="42" Width="232"/>
<ListView x:Name="DatabaseInfo" Grid.Row="1" Grid.Column="0" Header="Database Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="ServerNameDisplay" HorizontalAlignment="Left" Text="Server" Width="115" Height="25" />
<TextBox Name="Server" HorizontalAlignment="Right" Text="" Height="25" Width="115" />
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="DatabaseNameDisplay" HorizontalAlignment="Left" Text="Database" Width="115" Height="25" />
<TextBox Name="Database" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="UserNameDisplay" HorizontalAlignment="Left" Text="UserName" Width="115" Height="25" />
<TextBox Name="UserName" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="PasswordDisplay" HorizontalAlignment="Left" Text="Password" Width="115" Height="25" />
<TextBox Name="Password" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<ListView x:Name="RabbitMQInfo" Grid.Row="1" Grid.Column="1" Header="Rabbit MQ Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="RabbitMQUserDisplay" HorizontalAlignment="Left" Text="UserName" Width="115" Height="25" />
<TextBox Name="RabbitMQUser" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="RabbitMQPassDisplay" HorizontalAlignment="Left" Text="Password" Width="115" Height="25" />
<TextBox Name="RabbitMQPass" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<ListView x:Name="MachineInfo" Grid.Row="2" Grid.Column="0" Header="Name Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="NameDisplay" HorizontalAlignment="Left" Text="Name" Width="115" Height="25" />
<TextBox Name="Name" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<ListView x:Name="IPAddressInfo" Grid.Row="2" Grid.Column="1" Header="IP Address Info." BorderThickness="2" BorderBrush="Black" SelectionMode="None" FontFamily="Tahoma" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<ListView.HeaderTemplate>
<DataTemplate>
<ListViewHeaderItem Content="{Binding}" Height="40" />
</DataTemplate>
</ListView.HeaderTemplate>
<StackPanel Width="230" Height="30" Orientation="Horizontal" >
<TextBlock Name="IPAddressDisplay" HorizontalAlignment="Left" Text="IPAddress" Width="115" Height="25" />
<TextBox Name="IPAddress" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
<StackPanel Width="230" Height="30" Orientation="Horizontal">
<TextBlock Name="PortDisplay" HorizontalAlignment="Left" Text="Port" Width="115" Height="25" />
<TextBox Name="Port" HorizontalAlignment="Right" Text="" Height="25" Width="115"/>
</StackPanel>
</ListView>
<Button x:Name="btnSave" Content="Save" Grid.Row="3" Grid.ColumnSpan="2" HorizontalAlignment="Center" VerticalAlignment="Center" Width="100" Height="50"/>
</Grid>
Another question I have about UWP applications is do you have to have something special to run the .exe that gets outputted in the Bin folder? When trying to run the .exe as Admin it just crashes and with an unhandled win32 exception.
UWP runs in sandbox, it's different from the classic desktop application. You cannot directly double click the '.exe' file to start it. When you're coding in visual studio, you could press F5 to start it and debug it. If it has been deployed, you could start it from windows 'Start' menu.
Tips: Please do not post multiple question in one post next time.

Button disabled - DialogHost & Calendar

So for some reason I cannot get the button to be enabled. I am using the 2nd to last example within the Pickers usercontrol (MaterialDesignInXamlToolkit
) - https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/master/MainDemo.Wpf/Pickers.xaml
As per image attached this is what I see when run the following code(original):
<StackPanel Orientation="Horizontal" Margin="0 25 0 15" HorizontalAlignment="Center" IsEnabled="True">
<TextBlock Foreground="{DynamicResource MaterialDesignBodyLight}" Text="{Binding Date, StringFormat=d}" VerticalAlignment="Center" FontSize="24" />
<Button Margin="8 0 0 0" Content="..."
IsEnabled="True"
materialDesign:DialogHost.DialogOpenedAttached="CalendarDialogOpenedEventHandler"
materialDesign:DialogHost.DialogClosingAttached="CalendarDialogClosingEventHandler"
Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}">
<Button.CommandParameter>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Calendar x:Name="Calendar" Margin="-1 -4 -1 0" />
<StackPanel Grid.Row="1" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" IsDefault="True" CommandParameter="1" Style="{DynamicResource MaterialDesignFlatButton}">OK</Button>
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" IsCancel="True" CommandParameter="0" Style="{DynamicResource MaterialDesignFlatButton}">CANCEL</Button>
</StackPanel>
</Grid>
</Button.CommandParameter>
</Button>
I did have a look at this similar post but did not win - MaterialDesignXamlToolkit wpf dialoghost buttons are disabled when opened
xaml.cs:
public void CalendarDialogOpenedEventHandler(object sender, DialogOpenedEventArgs eventArgs)
{
Calendar.SelectedDate = ((ClientIntroViewModel)DataContext).Date;
}
public void CalendarDialogClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
{
if (!Equals(eventArgs.Parameter, "1")) return;
if (!Calendar.SelectedDate.HasValue)
{
eventArgs.Cancel();
return;
}
((ClientIntroViewModel)DataContext).Date = Calendar.SelectedDate.Value;
}
Latest XAML:
<StackPanel Orientation="Horizontal" Margin="0 25 0 0" HorizontalAlignment="Center" IsEnabled="True">
<Label Foreground="{DynamicResource MaterialDesignBodyLight}" VerticalAlignment="Center" Margin="0,0,5,0">Birth Date:</Label>
<TextBlock Foreground="{DynamicResource MaterialDesignBodyLight}" Text="{Binding Date, StringFormat=d}" VerticalAlignment="Center" FontSize="24" />
<Button Margin="8 0 0 0" Content="..."
IsEnabled="True"
materialDesign:DialogHost.DialogOpenedAttached="CalendarDialogOpenedEventHandler"
materialDesign:DialogHost.DialogClosingAttached="CalendarDialogClosingEventHandler"
Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"
CommandTarget="{Binding ElementName=PopupAddCustom}">
</Button>
<materialDesign:DialogHost Name="PopupAddCustom" HorizontalAlignment="Center" VerticalAlignment="Center" IsOpen="False" >
<materialDesign:DialogHost.DialogContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Calendar x:Name="Calendar" Margin="-1 -4 -1 0" />
<StackPanel Grid.Row="1" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" IsDefault="True"
CommandParameter="1" Style="{DynamicResource MaterialDesignFlatButton}">OK</Button>
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" IsCancel="True"
CommandParameter="0" Style="{DynamicResource MaterialDesignFlatButton}">CANCEL</Button>
</StackPanel>
</Grid>
</materialDesign:DialogHost.DialogContent>
</materialDesign:DialogHost>
</StackPanel>
You are not setting CommandTarget property on Button which is why it is not enabled.
<Button Margin="8 0 0 0" Content="..."
IsEnabled="True"
Command="{x:Static materialDesign:DialogHost.OpenDialogCommand}"
CommandTarget="{Binding ElementName=PopupAddCustom}">
</Button>
<materialDesign:DialogHost Name="PopupAddCustom" HorizontalAlignment="Center" VerticalAlignment="Center" IsOpen="False"
materialDesign:DialogHost.DialogOpenedCallback="CalendarDialogOpenedEventHandler"
materialDesign:DialogHost.DialogClosingCallback="CalendarDialogClosingEventHandler">
<materialDesign:DialogHost.DialogContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Calendar x:Name="Calendar" Margin="-1 -4 -1 0" />
<StackPanel Grid.Row="1" Margin="8" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" IsDefault="True"
CommandParameter="1" Style="{DynamicResource MaterialDesignFlatButton}">OK</Button>
<Button Command="{x:Static materialDesign:DialogHost.CloseDialogCommand}" IsCancel="True"
CommandParameter="0" Style="{DynamicResource MaterialDesignFlatButton}">CANCEL</Button>
</StackPanel>
</Grid>
</materialDesign:DialogHost.DialogContent>
</materialDesign:DialogHost>

WPF C# Vertical Scrollbar always visible by docking at a DockPanel

I have a problem with my vertical scrollbar.
If I scroll the Content with my horizontal bar, I see the vertical bar at the end of my Scrolling.
First I see this:
After Scrolling I see this:
I am looking for a solution to always see both bars!
Panel structure
Scrollviewer : Horizontical
Dockpanel : Content
Dockpanel : left
Scrollviewer : Vertical
Dockpanel right
Stackpanel : columns....
Code:
<ScrollViewer x:Name="scv_dpn_variable"
CanContentScroll="True"
HorizontalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Disabled"
Height="auto"
Width="auto"
Margin="15,0,0,0">
<StackPanel x:Name="spn_right" VerticalAlignment="Top">
<DockPanel x:Name="dpn_right_header" Width="auto" Height="auto" VerticalAlignment="Stretch">
<Label Content="Jan" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Feb" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Mrz" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Apr" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Mai" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Jun" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Jul" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Aug" Height="50" VerticalAlignment="Top" Width="45" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Sep" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Okt" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Nov" Height="50" VerticalAlignment="Top" Width="45" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Dez" Height="50" VerticalAlignment="Top" Width="40" Foreground="#FFFBF7F7" FontSize="18"/>
<Label Content="Bemerkung" Height="50" VerticalAlignment="Top" Width="300" Foreground="#FFFBF7F7" FontSize="18"/>
</DockPanel>
<ScrollViewer x:Name="scv_content_Vert1"
Height="auto"
MaxHeight="550"
VerticalScrollBarVisibility="Visible"
Width="auto" Margin="0,0,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" ScrollChanged="scv_content_Vert1_ScrollChanged" UseLayoutRounding="False" CanContentScroll="True"
>
<DockPanel x:Name="dpn_right_content" Width="auto" Height="auto" VerticalAlignment="Stretch">
<StackPanel x:Name="spn_col_jan" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_feb" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_mrz" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_apr" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_mai" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_jun" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_jul" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_aug" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_sep" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_okt" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_nov" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_dez" VerticalAlignment="Top" />
<StackPanel x:Name="spn_col_notice" VerticalAlignment="Top" />
</DockPanel>
</ScrollViewer>
</StackPanel>
</ScrollViewer>
the whole code!. Thanks for your help.

<view:Content ...> tags in XAML

I inherited some code where I've seen this construction, which I'm not used to, in several locations:
<view:Content x:Name="TimeFrame" Margin="220,50,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" >
<view:Content.ChildContent>
<view:TimeFrame />
</view:Content.ChildContent>
</view:Content>
Which I must admit seems rather nifty, and thus far works as I want it too. However, then there's this where instead of the <view:TimeFrame />-tag in the center there are a regular control-tags like so:
<view:Content x:Name="SignInControl" Margin="466,317,0,0" HorizontalAlignment="Left" Width="348" Height="344" VerticalAlignment="Top">
<view:Content.ChildContent>
<Grid>
<Border CornerRadius="8,8,0,0" BorderThickness="1" Width="270" Height="300" Background="#666666" Margin="1,0,-1,0" Opacity="0.57" >
<Border.Effect>
<BlurEffect/>
</Border.Effect>
</Border>
<Border CornerRadius="8,8,0,0" BorderThickness="1" Width="270" Height="300" Background="#FFF3F5F4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="15"/>
<RowDefinition Height="100"/>
<RowDefinition Height="25"/>
<RowDefinition Height="40"/>
<RowDefinition Height="40"/>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="ChartWizz" FontFamily="Verdana" FontSize="10" Margin="0,3,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" />
<ToggleButton Style="{StaticResource up_down}" Checked="ToggleButton_Checked" />
<Image Source="Pictures/logo_250.png" Margin="5" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" />
<StackPanel Width="210" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" >
<TextBlock Text="Change User or" Margin="0,0,3,0" FontFamily="Verdana" FontSize="11" />
<Button Style="{StaticResource LinkButton}" Click="CreateNewAccLink_Click" Margin="2, 0, 0, 0">
<TextBlock Text="Create new account" FontFamily="Verdana" FontSize="11" Foreground="Black" TextDecorations="Underline"/>
</Button>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Vertical" HorizontalAlignment="Center" >
<TextBlock Text="Username" FontFamily="Verdana" FontSize="10" Margin="0,0,0,3" HorizontalAlignment="Left" VerticalAlignment="Center" />
<TextBox Width="210" Height="20" HorizontalAlignment="Left" />
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Vertical" HorizontalAlignment="Center" >
<TextBlock Text="Password" FontFamily="Verdana" FontSize="10" Margin="0,4,0,3" HorizontalAlignment="Left" VerticalAlignment="Center" />
<PasswordBox Width="210" Height="20" HorizontalAlignment="Left" />
</StackPanel>
<Grid Grid.Row="5" HorizontalAlignment="Left" >
<Button Style="{StaticResource LinkButton}" Click="ForgotPassLink_Click" Margin="2, 0, 0, 0" HorizontalAlignment="Left">
<TextBlock Text="Forgot your password?" Width="Auto" Foreground="Black" TextDecorations="Underline" FontFamily="Verdana" FontSize="10" Margin="27,5,0,3" HorizontalAlignment="Left" VerticalAlignment="Center" />
</Button>
</Grid>
<StackPanel Grid.Row="7" Width="210" Margin="0,5,0,0" Orientation="Horizontal" HorizontalAlignment="Center" >
<CheckBox Content="Remember me" FontFamily="Verdana" FontSize="10" Margin="0,4,0,3" HorizontalAlignment="Left" VerticalAlignment="Center" />
<Button Width="60" Content="Sign in" Height="23" Margin="55,0,0,0" VerticalAlignment="Center" Click="SiginBtn_Click" />
</StackPanel>
</Grid>
</Border>
</Grid>
</view:Content.ChildContent>
</view:Content>
When I attempted to give the controls here names so that I could access them in code I got the following error:
Cannot set Name attribute value 'txtBox_username' on element 'TextBox'. 'TextBox' is under the scope of element 'Content', which already had a name registered when it was defined in another scope.
I don't know if it's possible to access these members in some other way through the Content scope but if anyone would enlighten me I would be grateful. Either way I'd really like a link to a relevant MSDN page(or other resource) as I can't seem to figure out what to search for in order to learn more about type tags.
Thanks
This behaviour is caused by how UserControls are implemented, see this question for workarounds.

Categories