Combobox dropdown don't visible as expected in windows mobile app (c#) - c#

What I need is to move other gui controllers down when I click on the combobox, so that I can clearly see the data inside the combobox. I'm doing this on a windows mobile 8.1 project.
</Grid>
<ComboBox x:Name="comboBoxCompanyLocation" HorizontalAlignment="Left" VerticalAlignment="Top" Width="210" FontSize="13.333" Height="56" Margin="142,87,0,0" DisplayMemberPath="CompanyCity" PlaceholderText="Select a Location"/>
<TextBlock x:Name="textBlockCompanyLocation" HorizontalAlignment="Left" Margin="0,0,0,78" TextWrapping="Wrap" Text="Location" VerticalAlignment="Bottom" RenderTransformOrigin="-0.089,-0.581" FontSize="17.333" Height="38"/>
<Button x:Name="buttonFilterSearch" Content="Filter" HorizontalAlignment="Left" Margin="251,155,0,0" VerticalAlignment="Top" Click="buttonFilterSearch_Click" Width="104"/>
<Button x:Name="buttonResetFilter" Content="Reset" HorizontalAlignment="Left" Margin="142,155,0,0" VerticalAlignment="Top" Click="buttonResetFilter_Click" Width="94"/>
</Grid>

Related

Using MaterialDesignThemes DrawerHost

Please could someone assist me in trying to figure this out.
I have created a menu on a WPF page called DashView.xaml
this menu has buttons on it going down and I would like to know how to get the BottomDrawerContent to be visible once I click on a button.
Below I have given the code that is in DashView.xaml
<materialDesign:DialogHost x:Name="hostSales" >
<materialDesign:DrawerHost x:Name="SalesDrawerHost" Content="Sales" Foreground="GhostWhite"
FontWeight="Bold" FontSize="22" BottomDrawerCloseOnClickAway="True"
Cursor="Hand" Width="200" Height="30" ToggleButton.Checked="chkSalesBt1">
<materialDesign:DrawerHost.BottomDrawerContent x:Uid="dashSalesBt1">
<StackPanel x:Name="stkSalesBt1">
<Button Content="Record Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
<Button Content="Recent Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
</StackPanel>
</materialDesign:DrawerHost.BottomDrawerContent>
</materialDesign:DrawerHost>
</materialDesign:DialogHost>
I do have a class called DashClass.cs
Just not sure what I am meant to put in it or how I am meant to get the execution to show the BottomDrawerContent
Yout need a tooglebutton:
<ToggleButton
x:Name="menuToggler"
Style="{DynamicResource MaterialDesignHamburgerToggleButton}" />`
and in the DrawerHost use IsLeftDrawerOpen
<materialDesign:DrawerHost
x:Name="SalesDrawerHost"
Content="Sales"
Foreground="GhostWhite"
FontWeight="Bold"
FontSize="22"
BottomDrawerCloseOnClickAway="True"
Cursor="Hand"
Width="200"
Height="30"
IsBottomDrawerOpen="{Binding ElementName=menuToggler, Path=IsChecked}">
<materialDesign:DrawerHost.BottomDrawerContent x:Uid="dashSalesBt1">
<StackPanel x:Name="stkSalesBt1">
<Button Content="Record Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
<Button Content="Recent Sales" Foreground="GhostWhite" FontWeight="SemiBold"/>
</StackPanel>
</materialDesign:DrawerHost.BottomDrawerContent>
</materialDesign:DrawerHost>

Mouse events not firing in Windows WPF

I have a simple WPF application
<Grid>
<Border BorderBrush="Black" BorderThickness="1"
HorizontalAlignment="Left" Height="388" Margin="10,10,0,0" VerticalAlignment="Top" Width="329"/>
<Image x:Name="PreviewImg" HorizontalAlignment="Left" Height="400" Margin="10,10,0,0" VerticalAlignment="Top" Width="329" MouseDown="PreviewImgMouse" AllowDrop="True" PreviewMouseWheel="PreviewImg_PreviewMouseWheel" MouseEnter="Entered" Focusable="True"></Image>
<Label Content="Matched Products" HorizontalAlignment="Left" Margin="344,10,0,0" VerticalAlignment="Top" Width="290"/>
<Label Content="Unknown Products" HorizontalAlignment="Left" Margin="661,10,0,0" VerticalAlignment="Top" Width="290"/>
<TextBlock x:Name="MatchedProducts" HorizontalAlignment="Left" Margin="349,36,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="362" Width="295"/>
<TextBlock x:Name="UnknownProducts" HorizontalAlignment="Left" Margin="666,36,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Height="362" Width="295"/>
<Grid HorizontalAlignment="Left" Height="50" Margin="10,410,0,0" VerticalAlignment="Top" Width="957">
<Button x:Name="FinalizeBtn" Content="Finalize" HorizontalAlignment="Left" Margin="826,10,0,0" VerticalAlignment="Top" Width="120" Height="30"/>
<Button x:Name="NewEntryBtn" Content="Create new entry" HorizontalAlignment="Left" Margin="701,10,0,0"
VerticalAlignment="Top" Width="120" Height="30"/>
<Button x:Name="FreeBtn" Content="Free Button" HorizontalAlignment="Left" Margin="576,10,0,0" VerticalAlignment="Top" Width="120" Height="30"/>
</Grid>
</Grid>
All the events defined under the Image component are not firing, I tried all of googles first page searches, but none of them work.
I read about the difference of Routed events in my application both MouseDown and PreviewMouseDown should work.
The only thing that can block the image is Border component, but I did try without it and still nothing, and since it is declared first the image should overlay it...?
All function names are correct since they were automatically generated.
I can paste in the .cs file if it can help.
Thanks
E1: Somehow it works now, but I have no idea what fixed it...
One change I did was mode the image inside the border:
<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="388" Margin="10,10,0,0" VerticalAlignment="Top" Width="329">
<Image x:Name="PreviewImg" Height="400" Margin="0" VerticalAlignment="Center" HorizontalAlignment="Center" Width="329" MouseDown="PreviewImgMouse" AllowDrop="True" PreviewMouseWheel="PreviewImg_PreviewMouseWheel" MouseEnter="Entered" Focusable="True"/>
</Border>
But I can't image that this fixed it.
You need to define a source for your image like <Image Source="image.jpg". Without the image the events will not fire.
For advanced users
Use a Button styled as an Image, see #Richard's answer with WPF Image Control with Click event
For beginners
The Image component needs a source to fire events as posted by #Örvar. Adding a transparent source is the solution, although a hacky one.
One way of achieving what you want is to place the image in a button and removing the button styles. There is an excellent example here:
WPF Image Control with Click Event

Setting image's build action property

I have simple problem. I want to add image to buttons and there is one case I can't manage. In designer everything works properly, but in debug mode there is no trace of a picture inside the button. I read that I have to set Build Action property of the image to "Recourses" or "Content" but I don't have these pictures in Solution Explorer, exactly I can see them when I click "Show All Files but they have strange icon not as the one image which I can normally see in Solutions Explorer and no Build Action property.
Am I supposed to add images in different way?
<Button x:Name="loadButton" HorizontalAlignment="Left" Margin="955,0,0,443" Style="{DynamicResource SimpleButton}" VerticalAlignment="Bottom" Width="29" Height="27" FontFamily="Courier New" FontWeight="Bold" Click="loadButton_Click" Background="{x:Null}" BorderBrush="{x:Null}">
<StackPanel Orientation="Horizontal">
<Image x:Name="Load" Source="open-map.png"/>
</StackPanel>
</Button>
<CheckBox x:Name="mode" Content="Tryb tworzenia" HorizontalAlignment="Left" Margin="30,292,0,0" VerticalAlignment="Top" FontSize="18.667" Foreground="#FFAC3333" FontFamily="Courier New" IsChecked="True"/>
<Button x:Name="button1_Copy" HorizontalAlignment="Left" Margin="912,0,0,443" Style="{DynamicResource SimpleButton}" VerticalAlignment="Bottom" Width="29" Height="27" FontFamily="Courier New" FontWeight="Bold" Click="button1_Copy_Click" Background="{x:Null}" BorderBrush="{x:Null}">
<StackPanel Orientation="Horizontal">
<Image x:Name="Save" Source="save-icon.png"/>
</StackPanel>
</Button>
Thank in advanced
The files like open-map.png are not part of the C# project so you can't set any properties. Right click on the C# project and add the file to the project, then you'll be able to set its properties.

How do you use StackPanel.FindName in WPF?

I have a stack panel with a set of four image buttons inside of it. When I try to search by the name of the image button it comes back null. What is wrong with my code?
XAML:
<StackPanel x:Name="swatchClearStackPanel" Orientation="Vertical" Grid.Column="1" Grid.Row="2" Margin="0,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Bottom">
<imgbutton:ImageButton x:Name="ClearSwatchColor1" Grid.Row="0" Grid.Column="2" Style="{DynamicResource ButtonClearSwatchColor}" Margin="5,8,5,5" HorizontalAlignment="Left" Visibility="Hidden" Click="ClearSwatchColor_Click" />
<imgbutton:ImageButton x:Name="ClearSwatchColor2" Grid.Row="0" Grid.Column="2" Style="{DynamicResource ButtonClearSwatchColor}" Margin="5,18,5,5" HorizontalAlignment="Left" Visibility="Hidden" Click="ClearSwatchColor_Click"/>
<imgbutton:ImageButton x:Name="ClearSwatchColor3" Grid.Row="0" Grid.Column="2" Style="{DynamicResource ButtonClearSwatchColor}" Margin="5,18,5,5" HorizontalAlignment="Left" Visibility="Hidden" Click="ClearSwatchColor_Click"/>
<imgbutton:ImageButton x:Name="ClearSwatchColor4" Grid.Row="0" Grid.Column="2" Style="{DynamicResource ButtonClearSwatchColor}" Margin="5,20,5,5" HorizontalAlignment="Left" Visibility="Hidden" Click="ClearSwatchColor_Click"/>
</StackPanel>
And the C#:
EDIT: Note: The button name is hard coded to show that it cannot find it, the end result will be a variable as its one method that several buttons will reference. This code triggers after the UI has loaded. (The user clicks a button and this code runs. Same window, same everything.)
var swatchClearButton = swatchClearStackPanel.FindName("ClearSwatchColor1");

TabIndex property is not working in Windows Phone 8 application

I am setting the TabIndex propertry inside the Grid.
My code is `
<Grid Margin="30,12" Grid.Row="1" Grid.Column="1" Background="White">
<TextBlock Foreground="#FF858585" Grid.Row="1" Grid.Column="0" Text="{Binding Path=LocalizedResources.Password, Source={StaticResource LocalizedStrings}}"
Padding="10,8" x:Name="tb_pwd" />
<PasswordBox TabIndex="1" Password="" Background="Transparent" BorderBrush="#FF1ba1e2"
Style="{StaticResource PwdBoxStyle}" Grid.Row="1" MaxLength="15" GotFocus="txtpwd_GotFocus_1" LostFocus="txtpwd_LostFocus_1" x:Name="txtpwd">
</PasswordBox>
</Grid>
<Grid Grid.Row="2" Grid.Column="1" Margin="30,0" Background="White">
<TextBlock Foreground="#FF858585" Grid.Row="2" Grid.Column="0" Text="{Binding Path=LocalizedResources.Domain, Source={StaticResource LocalizedStrings}}"
Padding="10,8" x:Name="tb_domain" />
<TextBox TabIndex="2" Text="" Background="Transparent" BorderBrush="#FF1ba1e2"
Style="{StaticResource TxtBoxStyle}"
Grid.Row="2" GotFocus="txtdomain_GotFocus_1"
LostFocus="txtdomain_LostFocus_1"
Grid.Column="1" x:Name="txtdomain" MaxLength="15" />
</Grid>`
But in emulator when i write username and click tab it does not work.
Any suggestions?
The SIP (keyboard) on windows phone does not include a tab key and so there is not support internally for this.
The de-facto convention in apps is to advance the tab focus from code when the user presses the enter key.
There are lots of resources online that show how to do this and helper classes to make it really simple.

Categories

Resources