I'm trying to add a ScrollViewer for TabControl but it seems that it's not working... scrollbars aren't even appearing. I need to set them only in the tab area in a way to be resized when window is maximized.
Is there someone who can help me on this please?
xaml code:
<StackPanel Orientation="Vertical">
<GroupBox x:Name="groupBox" Header="GroupBox">
<Grid>
<StackPanel Orientation="Horizontal">
<Label x:Name="label65" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label66" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label67" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label68" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label69" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
<TabControl>
<TabItem Header="Test" IsEnabled="True">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Horizontal" Height="Auto" Width="Auto">
<GroupBox x:Name="groupBox1" Header="GroupBox 1">
<Grid>
<StackPanel Orientation="Vertical">
<Label x:Name="label" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label1" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label2" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label3" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label4" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label5" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label6" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label7" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label8" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label9" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label10" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label50" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label51" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label52" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label53" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label54" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label55" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label56" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label57" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label58" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label59" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label60" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label61" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label62" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label63" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label64" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox x:Name="groupBox2" Header="GroupBox 2">
<Grid>
<StackPanel Orientation="Vertical">
<Label x:Name="label11" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label12" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label13" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label14" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label15" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label16" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label17" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label18" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label19" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label20" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label21" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox x:Name="groupBox3" Header="GroupBox 3">
<Grid>
<StackPanel Orientation="Vertical">
<Label x:Name="labe22" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label23" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label24" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label25" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label26" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label27" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label28" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label29" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label30" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label31" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label32" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
</StackPanel>
</ScrollViewer>
</TabItem>
</TabControl>
</StackPanel>
result minimized:
result maximized:
Scroll viewer's default behaiviour is showing scrollbars when it is needed (HorizontalScrollBarVisibility=Auto, VerticalScrollBarVisibility=Auto). You can change it to visible if you want to show them allways.
Your scrollviewer doesn't shows them because the height of your stackpanel is auto so it's height is definded by the childrens.
You should fix the stackpanels size (dynamicly if needed) to show scroll bars of your scrollviewer.
There is several ways to do this.
Here is the code which works for me :
c# side :
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
//On sizechanged event of your window, tabcontrol takes the height of the window - group box which occupies the top side of your screen.
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
tcTabs.Height = this.ActualHeight - gbGroup.ActualHeight;
}
}
And the xaml side :
<Window x:Class="test.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:test"
mc:Ignorable="d"
Title="MainWindow" Height="635" Width="856" SizeChanged="Window_SizeChanged">
<Grid>
<StackPanel Orientation="Vertical" Margin="0,0,0,13">
<GroupBox x:Name="gbGroup" Header="GroupBox">
<Grid>
<StackPanel Orientation="Horizontal">
<Label x:Name="label65" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label66" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label67" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label68" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label69" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
<TabControl x:Name="tcTabs" Height="545">
<TabItem Header="Test" IsEnabled="True">
<ScrollViewer x:Name="swScroll" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" Margin="0">
<StackPanel Orientation="Horizontal" Height="Auto" Width="Auto">
<GroupBox x:Name="groupBox1" Header="GroupBox 1">
<Grid>
<StackPanel Orientation="Vertical">
<Label x:Name="label" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label1" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label2" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label3" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label4" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label5" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label6" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label7" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label8" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label9" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label10" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label50" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label51" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label52" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label53" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label54" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label55" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label56" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label57" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label58" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label59" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label60" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label61" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label62" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label63" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label64" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox x:Name="groupBox2" Header="GroupBox 2">
<Grid>
<StackPanel Orientation="Vertical">
<Label x:Name="label11" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label12" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label13" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label14" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label15" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label16" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label17" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label18" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label19" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label20" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label21" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
<GroupBox x:Name="groupBox3" Header="GroupBox 3">
<Grid>
<StackPanel Orientation="Vertical">
<Label x:Name="labe22" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label23" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label24" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label25" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label26" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label27" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label28" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label29" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label30" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label31" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
<Label x:Name="label32" Content="ABCDEFGHIJKLMNOPQRSTUVWXYZ" Margin="10,10,0,0"/>
</StackPanel>
</Grid>
</GroupBox>
</StackPanel>
</ScrollViewer>
</TabItem>
</TabControl>
</StackPanel>
</Grid>
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have been looking over many similar questions on the forum but none have quite got me to where I need to be.
Background.
I am building a simple UI in Visual Studio to perform some simple tasks and then extracting the XAML code into Powershell which is responsible for the 'doing'. This choice is to keep the solution away from code based on customer request.
I am looking to use a list box which contains 3 values. There is a text box that goes with this and based on the item selected in the text box I want it to display a separate phone number.
Now I have tried multiple attacks at this from feeding in an xml file to trying a combo box. I have had it working in VS and compiled as an exe, But when I moved the XAML code to Powershell it failed due to missing missing components.
I assumed it was maybe a limitation of how I am doing it so I tried to simplify and keep it in pure XAML.
I can't seem to find the right combination of list box and text box to define it.
Simple example...
List box contains
London
Manchester
Leeds
When list box item is selected the text box will update with a separate phone number.
I am not looking for code in VS to do this it needs to be purely defined in xaml that can be lifted up and into Powershell.
Code Start
[xml]$xaml = #"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="SAMPLECODE" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Window.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FFAA3D3D" Offset="1"/>
</LinearGradientBrush>
</Window.Background>
<Grid>
<Button Name="FirstSetup" Content="Initiate First Setup" HorizontalAlignment="Left" Margin="651,383,0,0" VerticalAlignment="Top" Width="132" FontWeight="Bold" FontSize="14" Height="28" BorderBrush="#FF070606" Background="#FF933838" Foreground="#FFFCFAFA"/>
<Label Name="HostName" Content="HostName" HorizontalAlignment="Left" Margin="39,27,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="HostNameValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="148,27,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14"/>
<Label Name="UserName" Content="UserName" HorizontalAlignment="Left" Margin="39,83,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="UserNameValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="148,83,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14"/>
<Label Name="OSPlatform" Content="OS Platform" HorizontalAlignment="Left" Margin="492,27,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="OSPlatformValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,27,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="OSRelease" Content="OS Release" HorizontalAlignment="Left" Margin="501,73,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="OSReleaseValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,73,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="UpdateVersion" Content="Update Version" HorizontalAlignment="Left" Margin="471,120,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="UpdateVersionValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,120,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="LocalITDesk" Content="Local IT Desk" HorizontalAlignment="Left" Margin="10,327,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold" RenderTransformOrigin="2.696,-3.142"/>
<Label Name="M365" Content="M365 Version" HorizontalAlignment="Left" Margin="472,178,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="M365Value" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,178,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="165"/>
<ListBox Name="GlobalSDLocations" HorizontalAlignment="Left" Height="29" Margin="10,366,0,0" VerticalAlignment="Top" Width="116" Background="#FFAA3D3D">
<ListBoxItem>London</ListBoxItem>
<ListBoxItem>New York</ListBoxItem>
<ListBoxItem>Singapore</ListBoxItem>
<ListBoxItem>Insert More</ListBoxItem>
</ListBox>
<TextBlock Name="TelNo" HorizontalAlignment="Left" Height="49" Margin="167,207,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="165"/>
</Grid>
</Window>
"#
Code End
Appreciate any pointers
Thanks
My English is not that good and I hope I understood you correctly.
Your design looks really great, I just replaced the list box with a combo box, that fit better. But you are welcome to take your list box again, it works the same way.
Here is a solution that not only consists of xml, but it works that way.
If you want an XMLOnly solution you also need a list in Powershell and Databinding, but at the moment I don't know whether databinding works with Powershell.
Let me know if anything is wrong with my solution
[xml]$xaml = #"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="SAMPLECODE" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Window.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FFAA3D3D" Offset="1"/>
</LinearGradientBrush>
</Window.Background>
<Grid>
<Button Name="FirstSetup" Content="Initiate First Setup" HorizontalAlignment="Left" Margin="651,383,0,0" VerticalAlignment="Top" Width="132" FontWeight="Bold" FontSize="14" Height="28" BorderBrush="#FF070606" Background="#FF933838" Foreground="#FFFCFAFA"/>
<Label Name="HostName" Content="HostName" HorizontalAlignment="Left" Margin="39,27,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="HostNameValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="148,27,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14"/>
<Label Name="UserName" Content="UserName" HorizontalAlignment="Left" Margin="39,83,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="UserNameValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="148,83,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14"/>
<Label Name="OSPlatform" Content="OS Platform" HorizontalAlignment="Left" Margin="492,27,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="OSPlatformValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,27,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="OSRelease" Content="OS Release" HorizontalAlignment="Left" Margin="501,73,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="OSReleaseValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,73,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="UpdateVersion" Content="Update Version" HorizontalAlignment="Left" Margin="471,120,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="UpdateVersionValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,120,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="LocalITDesk" Content="Local IT Desk" HorizontalAlignment="Left" Margin="10,327,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold" RenderTransformOrigin="2.696,-3.142"/>
<Label Name="M365" Content="M365 Version" HorizontalAlignment="Left" Margin="472,178,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="M365Value" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,178,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="165"/>
<ComboBox Name="GlobalSDLocations" HorizontalAlignment="Left" Height="29" Margin="10,366,0,0" VerticalAlignment="Top" Width="116" Background="#FFAA3D3D">
<ComboBoxItem IsSelected="True">London</ComboBoxItem>
<ComboBoxItem>New York</ComboBoxItem>
<ComboBoxItem>Singapore</ComboBoxItem>
<ComboBoxItem>Insert More</ComboBoxItem>
</ComboBox>
<TextBlock Name="TelNo" HorizontalAlignment="Left" Height="49" Margin="167,207,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="165"/>
</Grid>
</Window>
"#
$phoneList = [System.Collections.ArrayList]::new()
$phoneList.Add([pscustomobject]#{Country = "London"; PhoneNr= "09876"});
$phoneList.Add([pscustomobject]#{Country = "New York"; PhoneNr= "123456"});
$phoneList.Add([pscustomobject]#{Country = "Singapore"; PhoneNr= "67543345"});
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
$window = [Windows.Markup.XamlReader]::Load($reader)
$comboBox = $window.FindName("GlobalSDLocations")
$textBlock = $window.FindName("TelNo")
$textBlock.Text = ($phoneList | where Country -eq $comboBox.SelectedItem.Content).PhoneNr
$comboBox.add_SelectionChanged({$textBlock.Text = ($phoneList | where Country -eq $comboBox.SelectedItem.Content).PhoneNr})
$window.ShowDialog()
Best Regards
Here the same thing with Databinding thanx #T-Me
Add-Type -AssemblyName PresentationFramework
[xml]$xaml = #"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Title="SAMPLECODE" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize">
<Window.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="0"/>
<GradientStop Color="#FFAA3D3D" Offset="1"/>
</LinearGradientBrush>
</Window.Background>
<Grid>
<Button Name="FirstSetup" Content="Initiate First Setup" HorizontalAlignment="Left" Margin="651,383,0,0" VerticalAlignment="Top" Width="132" FontWeight="Bold" FontSize="14" Height="28" BorderBrush="#FF070606" Background="#FF933838" Foreground="#FFFCFAFA"/>
<Label Name="HostName" Content="HostName" HorizontalAlignment="Left" Margin="39,27,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="HostNameValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="148,27,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14"/>
<Label Name="UserName" Content="UserName" HorizontalAlignment="Left" Margin="39,83,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="UserNameValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="148,83,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14"/>
<Label Name="OSPlatform" Content="OS Platform" HorizontalAlignment="Left" Margin="492,27,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="OSPlatformValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,27,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="OSRelease" Content="OS Release" HorizontalAlignment="Left" Margin="501,73,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="OSReleaseValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,73,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="UpdateVersion" Content="Update Version" HorizontalAlignment="Left" Margin="471,120,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="UpdateVersionValue" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,120,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="187"/>
<Label Name="LocalITDesk" Content="Local IT Desk" HorizontalAlignment="Left" Margin="10,327,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold" RenderTransformOrigin="2.696,-3.142"/>
<Label Name="M365" Content="M365 Version" HorizontalAlignment="Left" Margin="472,178,0,0" VerticalAlignment="Top" Foreground="#FFFEFBFB" FontSize="14" FontWeight="Bold"/>
<Label Name="M365Value" Content="Collecting Data" HorizontalAlignment="Left" Margin="596,178,0,0" VerticalAlignment="Top" Foreground="#FFF7F5F5" FontSize="14" Width="165"/>
<ComboBox Name="GlobalSDLocations" HorizontalAlignment="Left" Height="29" Margin="10,366,0,0" VerticalAlignment="Top" Width="116" Background="#FFAA3D3D">
</ComboBox>
<TextBlock Name="TelNo" HorizontalAlignment="Left" Height="49" Margin="167,207,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="165"/>
</Grid>
</Window>
"#
$phoneList = [System.Collections.ArrayList]::new()
$phoneList.Add([pscustomobject]#{Country = "London"; PhoneNr= "09876"});
$phoneList.Add([pscustomobject]#{Country = "New York"; PhoneNr= "123456"});
$phoneList.Add([pscustomobject]#{Country = "Singapore"; PhoneNr= "67543345"});
$phoneList.Add([pscustomobject]#{Country = "Germany"; PhoneNr= "4949494949"});
$reader = (New-Object System.Xml.XmlNodeReader $xaml)
$window = [Windows.Markup.XamlReader]::Load($reader)
$comboBox = $window.FindName("GlobalSDLocations")
$DataContext = New-Object System.Collections.ObjectModel.ObservableCollection[Object]
$DataContext.Add($phoneList.Country)
$comboBox.DataContext = $DataContext
# Create and set a binding on the textbox object
$Binding = New-Object System.Windows.Data.Binding
$Binding.Path = "[0]"
$Binding.Mode = [System.Windows.Data.BindingMode]::OneWay
[void][System.Windows.Data.BindingOperations]::SetBinding($comboBox,[System.Windows.Controls.ComboBox]::ItemsSourceProperty,$Binding)
$textBlock = $window.FindName("TelNo")
$textBlock.Text = ($phoneList | where Country -eq $comboBox.SelectedItem).PhoneNr
$comboBox.add_SelectionChanged({$textBlock.Text = ($phoneList | where Country -eq $comboBox.SelectedItem).PhoneNr})
$comboBox.SelectedIndex = 0
$window.ShowDialog()
Best Regards
Click Here to View ImageI am implementing Drag& Drop in wpf. I want when i dragged ListBoxItem From one Listbox to another. that listboxitem should be visible while dragging.Do i missing Something ?
XAML
<Grid x:Name="MainGrid" Width="{Binding ElementName=ProjectWindow,Path=ActualWidth}" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="19*" />
<ColumnDefinition Width="283*" />
<ColumnDefinition Width="59*" />
<ColumnDefinition Width="19*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="7*" />
<RowDefinition Height="83*" />
</Grid.RowDefinitions>
<Canvas Grid.Row="0" >
<Label Content="TM" FontSize="14" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="118" Canvas.Top="-4"></Label>
<Label Content="smart" FontSize="26" Foreground="White" FontFamily="segoe_uilight"></Label>
<Label Content="Project" FontSize="26" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="64" FontWeight="Bold"></Label>
<TextBlock Canvas.Left="164" Canvas.Top="15" Background="Black">
<Label Background="Black" Content="From" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="164" Canvas.Top="15" ></Label>
<DatePicker x:Name="StartDate" Width="100" Background="Black" Canvas.Left="204" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="Till" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<DatePicker x:Name="EndDate" Width="100" Background="Black" Canvas.Left="344" Canvas.Top="15"></DatePicker>
<Label Background="Black" Content="My Activities" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<CheckBox x:Name="ChckBoxMyActivities" Click="ChckBoxMyActivities_Click_1" Background="Black" Margin="0,0,0,5" Width="20"></CheckBox>
<Label Background="Black" Content="Project Component" FontSize="12" Foreground="White" FontFamily="segoe_uilight" Canvas.Left="315" Canvas.Top="15" ></Label>
<ComboBox x:Name="ComboBoxSubProjects" SelectionChanged="ComboBoxSubProjects_SelectionChanged_1" Background="Black" Margin="0,0,0,5" Width="100" ></ComboBox>
</TextBlock>
<Expander HorizontalAlignment="Right" FlowDirection="RightToLeft" Foreground="White" FontFamily="segoe_uilight" Width="200px" Canvas.Top="1" Canvas.Right="200" Canvas.Left="{Binding Source={x:Static SystemParameters.PrimaryScreenWidth}}" BorderBrush="#FF0A0909" BorderThickness="1,1,1,2" Background="#BF080707" Panel.ZIndex="99999">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Canvas Height="22" Width="172px" VerticalAlignment="Bottom">
<Label x:Name="LoginUserName" Margin="0px 0 0 0" HorizontalAlignment="Left" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0"></Label>
<Image Source="img\icons\dropdown_user.png" Height="20px" Width="20px" RenderTransformOrigin="2.75,0.8" Canvas.Left="117" />
</Canvas>
</StackPanel>
</Expander.Header>
<!--<Expander.Content>
<TextBox Text="LoginUserName"></TextBox>
</Expander.Content>-->
<StackPanel Margin="10,4,0,0" >
<StackPanel Orientation="Horizontal">
<Label x:Name="lblSettings" Margin="49px 0 31px 0" HorizontalAlignment="Left" Content="Settings" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" RenderTransformOrigin="2.019,0.625">
</Label>
<Image Source="img\icons\setting.png" Height="20px" Width="20px" />
</StackPanel>
<!--<Label Margin="4" Content="Logout" />-->
<!--<Button x:Name="btnLogout" Margin="4" Content="Logout" Click="btnLogout_Click_1"></Button>-->
<StackPanel Orientation="Horizontal">
<Label x:Name="btnLogout" HorizontalAlignment="Left" Margin="54px 0 31px 0" Content="Logout" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0">
</Label>
<Image Source="img\icons\logout.png" Height="20px" Width="20px" />
</StackPanel>
</StackPanel>
</Expander>
</Canvas>
<Canvas Grid.Column="0" Grid.Row="1" Background="Orange">
<StackPanel Canvas.Left="10" Background="Gray" Width="60" >
<Image Source="img\icons\information.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="45" Background="Gray" Width="60" >
<Image Source="img\icons\Scheme.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Schema" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="10" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\Tavala.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Tavla" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
<Canvas x:Name="gd" Grid.Column="1" Grid.Row="1" Panel.ZIndex="-1" Background="Orange">
<Grid Width="{Binding ElementName=gd, Path=ActualWidth}" Panel.ZIndex="-1">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<Canvas Grid.Column="1" Grid.Row="0" >
<Canvas x:Name="MainCanvas" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBoxItem>
<ListBox Loaded="icTodoList_Loaded_1" Background="Azure" SelectionChanged="icTodoList_SelectionChanged_1" Name="icTodoList" Height="50" Width="{Binding ElementName=gd,Path=ActualWidth}" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="Phases" BorderThickness="0">
<ListBoxItem>
<Canvas x:Name="PhaseCanvas" Height="20" Width="200" Margin="0,0,20,20" >
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="txtPhaseID" TextAlignment="Center" FontWeight="Light" HorizontalAlignment="Center" FontSize="16" Foreground="Black" FontFamily="segoe_uilight" Text="{Binding PhaseTitle}" Height="20" Width="140" />
<Image Margin="20,0,0,0" Tag="{Binding PhaseID}" Source="img\icons\add_btn.png" Width="20" Height="15" MouseUp="Image_MouseUp_1"></Image>
<!--<TextBlock HorizontalAlignment="Left" FontFamily="segoe_uilight" FontStyle="Italic" Text="{Binding UserName}" Height="20" Width="180" />
<TextBlock TextWrapping="Wrap" HorizontalAlignment="Left" FontFamily="segoe_uilight" Text="{Binding ThreadDescription}" Height="45" Width="200" />-->
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
<ListBoxItem>
<ListBox Loaded="ActivityListBox_Loaded_1" Background="Orange" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Width="{Binding ElementName=gd,Path=ActualWidth}" BorderThickness="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox x:Name="InnerActivityListBox" Tag="{Binding PhaseID}" Width="225" Height="{Binding ElementName=gd,Path=ActualHeight}" Background="Orange" PreviewMouseLeftButtonDown="InnerActivityListBox_PreviewMouseLeftButtonDown_1" AllowDrop="True" DragEnter="InnerActivityListBox_DragEnter_1" Drop="InnerActivityListBox_Drop_1" DragOver="InnerActivityListBox_DragOver_1" BorderThickness="0">
<!--<ListBoxItem>-->
<!--<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>-->
<!--</ListBoxItem>-->
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ListBoxItem>
</ListBox>
<!--<ListBox Loaded="ActivityListBox_Loaded_1" Name="ActivityListBox" Height="{Binding ElementName=gd,Path=ActualHeight}" Canvas.Top="100" Width="{Binding ElementName=gd,Path=ActualWidth}" Background="Orange">
<ListBox.ItemTemplate >
<DataTemplate>
<ListBox x:Name="InnerActivityListBox">
<ListBoxItem>
<Canvas x:Name="ActivityCanvas" Width="200" Height="70" Background="White" >
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" FontWeight="Bold" Height="70" Width="10" Background="{Binding ColorDefination}" Margin="0"></TextBlock>
<TextBlock Margin="30,-70,0,0" Text="{Binding ActivityTitle}" FontWeight="Bold" ></TextBlock>
<TextBlock Margin="30,-60,0,0" Text="{Binding ProjectComponentTitle}" ></TextBlock>
<TextBlock Margin="30,-40,0,0" Text="1 Jan-3Mar" ></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" >
<Image Name="imgDesc" MouseUp="imgDesc_MouseUp_1" Source="img/icons/icon.png" Margin="20,50,0,0" Canvas.Left="15" Canvas.Top="50"></Image>
<Image Name="imgComments" MouseUp="imgComments_MouseUp_1" Source="img/icons/icon_1.png" Margin="20,50,0,0" Canvas.Left="45" Canvas.Top="50"></Image>
<Image Name="imgMembers" MouseUp="imgMembers_MouseUp_1" Source="img/icons/icon_2.png" Margin="20,50,0,0" Canvas.Left="75" Canvas.Top="50"></Image>
<Image Name="imglinks" MouseUp="imglinks_MouseUp_1" Source="img/icons/t3.png" Margin="20,50,0,0" Canvas.Left="105" Canvas.Top="50"></Image>
</StackPanel>
</Canvas>
</ListBoxItem>
</ListBox>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>-->
<!--<Canvas Width="200" Height="50" Background="White" Canvas.Left="46" Canvas.Top="10">
<TextBlock FontWeight="Bold" Height="50" Width="10" Canvas.Left="0" Background="Gray"></TextBlock>
<TextBlock Text="Header Style" FontWeight="Bold" Canvas.Top="2" Canvas.Left="15"></TextBlock>
<TextBlock Text="Schedule" Canvas.Top="14" Canvas.Left="15"></TextBlock>
<TextBlock Text="1 Jan-3Mar" Canvas.Top="7" Canvas.Left="110"></TextBlock>
<Image Source="img/icons/icon.png" Canvas.Left="15" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_1.png" Canvas.Left="45" Canvas.Bottom="5"></Image>
<Image Source="img/icons/icon_2.png" Canvas.Left="75" Canvas.Bottom="5"></Image>
<Image Source="img/icons/t3.png" Canvas.Left="105" Canvas.Bottom="5"></Image>
</Canvas>-->
</Canvas>
</Canvas>
</Grid>
</Canvas>
<Canvas x:Name="cn" Grid.Column="2" Grid.Row="1" Background="White" MouseUp="Canvas_MouseUp_1">
<!--`ActivityInfo Popup up-->
<Canvas x:Name="ActivityInfo" Background="Green" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="ActivityInfo_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="projectdescrption" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Information" Canvas.Left="10" ></TextBlock>
<Canvas Background="White" Height="900" Width="200" Canvas.Top="50" Canvas.Left="10">
<StackPanel Width="200" Height="900" Background="White" Orientation="Vertical" >
<TextBlock x:Name="ActivityTitle" Text="Title" FontFamily="segoe_uilight" FontSize="18" Foreground="Black"></TextBlock>
<TextBlock x:Name="txtActivityTitle" Text="Page Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ProjectCompnt" Text="Project Component" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtProjectCompnt" Text="Project Component Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Phase" Text="Phase" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtPhase" Text="Phase Design" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Start" Text="Start" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtStart" Text="2014-1-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="End" Text="End" FontFamily="segoe_uilight" FontSize="18" Foreground="Black" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtEnd" Text="2014-2-16" FontFamily="segoe_uilight" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="Activitydescrption" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Description" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivitydescrption" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<TextBlock x:Name="ActivityRequirement" Foreground="Black" FontFamily="segoe_uilight" FontSize="18" Text="Requirement" Margin="0,20,0,0"></TextBlock>
<TextBlock x:Name="txtActivityRequirement" HorizontalAlignment="Left" Text="Loresum lipsum Loresum lipsum Loresum lipsum lipsum Loresum lipsum lipsum Loresum lipsum" Height="70" Width="180" FontFamily="segoe_uilight" TextWrapping="Wrap" Margin="0,0,0,0" FontSize="12" Foreground="Black"></TextBlock>
<Button x:Name="btnsave" Content="Save" Foreground="Black" Height="30" Width="100" HorizontalAlignment="Right" Background="#FFF3800C"></Button>
</StackPanel>
</Canvas>
</Canvas>
<!--`Activity Comments-->
<Canvas x:Name="Comments" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" MouseUp="Comments_MouseUp_1" Visibility="Hidden">
<TextBlock x:Name="ActivityComments" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="23" Text="Comments" Canvas.Left="35"></TextBlock>
<TextBox x:Name="txtComments" Height="110" Width="200" BorderBrush="Black" TextWrapping="Wrap" Canvas.Top="40" Canvas.Left="5" VerticalScrollBarVisibility="Visible" AcceptsReturn="True"></TextBox>
<Button x:Name="btnsavecomments" Content="Send" Foreground="Black" Height="30" Width="100" Canvas.Top="170" Canvas.Left="35" Background="#FFF3800C"></Button>
<ListBox Canvas.Top="220" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" >
<Border BorderThickness="2,2,2,2" CornerRadius="4" Background="#E26806">
<TextBlock x:Name="txtthreadComments" Height="Auto" Width="190" TextWrapping="Wrap" Background="#E26806" Text="g rg rg r g rg rg rg rg er gre ger ger g g gr" Foreground="White" ></TextBlock>
</Border>
<Image x:Name="imgthread" Height="30" Width="30" Margin="-100,-12,0,0" Source="D:\Amrit\Working Code\smart Info WPF app\SmartInfo\SmartAccount\SmartAccount\img\tol_tip.jpg"></Image>
<TextBlock x:Name="threadtime" Text="2014-6-7 12:00" HorizontalAlignment="Stretch" Margin="0,0,10,0" FontStyle="Italic" Height="20" Width="150" Foreground="Black" FontSize="16"></TextBlock>
<TextBlock x:Name="threadPostedBy" Text="Amrit Verma" Height="20" Width="150" Foreground="Black" FontStyle="Italic" FontWeight="Bold" FontSize="15"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
<!-- Assigned Memebres -->
<Canvas x:Name="AssignedMemebres" Background="White" Height="{Binding ElementName=cn,Path=ActualHeight}" Visibility="Hidden">
<TextBlock x:Name="Memebres" Foreground="#FFF3800C" FontFamily="segoe_uilight" FontSize="18" Text="Assigned Members" Canvas.Left="30"></TextBlock>
<ListBox Canvas.Top="40" BorderBrush="White">
<ListBoxItem>
<!--<ListBox.ItemTemplate>
<DataTemplate>-->
<Canvas Width="220" Height="620">
<TextBlock x:Name="AssignMemeber" Foreground="Black" FontFamily="segoe_uilight" FontSize="14" Text="+ Assign Memeber" FontStyle="Italic" Canvas.Left="12" Canvas.Top="-3"></TextBlock>
<StackPanel Width="200" Height="Auto" Canvas.Top="20" Orientation="Vertical" Canvas.Left="20">
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedto" Text="Amrit Verma" FontWeight="Bold"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="16" x:Name="txtassignedrole" Text="Developer" ></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Email" Text="Email" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtEmail" Text="Amrit#gmail.com" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="Phone" Text="Phone" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtPhone" Text="555-111 442 213" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingHours" Text="Working Hours" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingHours" Text="9:00 - 12:00" FontStyle="Italic"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="12" x:Name="WorkingDays" Text="Working Days" Margin="0,10,0,0"></TextBlock>
<TextBlock FontFamily="segoe_uilight" FontSize="14" x:Name="txtWorkingDays" Text="Mon-Sat" FontStyle="Italic"></TextBlock>
</StackPanel>
</Canvas>
</ListBoxItem>
<!--</DataTemplate>
</ListBox.ItemTemplate>-->
</ListBox>
</Canvas>
</Canvas>
<Canvas Grid.Column="3" Grid.Row="1" Background="Orange" >
<StackPanel Canvas.Left="0" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_1" x:Name="stackpnlinfo">
<Image Source="img\icons\icon.png" Height="20px" Width="20px" />
<!--<Image Source="img\btn_img.jpg" Height="45px" Width="60px" />-->
<Label HorizontalAlignment="Center" Content="Info" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" ></Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="45" Background="Gray" Width="60" MouseUp="StackPanel_MouseUp_2" x:Name="stackpnlcomment">
<Image Source="img\icons\icon_1.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Comments" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="90" Background="Gray" Width="60" >
<Image Source="img\icons\icon_2.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Files" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
<StackPanel Canvas.Left="0" Canvas.Top="135" Background="Gray" Width="60" x:Name="AssignedMembrs" MouseUp="AssignedMembrs_MouseUp_1">
<Image Source="img\icons\at.png" Height="20px" Width="20px" />
<Label HorizontalAlignment="Center" Content="Assigned Members" Foreground="White" FontFamily="segoe_uilight" BorderThickness="0" >
</Label>
</StackPanel>
</Canvas>
</Grid>
c#
private void InnerActivityListBox_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
if (_dragged != null)
return;
UIElement element = Phaseitem.InputHitTest(e.GetPosition(Phaseitem)) as UIElement;
while (element != null)
{
if (element is ListBoxItem)
{
_dragged = (ListBoxItem)element;
break;
}
element = VisualTreeHelper.GetParent(element) as UIElement;
}
SourcePhaseID = Phaseitem.Tag.ToString();
Globallb = Phaseitem;
Globallbi = _dragged;
Phaseitem.Items.Remove(_dragged);
}
private void InnerActivityListBox_DragEnter_1(object sender, DragEventArgs e)
{
if (_dragged == null || e.Data.GetDataPresent(DataFormats.Text, true) == false)
e.Effects = DragDropEffects.None;
else
e.Effects = DragDropEffects.All;
}
private void InnerActivityListBox_Drop_1(object sender, DragEventArgs e)
{
ListBox Phaseitem = (ListBox)sender as ListBox;
DestinationPhaseID = Phaseitem.Tag.ToString();
Phaseitem.Items.Add(_dragged);
}
private void InnerActivityListBox_DragOver_1(object sender, DragEventArgs e)
{
e.Effects = DragDropEffects.Move;
}
If this is you are trying to achieve. This also include designing your own Adorner to be shown as Ghost Perview while dragging
http://www.codeproject.com/Articles/43702/Drag-and-Drop-in-WPF-Part-II
and this article has vanilla code and doing exactly what you want
http://www.essentialobjects.com/doc/5/controls/treeview/dragdrop.aspx#list_box
I am going through the tutorial here and for whatever reason, the labels for FirstName, LastName, and City are not visible, neither at design time nor at runtime. I've tried deleting them and re-adding and I get the same result. Can anyone see what is causing them to be hidden?
<Grid Margin="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="73*"/>
<RowDefinition Height="247*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="259*"/>
<ColumnDefinition Width="258*"/>
</Grid.ColumnDefinitions>
<Button x:Name="btnSave" Content="Save" Grid.Column="1" HorizontalAlignment="Right" Margin="0,10,10,0" Width="60" Height="22" VerticalAlignment="Top"/>
<Button x:Name="btnRevert" Content="Revert" Grid.Column="1" HorizontalAlignment="Right" Margin="0,10,86,0" Width="60" RenderTransformOrigin="-0.047,0.36" Height="22" VerticalAlignment="Top"/>
<Button x:Name="btnAdd" Content="Add" Grid.Column="1" HorizontalAlignment="Right" Margin="0,10,162,0" VerticalAlignment="Top" Width="60"/>
<Button x:Name="btnDelete" Content="Delete" HorizontalAlignment="Right" Margin="0,10,238,0" VerticalAlignment="Top" Width="60" RenderTransformOrigin="-1.521,0.477" Grid.Column="1"/>
<Button x:Name="btnFirst" Content="|<" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="35"/>
<Button x:Name="btnFirst_Copy" Content="|<" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="35"/>
<Button x:Name="btnPrevious" Content="<" HorizontalAlignment="Left" Margin="54,10,0,0" VerticalAlignment="Top" Width="35"/>
<Button x:Name="btnNext" Content=">" HorizontalAlignment="Left" Margin="94,10,0,0" VerticalAlignment="Top" Width="35"/>
<Button x:Name="btnLast" Content=">|" HorizontalAlignment="Left" Margin="134,10,0,0" VerticalAlignment="Top" Width="35" RenderTransformOrigin="4.102,1.005"/>
<StackPanel HorizontalAlignment="Left" Height="28" Grid.Row="1" VerticalAlignment="Top" Width="304">
<Label x:Name="lblCustomerID" Content="Customer ID" Height="28"/>
<Label x:Name="lblFirstName" Content="First Name" Height="28"/>
<Label x:Name="lblLastName" Content="Last Name" Height="28"/>
<Label x:Name="lblCity1" Content="City" Height="28"/>
</StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Left" Height="251" Grid.Row="1" VerticalAlignment="Top" Width="297">
<TextBox x:Name="txtCustomerID" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=CustomerID, Mode=OneWay}"/>
<TextBox x:Name="txtLastName" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=LastName}"/>
<TextBox x:Name="txtFirstName" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=FirstName}"/>
<TextBox x:Name="txtCity" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=City}"/>
</StackPanel>
</Grid>
Remove your StackPanel's Height. Let it fill its height automatically. You set it to 28 which makes the other children get cutted off.
<StackPanel HorizontalAlignment="Left" Grid.Row="1" VerticalAlignment="Top" Width="304">
<Label x:Name="lblCustomerID" Content="Customer ID" Height="28"/>
<Label x:Name="lblFirstName" Content="First Name" Height="28"/>
<Label x:Name="lblLastName" Content="Last Name" Height="28"/>
<Label x:Name="lblCity1" Content="City" Height="28"/>
</StackPanel>
<StackPanel Grid.Column="1" HorizontalAlignment="Left" Grid.Row="1" VerticalAlignment="Top" Width="297">
<TextBox x:Name="txtCustomerID" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=CustomerID, Mode=OneWay}"/>
<TextBox x:Name="txtLastName" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=LastName}"/>
<TextBox x:Name="txtFirstName" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=FirstName}"/>
<TextBox x:Name="txtCity" Height="28" TextWrapping="Wrap" Width="Auto" Text="{Binding Path=City}"/>
</StackPanel>
I have created methods in C# visual studio 2010 that disable or enable buttons in a record using wpf commands as below:
private void CanSavePageCommandExecute(object sender, CanExecuteRoutedEventArgs e)
{
**if (studentsViewSource != null && studentsViewSource.View != null && novelDataSetTableAdapter.Update(novelDataSet.students) > 0)
{
e.CanExecute = true;
//e.Handled = true;
}
else
{
e.CanExecute = false;
}
}**
should be:
private void CanSavePageCommandExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = studentsViewSource != null && this.novelDataSet.HasChanges();
e.Handled = true;
}
private void OnSavePageCommandExecute(object sender, ExecutedRoutedEventArgs e)
{
if (novelDataSetTableAdapter.Update(novelDataSet.students) > 0)
MessageBox.Show("Entries have been updated !", "DATA STATUS");
else
MessageBox.Show("Error occurred!", "DATA NOT SAVED");
}
The 'CanSavePageCommandExecute' is supposed to just disable the SAVE button if the enclosed conditions are met. It actually does that but it goes a step further and saves the data to the database.
The 'OnSavePageCommandExecute' command is not carried out even if I just test using MessageBox.show.
How do I prevent the CanExecute command from saving data to just enabling and disabling button based on changes made to the datasets?
I am not using MVVM but this is part of the Xaml code from a user control:
<UserControl.CommandBindings>
<CommandBinding Command="New"
CanExecute="CanNewPageCommandExecute" Executed="OnNewPageCommandExecute" />
<CommandBinding Command="NavigationCommands.PreviousPage"
CanExecute="CanPreviousPageCommandExecute" Executed="OnPreviousPageCommandExecute" />
<CommandBinding Command="NavigationCommands.NextPage"
CanExecute="CanNextPageCommandExecute" Executed="OnNextPageCommandExecute" />
<CommandBinding Command="FirstPage"
CanExecute="CanPreviousPageCommandExecute" Executed="OnFirstPageCommandExecute" />
<CommandBinding Command="LastPage"
CanExecute="CanNextPageCommandExecute" Executed="OnLastPageCommandExecute" />
<CommandBinding Command="{x:Static local:student.saves}"
CanExecute="CanSavePageCommandExecute" Executed="OnSavePageCommandExecute" />
<CommandBinding Command="Delete"
CanExecute="CanDeletePageCommandExecute" Executed="OnDeletePageCommandExecute" />
</UserControl.CommandBindings>
<Border Width="Auto" Height="Auto" BorderThickness="1" CornerRadius="2">
<dxlc:LayoutControl Name="layoutControl1" Cursor="Arrow">
<dxlc:LayoutGroup Orientation="Vertical" Height="303">
<Border BorderThickness="1" Height="160" Width="160" BorderBrush="Black" Margin="0,0,0,20">
<Border.Background>
<ImageBrush ImageSource="/college12;component/images/prime.jpg" Stretch="Uniform" TileMode="None" />
</Border.Background>
<Image Height="150" Name="studypixx" Stretch="UniformToFill" Width="150" UseLayoutRounding="False" DataContext="{StaticResource studentsViewSource}" Source="{Binding Path=studyphoto, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Border>
<Button Content="Upload Photo" Height="23" HorizontalAlignment="Center" Name="studentphotoupload" VerticalAlignment="Top" Width="116" ToolTip="Inserts photo" Background="#FFEC3B3B" BorderBrush="Black" Cursor="Hand" Click="studentphotoupload_Click" />
<TextBox Name="photo_text" Width="160" HorizontalAlignment="Left" Height="20" IsHitTestVisible="False" Visibility="Visible" Text="{Binding Path=studyphoto, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}" DataContext="{StaticResource studentsViewSource}" />
<dxlc:LayoutGroup Name="layoutGroup3" View="GroupBox" Width="160" Height="62">
<Button Content="NEW STUDENT" Height="23" HorizontalAlignment="Center" Name="addstudent" VerticalAlignment="Bottom" Width="93" Command="ApplicationCommands.New" Cursor="Hand" />
</dxlc:LayoutGroup>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup Orientation="Vertical">
<dxlc:LayoutGroup Name="layoutGroup1" View="GroupBox" Height="238" UseLayoutRounding="True" Orientation="Vertical" Width="450" DragScrolling="False" Header="{Binding Path=surname}" DataContext="{StaticResource studentsViewSource}">
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="First Name" Name="layoutItem1">
<dxe:TextEdit Name="first_name" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" MaskSaveLiteral="True" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=firstname, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=LostFocus}" />
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Middle Name" Name="layoutItem2">
<dxe:TextEdit Name="other_name" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" MaskSaveLiteral="True" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=othername, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Surname" Name="layoutItem3">
<dxe:TextEdit Name="other_surname" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" MaskSaveLiteral="True" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=surname, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=LostFocus}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Email" Name="layoutItem10">
<dxe:TextEdit Name="email_address" EditValue="{Binding Path=email, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Birth Date" Name="layoutItem4">
<dxe:DateEdit Name="birth_date" Mask="d/MM/yyyy" MaskSaveLiteral="False" MaskType="DateTime" MaskUseAsDisplayFormat="True" UseLayoutRounding="False" FontFamily="Consolas" FontSize="12" EditValue="{Binding Path=birthdate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Enrol Date" Name="layoutItem5">
<dxe:DateEdit Name="enrol_date" MaskUseAsDisplayFormat="True" MaskType="DateTime" MaskSaveLiteral="False" Mask="d/MM/yyyy" UseLayoutRounding="False" FontFamily="Consolas" FontSize="12" EditValue="{Binding Path=enroldate, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Enrol NO." Name="layoutItem6">
<dxe:TextEdit Name="enrol_no" FontFamily="Consolas" FontSize="10" EditValue="{Binding Path=enrolnum, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Phone NO." Name="layoutItem9">
<dxe:TextEdit Name="phone_no" Mask="(\d?\d?\d?\d)\d\d-\d\d-\d\d" MaskType="Regular" MaskUseAsDisplayFormat="True" FontFamily="Consolas" FontSize="10" MaskBeepOnError="False" MaskSaveLiteral="False" AcceptsReturn="True" AcceptsTab="True" EditValue="{Binding Path=phone, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup>
<dxlc:LayoutItem Label="Address" Name="layoutItem7">
<dxe:TextEdit Name="address" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" EditValue="{Binding Path=address, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
<dxlc:LayoutItem Label="Town/City" Name="layoutItem8">
<dxe:TextEdit Name="town_city" FontFamily="Consolas" UseLayoutRounding="False" CharacterCasing="Upper" Mask="[a-zA-Z]+" MaskType="RegEx" EditValue="{Binding Path=town, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true, UpdateSourceTrigger=PropertyChanged}"/>
</dxlc:LayoutItem>
</dxlc:LayoutGroup>
</dxlc:LayoutGroup>
<dxlc:LayoutGroup Name="layoutGroup2" View="GroupBox" Width="450">
<Button Content="FIRST" Height="23" HorizontalAlignment="Left" Name="firststudent" VerticalAlignment="Top" Width="75" Cursor="Hand" Command="NavigationCommands.FirstPage" />
<Button Content="PREVIOUS" Height="23" HorizontalAlignment="Left" Name="previoustudent" VerticalAlignment="Top" Width="75" Command="NavigationCommands.PreviousPage" ToolTip="Preceding student record" Cursor="Hand" />
<Button Content="NEXT" Height="23" HorizontalAlignment="Left" Name="nextstudent" VerticalAlignment="Top" Width="75" Command="NavigationCommands.NextPage" ToolTip="Next student record" Cursor="Hand" />
<Button Content="LAST" Height="23" HorizontalAlignment="Left" Name="laststudent" VerticalAlignment="Top" Width="75" Cursor="Hand" Command="NavigationCommands.LastPage" />
<Button Content="SAVE" Height="23" HorizontalAlignment="Left" Name="savestudent" VerticalAlignment="Top" Width="75" Cursor="Hand" Command="{x:Static local:student.saves}"/>
</dxlc:LayoutGroup>
</dxlc:LayoutGroup>
</dxlc:LayoutControl>
</Border>
I created a custom user control, and it looks like this:
XAML for the control is:
<Grid>
<Label Content="Job #" Height="28" HorizontalAlignment="Left" Margin="6,14,0,0" Name="label1" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="48" HorizontalContentAlignment="Right" />
<Label Content="Customer" Height="28" HorizontalAlignment="Left" Margin="6,41,0,0" Name="label2" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="48" HorizontalContentAlignment="Right" />
<Label Content="Location" Height="28" HorizontalAlignment="Left" Margin="6,68,0,0" Name="label3" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="48" HorizontalContentAlignment="Right" />
<Label Content="Crossing" Height="28" HorizontalAlignment="Left" Margin="6,95,0,0" Name="label4" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="48" HorizontalContentAlignment="Right" />
<Label Content="Engineer" Height="28" HorizontalAlignment="Left" Margin="6,122,0,0" Name="label5" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="48" HorizontalContentAlignment="Right" />
<Label Content="Probe #" Height="28" HorizontalAlignment="Left" Margin="6,149,0,0" Name="label6" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="48" HorizontalContentAlignment="Right" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="53,14,0,0" Name="lblJob" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="53,41,0,0" Name="lblCustomer" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="53,68,0,0" Name="lblLocation" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="53,95,0,0" Name="lblCrossing" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="53,122,0,0" Name="lblEngineer" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="53,149,0,0" Name="lblProbe" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Away" Height="28" HorizontalAlignment="Left" Margin="204,41,0,0" Name="label14" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="55" />
<Label Content="Elevation" Height="28" HorizontalAlignment="Left" Margin="204,68,0,0" Name="label15" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="55" />
<Label Content="Right" Height="28" HorizontalAlignment="Left" Margin="204,95,0,0" Name="label16" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="55" />
<Label Content="Inclination" Height="28" HorizontalAlignment="Left" Margin="204,122,0,0" Name="label17" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="55" />
<Label Content="Baseline" Height="28" HorizontalAlignment="Left" Margin="204,149,0,0" Name="label18" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="55" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="258,41,0,0" Name="lblAway" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="258,68,0,0" Name="lblElevation" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="258,95,0,0" Name="lblRight" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="258,122,0,0" Name="lblInclination" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="258,149,0,0" Name="lblBaseline" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Entry" Height="28" HorizontalAlignment="Left" Margin="338,12,0,0" Name="label13" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="40" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="377,12,0,0" Name="lblEntry" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Exit" Height="28" HorizontalAlignment="Left" Margin="521,12,0,0" Name="label25" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="40" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="560,12,0,0" Name="lblExit" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<Label Content="Units" Height="28" HorizontalAlignment="Left" Margin="706,12,0,0" Name="label27" Style="{StaticResource MyLabel2}" VerticalAlignment="Top" Width="40" />
<Label Content="Default" Height="28" HorizontalAlignment="Left" Margin="745,12,0,0" Name="lblUnits" Style="{StaticResource MyLabel3}" VerticalAlignment="Top" Width="120" />
<DataGrid AutoGenerateColumns="True" Height="275" Margin="12,186,0,0" Name="dataGrid1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="849" />
</Grid>
Yet, when I add it to the window that it's going to be in, it looks like this:
XAML for the Window is:
<Grid>
<SurveyReport:SurveyReport Margin="0,12,0,0" Height="727" VerticalAlignment="Top" HorizontalAlignment="Left" Width="1425" />
</Grid>
Now, when I run the program, it appears the way that it should. But in the designer, it looks all messed up. All my other custom controls look the way that they should. It's just this one that is giving me issues. Is there a reason for this?