Im trying to desing a plugin for a engineering software using their API.
They have predefined UserControl blocks to help people with programming tools for their software.
Im trying to change the colour of foreground and text colour of said UserControl button, but haven't had any luck yet.
My knowledge in WPF or programming as a whole is limited, so haven't tried any fancy stuff.
So my question is: Is there an easy way to change the colours of objects inside UserControl blocks?
<tsd:PluginWindowBase
x:Class="MyFirstPlugin.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:MyFirstPlugin"
xmlns:UIControls="clr-namespace:Tekla.Structures.Dialog.UIControls;assembly=Tekla.Structures.Dialog"
xmlns:dialog="clr-namespace:Tekla.Structures.Dialog;assembly=Tekla.Structures.Dialog"
mc:Ignorable="d"
xmlns:tsd="clr-namespace:Tekla.Structures.Dialog;assembly=Tekla.Structures.Dialog"
Title="{tsd:Loc albl_Title_Plugin}" Height="500"
Width="800"
MinWidth="600"
MinHeight="400">
<Grid Margin="10,10,10,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<UIControls:WpfSaveLoad
HorizontalAlignment="Left"
Margin="0,0,0,0"
VerticalAlignment="Top"
/>
<UIControls:WpfOkApplyModifyGetOnOffCancel
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="0,0,0,0"
Grid.ColumnSpan="2" >
</UIControls:WpfOkApplyModifyGetOnOffCancel>
<Button
Margin="10,53,29,369">
</Button>
</Grid>
<UserControl x:Class="Tekla.Structures.Dialog.UIControls.WpfOkApplyModifyGetOnOffCancel"
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:Tekla.Structures.Dialog.UIControls">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="363*"/>
<ColumnDefinition Width="194*"/>
</Grid.ColumnDefinitions>
<DockPanel HorizontalAlignment="Stretch" LastChildFill="false" VerticalAlignment="Top" Grid.ColumnSpan="2">
<Button Click="ok_Click" x:Name="okButton" Content="albl_OK" HorizontalAlignment="Left" Margin="11"
VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left"/>
<Button Click="apply_Click" x:Name="applyButton" Content="albl_Apply" HorizontalAlignment="Left"
Margin="11" VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left"/>
<Button Click="modify_Click" x:Name="modifyButton" Content="albl_Modify" HorizontalAlignment="Left"
Margin="11" VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left"/>
<Button Click="get_Click" x:Name="getButton" Content="albl_Get" HorizontalAlignment="Left" Margin="11"
VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left"/>
<Button Click="onoff_Click" x:Name="toggleButton" Content="" HorizontalAlignment="Left" Margin="11"
VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left">
<Control.Background>
<ImageBrush ImageSource="Onoff.png"/>
</Control.Background>
</Button>
<Button Click="cancel_Click" x:Name="cancelButton" Content="albl_Cancel" HorizontalAlignment="Left"
Margin="11" VerticalAlignment="Top" Width="70" Height="26" DockPanel.Dock="Right"/>
</DockPanel>
</Grid>
</UserControl>
You can set the the Foreground color on the UserContol itself, but that will not apply to all controls inside.
<UIControls:WpfOkApplyModifyGetOnOffCancel Foreground="Red"/>
For those controls that do not apply it, you can use a relative source binding to refer to Foreground.
<Button x:Name="okButton" Content="albl_OK" HorizontalAlignment="Left" Margin="11"
VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left"
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type local:WpfOkApplyModifyGetOnOffCancel}}}"/>
If you intend to have multiple different foreground colors in your UserControl, like for your buttons specifically, you can always declare custom dependency properties in your control, e.g.:
public partial class WpfOkApplyModifyGetOnOffCancel : UserControl
{
// ...constructor, other code.
public static readonly DependencyProperty ButtonForegroundProperty = DependencyProperty.Register(
nameof(ButtonForeground), typeof(Brush), typeof(WpfOkApplyModifyGetOnOffCancel), new PropertyMetadata(Brushes.Black));
public Brush ButtonForeground
{
get => (Brush)GetValue(ButtonForegroundProperty);
set => SetValue(ButtonForegroundProperty, value);
}
}
Bind the Foreground property of the target control like above using a relative source binding.
<Button x:Name="okButton" Content="albl_OK" HorizontalAlignment="Left" Margin="11"
VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left"
Foreground="{Binding ButtonForeground, RelativeSource={RelativeSource AncestorType={x:Type local:WpfOkApplyModifyGetOnOffCancel}}}"/>
Then you can assign the foreground color for your buttons directly, bind it or create a style.
<local:WpfOkApplyModifyGetOnOffCancel ButtonForeground="Red"/>
An alternative to the RelativeSource bindings above is to assign a name to your UserControl and use an ElementName binding instead, which is less verbose here.
<UserControl x:Class="Tekla.Structures.Dialog.UIControls.WpfOkApplyModifyGetOnOffCancel"
...
x:Name="WpfOkApplyModifyGetOnOffCancelInstance">
<Button x:Name="okButton" Content="albl_OK" HorizontalAlignment="Left" Margin="11"
VerticalAlignment="Top" MinWidth="70" MaxWidth="200" Height="26" DockPanel.Dock="Left"
Foreground="{Binding ButtonForeground, ElementName=WpfOkApplyModifyGetOnOffCancelInstance}"/>
<Button Content="Hello" Foreground="Black"/>
To change the background, use the Background property.
For example:
<Button Content="Hello" Background="Black"/>
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>....
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.
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>
The tag 'CardGUIUserControlWpf' does not exisrt in XML namespace 'clr-namespace:CardGameControls;assembly=CardGameControls'. Line 14 Pos 14
The error occurs in the clas PlayerGUI.xaml .
PlayerGUI is a UserControl. It contains another UserControl named CardGUIUserControlWpf.
I attach the code:
<UserControl x:Class="CardGameControls.PlayerGUI"
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:MyControl="clr-namespace:CardGameControls;assembly=CardGameControls"
mc:Ignorable="d" xmlns:my="clr-namespace:CardGameControls;assembly=CardGameControls">
<Grid Height="152" Width="385">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80*" />
<ColumnDefinition Width="305*" />
</Grid.ColumnDefinitions>
<StackPanel Height="100" HorizontalAlignment="Left" Margin="8,12,0,0" Name="stackPanelPlayer" VerticalAlignment="Top" Width="342" Panel.ZIndex="1" Background="#E6F5EFEF" Grid.ColumnSpan="2" Orientation="Horizontal">
<my:CardGUIUserControlWpf x:Name="cardGUIUserControlWpf1" Loaded="cardGUIUserControlWpf1_Loaded" />
</StackPanel>
<Label Content="Player" Height="28" HorizontalAlignment="Left" Margin="12,121,0,0" Name="labelPlayer" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="60,121,0,0" Name="textBoxPlayer" VerticalAlignment="Top" Width="76" TextChanged="textBoxPlayer_TextChanged" IsReadOnly="True" Grid.ColumnSpan="2" />
<Label Content="Sum" Height="28" HorizontalAlignment="Left" Margin="62,121,0,0" Name="labelSumText" VerticalAlignment="Top" Grid.Column="1" />
<Label Content="Sum" Height="28" HorizontalAlignment="Left" Margin="97,120,0,0" Name="labelSumValue" VerticalAlignment="Top" Grid.Column="1" />
<Button Content="Stand" Height="23" HorizontalAlignment="Left" Margin="207,126,0,0" Name="buttonDraw" VerticalAlignment="Top" Width="63" Click="buttonDraw_Click" Grid.Column="1" />
<Button Content="Draw" Height="23" HorizontalAlignment="Right" Margin="0,125,104,0" Name="buttonStand" VerticalAlignment="Top" Width="55" Click="buttonStand_Click" Grid.Column="1" />
</Grid>
</UserControl>
CardGUIUserControlWpf :
<UserControl x:Class="CardGameControls.CardGUIUserControlWpf"
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"
d:DesignHeight="91" d:DesignWidth="84" Loaded="UserControl_Loaded" Name="cardUserControl">
<Grid Width="79" Height="88">
<Grid.RowDefinitions>
<RowDefinition Height="82*" />
<RowDefinition Height="6*" />
</Grid.RowDefinitions>
<Image Height="41" HorizontalAlignment="Left" Margin="24,23,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="32" ImageFailed="image1_ImageFailed" OpacityMask="#FF001919" Source="Images/Diamond.ico" />
<Label Content="Label" Height="27" HorizontalAlignment="Left" Name="labelValue" VerticalAlignment="Top" Width="39" />
<Label Content="Label" Height="28" HorizontalAlignment="Left" Margin="43,61,0,0" Name="labelValue2" VerticalAlignment="Top" Background="White" Width="38" Grid.RowSpan="2" />
</Grid>
</UserControl>
Try removing assembly part in xmlns. xmlns:my="clr-namespace:CardGameControls
(Old: xmlns:my="clr-namespace:CardGameControls;assembly=CardGameControls)