I have two Expanders in a DockPanel control, the first Expander that is at the top is set to isExpanded true while the other Expander is not.
I just want the second Expander to go up whenever the first Expander is set to isExpanded false in run time...
Here is my XAML code :
<DockPanel LastChildFill="False" Margin="0,26,0,0" Background="#FF552D2D" HorizontalAlignment="Left" Width="149">
<StackPanel ScrollViewer.VerticalScrollBarVisibility="Auto">
<Expander x:Name="AdminManage" Header="Manage" Margin="0" Foreground="#FF14D0EE" Height="198" IsExpanded="True" Collapsed="AdminManage_Collapsed" Width="544">
<StackPanel x:Name="AdminStackPanel" Height="177" Margin="0,0,-2,0">
<Button Content="" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" Margin="23,0,0,0" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
</StackPanel>
</Expander>
<Expander Header="Account" Margin="0" VerticalAlignment="Top" Foreground="#FF14D0EE" Height="66">
<StackPanel Height="44" Margin="0,0,-2,0">
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
<Button Content="" Margin="23,0,0,0" Background="#FF552D2D" BorderBrush="{x:Null}" BorderThickness="0" Opacity="0.5" Foreground="White" VerticalAlignment="Center" HorizontalContentAlignment="Left" HorizontalAlignment="Left" Width="124"/>
</StackPanel>
</Expander>
</StackPanel>
</DockPanel>
Remove your Height property from AdminManage Expander, i test it it will work like expected
By go below do you mean to expand the expander ?
If so, you can do a element binding like below. You also need a converter to invert the Boolean value of the first expander.
<Expander Header="Account" Margin="0" VerticalAlignment="Top" Foreground="#FF14D0EE" Height="66"
IsExpanded="{Binding IsExpanded, ElementName=AdminManage, Converter={StaticResource InvertBooleanConverter}"
<StackPanel Height="44" Margin="0,0,-2,0">
<!-- your content here -->
</StackPanel>
</Expander>
Else if you meant to interchange their positions you would want to add the expanders inside a Grid instead of a StackPanel and change the attached Grid.Row property of the expanders whenever IsExpanded changes
Related
I have a strange problem, I had a WPF (with C# code behind) page with some buttons and some keydown events. Recently I've added a ribbon control to group the buttons and the keydown events aren't working any more.
The strangest thing is that if I add back any of the old buttons (outside of the ribbon) and click on it then the keydown events start working.
Thanks
<Page x:Class="Ab3d.PowerToys.Samples.SceneEditor.SceneEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cameras="clr-namespace:Ab3d.Cameras;assembly=Ab3d.PowerToys"
xmlns:ab3d="clr-namespace:Ab3d.Controls;assembly=Ab3d.PowerToys"
xmlns:visuals="clr-namespace:Ab3d.Visuals;assembly=Ab3d.PowerToys"
xmlns:local="clr-namespace:Ab3d.PowerToys.Samples.SceneEditor"
mc:Ignorable="d"
d:DesignHeight="550" d:DesignWidth="800"
Title="SceneEditor" KeyDown="MainViewport_KeyDown" PreviewKeyDown="Window_PreviewKeyDown"
ShowsNavigationUI="False" >
<Page.Resources>
<BooleanToVisibilityConverter x:Key="VisibilityOfBool" />
<DiffuseMaterial x:Key="Material1" Brush ="Coral" />
</Page.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid Name="OptionsGrid" Grid.Row="0" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- THE RIBBON -->
<ribbon:Ribbon SelectedIndex="0" KeyDown="MainViewport_KeyDown">
<!-- Tab -->
<RibbonTab Header="Model" HorizontalAlignment="Left" Height="88" VerticalAlignment="Top" Width="1000">
<!-- Draw -->
<RibbonGroup Header="Draw" Height="88" Margin="0" VerticalAlignment="Top" Width="280">
<RibbonButton x:Name="Point"
Label="Point"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\PointRo.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="NewLine"
Label="Line"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\NewLine2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewLineButton_Click"/>
<RibbonButton x:Name="Arc"
Label="Arc"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Arc2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Surface"
Label="Surface"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Surface2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="20"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Volume"
Label="Volume"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Volume2.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<StackPanel>
<RibbonButton x:Name="Clothoid"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Clothoid2.png"
HorizontalAlignment="Left"
Height="20"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="22"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Spline"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Spline2.png"
HorizontalAlignment="Left"
Height="25"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="22"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Ellipse"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Ellipse2.png"
HorizontalAlignment="Left"
Height="24"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="22"
Click="NewPointButton_Click"/>
</StackPanel>
</RibbonGroup>
<!-- Transform -->
<RibbonGroup Header="Transform" Height="88" Margin="0" VerticalAlignment="Top" Width="140">
<StackPanel>
<RibbonButton x:Name="Move"
Label="Move"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Move.png"
HorizontalAlignment="Left"
Height="20"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Copy"
Label="Copy"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Copy3.png"
HorizontalAlignment="Left"
Height="30"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Rotate"
Label="Rotate"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Rotate2.png"
HorizontalAlignment="Left"
Height="20"
Margin="0,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
</StackPanel>
<StackPanel>
<RibbonButton x:Name="Mirror"
Label="Mirror"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Mirror.png"
HorizontalAlignment="Left"
Height="20"
Margin="10,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Scale"
Label="Scale"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Scale.png"
HorizontalAlignment="Left"
Height="30"
Margin="10,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Array"
Label="Array"
SmallImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Array.png"
HorizontalAlignment="Left"
Height="20"
Margin="10,0,0,0"
VerticalAlignment="Top"
Width="60"
Click="NewPointButton_Click"/>
</StackPanel>
</RibbonGroup>
<!-- Loads -->
<RibbonGroup Header="Loads" Height="88" Margin="0" VerticalAlignment="Top" Width="160">
<RibbonButton x:Name="Nodal"
Label="Nodal"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\NoadalLoads.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="50"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="UDL"
Label="UDL"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\UDL.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="50"
Click="NewPointButton_Click"/>
<RibbonButton x:Name="Face"
Label="Face"
LargeImageSource="C:\Users\Infra-Iordanescu\source\repos\ARES\Images\Face.png"
HorizontalAlignment="Left"
Height="60"
Margin="0,5,0,0"
VerticalAlignment="Top"
Width="45"
Click="NewPointButton_Click"/>
</RibbonGroup>
<RibbonGroup Header="Analysis" Height="88" Margin="0" VerticalAlignment="Top" Width="100"/>
<RibbonGroup Header="Results" Height="88" Margin="0" VerticalAlignment="Top" Width="100"/>
<RibbonGroup Header="View" Height="88" Margin="0" VerticalAlignment="Top" Width="100"/>
</RibbonTab>
<RibbonTab Header="Prop" HorizontalAlignment="Left" Height="88" VerticalAlignment="Top" Width="798"/>
</ribbon:Ribbon>
<StackPanel Grid.Column="0" Orientation="Horizontal" Margin="10 0 0 0">
<!-- <StackPanel Orientation="Vertical">
<Button Name="ResetCameraCenterButton" Content="Reset camera" ToolTip="Sets camera TargetPosition to (0,0,0)" VerticalAlignment="Center" Click="ResetCameraCenterButton_Click" Margin="0 0 5 0"/>
<Button Name="FitViewButton" Content="Fit to view" Click="FitViewButton_Click" VerticalAlignment="Center" Margin="0 5 5 0" />
</StackPanel> -->
</StackPanel>
<!-- <StackPanel Grid.Column="1" Orientation="Vertical" Margin="10 0 0 0">
<Button Name="newPoint" Content="Point" ToolTip="New Point" VerticalAlignment="Center" Click="NewPointButton_Click" Margin="0 0 5 0"/>
<Button Name="newLine" Content="Line" ToolTip="New Line (L)" VerticalAlignment="Center" Click="NewLineButton_Click" Margin="0 5 5 0"/>
</StackPanel> -->
</Grid>
<Border Name="ViewportBorder" Grid.Row="1" Background="White"
MouseMove="ViewportBorder_MouseMove" >
<Viewport3D Name="MainViewport">
<ModelVisual3D x:Name="VisualSpace" />
<visuals:WireGridVisual3D x:Name="MainWireGrid"
CenterPosition="0 0 0"
Size="200 200"
WidthCellsCount="25"
HeightCellsCount="25"
LineColor="#555555"
LineThickness="1"
MajorLinesFrequency="5"
MajorLineThickness="2"
MajorLineColor="#333333"
IsVisible="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowWireGrid}" />
<ModelVisual3D x:Name="ObjectsVisual" />
</Viewport3D>
</Border>
<cameras:TargetPositionCamera Name="Camera1" Grid.Row="1"
TargetPosition="0 0 0"
Heading="30" Attitude="-30" Bank="0"
Distance="300"
ShowCameraLight="Always"
TargetViewport3D="{Binding ElementName=MainViewport}"/>
<ab3d:MouseCameraController Name="MouseCameraController1" Grid.Row="1"
ShowRotationCenterMarker="True"
ZoomMode="MousePosition"
RotateCameraConditions="RightMouseButtonPressed"
MoveCameraConditions="MiddleMouseButtonPressed"
EventsSourceElement="{Binding ElementName=ViewportBorder}"
TargetCamera="{Binding ElementName=Camera1}" />
<ab3d:CameraAxisPanel Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Left"
TargetCamera="{Binding ElementName=Camera1}"
Visibility="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowCameraAxis, Converter={StaticResource VisibilityOfBool}}"/>
<ab3d:ViewCubeCameraController Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Right"
TargetCamera="{Binding ElementName=Camera1}"
Visibility="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowViewCubeCameraController, Converter={StaticResource VisibilityOfBool}}" />
<ab3d:MouseCameraControllerInfo Name="MouseCameraControllerInfo1" Grid.Row="1" Margin="0 5 0 0"
VerticalAlignment="Top" HorizontalAlignment="Right"
MouseCameraController="{Binding ElementName=MouseCameraController1}"
Visibility="{Binding Source={x:Static local:SceneEditorContext.Current}, Path=ShowMouseCameraControllerInfo, Converter={StaticResource VisibilityOfBool}}" />
<!-- Selection canvas -->
<Canvas Name="SelectionOverlayCanvas" Grid.Column="0" IsHitTestVisible="False">
<Rectangle Name="SelectionRectangle" Fill="#555FD3FF" Stroke="#AA5FD3FF" StrokeThickness="1" Visibility="Collapsed" />
</Canvas>
<!-- Point data tooltip -->
<Canvas Name="DataToolTipCanvas" Grid.Column="0" IsHitTestVisible="False">
<Border Name="DataToolTipBorder" BorderThickness="2" BorderBrush="Black" Background="LightGray" Visibility="Collapsed">
<StackPanel Orientation="Vertical">
<TextBlock Text="Coordinates:" />
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding X, StringFormat={}X:{0:N}}"/>
<TextBlock Text="{Binding Y, StringFormat={} Y:{0:N}}"/>
<TextBlock Text="{Binding Z, StringFormat={} Z:{0:N}}"/>
</StackPanel>
</StackPanel>
</Border>
</Canvas>
</Grid>
</Page>
private void MainViewport_KeyDown(object sender, KeyEventArgs e)
{
System.Diagnostics.Debug.WriteLine("KeyDown");
// ESC deselects all
if (e.Key == Key.Escape)
{
for (var i = 0; i < spheres.Count; i++)
{
spheres[i].Material = material;
spheres[i].Radius = originalRadius;
}
for (var i = 0; i < lines.Count; i++)
{
lines[i].LineColor = originalLineColor;
}
DataToolTipBorder.Visibility = Visibility.Collapsed;
this.DataContext = null;
}
The problem has been solved, by:
Loaded="Page_Loaded" Focusable="True"
and
private void Page_Loaded(object sender, RoutedEventArgs e)
{
this.Focus();
}
It seems it was a focus issue.
Thanks.
I am not able to have a user input in a textbox when click it both in the Emulator and in windows phone device. I have deleted all the textboxes and replace them with new ones without any special preferences and still don't work. I have implemented the whole interface of my application and need help to solve this issue and start playing with the server connection. Also the rest of the controls all work properly. Please any ideas?
This is the corresponding interface of the code I am posting below.
This is my mainpage.xaml code: If you need anything else please let me know.
<controls:ViewPage
x:Class="Menu_and_Topbar_app__Windows_Phone_8._1_3.MainPage"
xmlns:controls="using:Menu_and_Topbar_app__Windows_Phone_8._1_3.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Menu_and_Topbar_app__Windows_Phone_8._1_3"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="#FF250D5C">
<ScrollViewer HorizontalAlignment="Center"
VerticalAlignment="Center"
Margin="5.857,6.897,8.265,12.783" RenderTransformOrigin="0.5,0.5" Height="620.32" UseLayoutRounding="False" Width="385.878" d:LayoutRounding="Auto">
<ScrollViewer.RenderTransform>
<CompositeTransform Rotation="0.309"/>
</ScrollViewer.RenderTransform>
<Pivot Name="MyPivot" IsEnabled="True" IsTapEnabled="True">
<Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" FontSize="37" SelectionHighlightColor="#FF898888" />
</DataTemplate>
</Pivot.HeaderTemplate>
<PivotItem x:Name="PivotItem1" Header="Sign In" IsEnabled="True" IsTapEnabled="True">
<Grid HorizontalAlignment="Left" Height="496" Margin="18,19,0,0" VerticalAlignment="Top" Width="311" IsTapEnabled="True" IsRightTapEnabled="True">
<Image x:Name="image" HorizontalAlignment="Left" Height="70" Margin="64,9,0,0" VerticalAlignment="Top" Width="193" Source="/Menu and Topbar app (Windows Phone 8.1)3/Pictures/logo.png" Visibility="Visible" />
<Button x:Name="button" Content="Log In" HorizontalAlignment="Left" Margin="98,409,0,0" VerticalAlignment="Top" Click="button_Click_1"/>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="16,113,0,0" TextWrapping="Wrap" Text="Username or Email:" VerticalAlignment="Top" FontSize="16"/>
<TextBlock x:Name="textBlock2" HorizontalAlignment="Left" Margin="16,210,0,0" TextWrapping="Wrap" Text="Password:" VerticalAlignment="Top" FontSize="16"/>
<HyperlinkButton Content="Sign Up for SCP?" HorizontalAlignment="Left" Margin="17,266,0,0" VerticalAlignment="Top" FontSize="13.333" NavigateUri="http://scponline.azurewebsites.net/Home/LoginPartialView"/>
<CheckBox x:Name="checkBox" Content="Remember me?" HorizontalAlignment="Left" Margin="17,312,0,0" VerticalAlignment="Top"/>
<TextBox x:Name="textBox" HorizontalAlignment="Left" Margin="17,137,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="275" GotFocus="textBox_GotFocus" AllowDrop="True" />
</Grid>
</PivotItem>
<PivotItem x:Name="PivotItem2" Header="Sign Up" >
<Grid HorizontalAlignment="Left" Height="496" Margin="18,19,0,0" VerticalAlignment="Top" Width="311">
<Button Content="Sign Up" HorizontalAlignment="Left" Margin="97,437,0,0" VerticalAlignment="Top" Click="Button_Click_2"/>
<TextBlock x:Name="textBlock3" HorizontalAlignment="Left" Margin="16,108,0,0" TextWrapping="Wrap" Text="Email:" VerticalAlignment="Top" FontSize="16"/>
<TextBlock x:Name="textBlock4" HorizontalAlignment="Left" Margin="16,168,0,0" TextWrapping="Wrap" Text="Password:" VerticalAlignment="Top" FontSize="16"/>
<TextBox x:Name="textBox3" HorizontalAlignment="Left" Margin="16,126,0,0" TextWrapping="Wrap" Text="username#mail.com" VerticalAlignment="Top" Height="0" Width="276" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
<TextBox x:Name="textBox4" HorizontalAlignment="Left" Margin="16,187,0,0" TextWrapping="Wrap" Text="***********" VerticalAlignment="Top" Height="0" Width="276" TextChanged="textBox2_TextChanged" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
<Image x:Name="image1" HorizontalAlignment="Left" Height="70" Margin="64,9,0,0" VerticalAlignment="Top" Width="193" Source="/Menu and Topbar app (Windows Phone 8.1)3/Pictures/logo.png"/>
<TextBlock x:Name="textBlock1" HorizontalAlignment="Left" Margin="16,232,0,0" TextWrapping="Wrap" Text="Name:" VerticalAlignment="Top" SelectionChanged="textBlock1_SelectionChanged" FontSize="16"/>
<TextBox x:Name="textBox5" HorizontalAlignment="Left" Margin="16,250,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="0" Width="276" TextChanged="textBox2_TextChanged" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
<TextBlock x:Name="textBlock5" HorizontalAlignment="Left" Margin="16,292,0,0" TextWrapping="Wrap" Text="Name:" VerticalAlignment="Top" SelectionChanged="textBlock1_SelectionChanged" FontSize="16"/>
<TextBox x:Name="textBox6" HorizontalAlignment="Left" Margin="16,310,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="0" Width="276" TextChanged="textBox2_TextChanged" FontSize="17.593" RenderTransformOrigin="0.5,0.5">
<TextBox.RenderTransform>
<CompositeTransform ScaleY="0.9"/>
</TextBox.RenderTransform>
</TextBox>
</Grid>
</PivotItem>
</Pivot>
</ScrollViewer>
</Grid>
I am looking for something like:
lv.Children.Add(e1);
But lv.children.add does not exist
<ListView x:Name="lv" Height="300" Margin="727,97,208,231" Grid.Row="1" >
<Grid Name="e1" Height="48" Width="417" >
<Image Width="32" HorizontalAlignment="Left" Margin="5" Source="ms-appx:///img/coffee.png" />
<TextBlock Text="caffee" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="40,0,26,5" ></TextBlock>
<TextBlock Text="$2" FontSize="18" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5,5,30,5"></TextBlock>
<TextBlock Text="caffee" FontSize="18" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5,5,90,5"></TextBlock>
</Grid>
</ListView>
you have to use
lv.Items.Add(e1);
Iam new to windows phone development. I have a grid, which contains a image. I need to make the image visible when i tap on grid(parent of image) and collapsed when i tapped for the second time.
My design as follows
<Grid x:Name="gridThriller" HorizontalAlignment="Left" Height="172" Margin="33,85,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller" >
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None" />
</Grid>
<Grid x:Name="gridAction" HorizontalAlignment="Left" Height="172" Margin="186,85,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
<Grid x:Name="gridHorror" HorizontalAlignment="Left" Height="172" Margin="340,85,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
<Grid x:Name="gridSciFi" HorizontalAlignment="Left" Height="172" Margin="33,283,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
<Grid x:Name="gridRomantic" HorizontalAlignment="Left" Height="172" Margin="186,283,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
<Grid x:Name="gridComedy" HorizontalAlignment="Left" Height="172" Margin="340,283,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
<Grid x:Name="gridDrama" HorizontalAlignment="Left" Height="172" Margin="33,481,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
<Grid x:Name="gridFantacy" HorizontalAlignment="Left" Height="172" Margin="186,481,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
<Grid x:Name="gridAnimated" HorizontalAlignment="Left" Height="172" Margin="340,481,0,0" VerticalAlignment="Top" Width="123" Background="Transparent" Tap="selectThiller">
<Image Source="/Images/right.png" HorizontalAlignment="Right" VerticalAlignment="Top" Stretch="None"/>
</Grid>
How to solve this problem?
Well it looks like you have the tap event for all of them pointing at the same method so thats an okay first start. If you want to continue down that path then what I would do is the following.
Inside your tap event
foreach(Image item in (sender as Grid).Children)
{
if(item.Visibility == Visibility.Visible)
item.Visibility = Visibility.Collapsed;
else
item.Visibility = Visibility.Visible;
}
NOTE# if you put ANYTHING else in those grid elements other than images this will explode. If you need to add other things then you will need to add separate logic above this to weed out images.
How could we arrange the controls on a WPF window so that it would automatically align the controls while switching between view modes occur ie between landscape and portrait mode.
<Window x:Class="Custom_Track_Reports.LoginWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="LoginWindow" >
<Viewbox Stretch="Fill">
<Grid Background="#FF58B0DF" Height="401">
<Rectangle Fill="#FFF0F3F4" Height="173" Margin="45,197,58,0" Stroke="Black" VerticalAlignment="Top" AllowDrop="True" />
<Image Height="125" Margin="340,10,330,0" VerticalAlignment="Top" Source="Images/logo_lrg.png"/>
<Label Content="Custom Track Reports" HorizontalAlignment="Left" Margin="287,147,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.607,1.112" Width="268" Height="47" FontFamily="Arial" FontSize="26" Foreground="White"/>
<TextBox Margin="128,0,0,110" TextWrapping="Wrap" VerticalAlignment="Bottom" Height="25" BorderThickness="1" FontFamily="Arial" FontSize="21" Text="" Name="userTextBox" FontStretch="Expanded" Opacity="1" HorizontalAlignment="Left" Width="546" AcceptsReturn="False" KeyDown="userTextBox_KeyDown" />
<Button x:Name="enterButton" Content="Enter" HorizontalAlignment="Right" Margin="0,311,166,0" VerticalAlignment="Top" Width="110" Height="26" FontSize="14" Style="{DynamicResource button}" Click="enterButton_Click"/>
<Label Content="User ID" FontSize="20" FontWeight="Bold" Height="40" HorizontalAlignment="Left" Margin="122,215,0,0" Name="label1" VerticalAlignment="Top" Width="105" />
</Grid>
</Viewbox>