How to show Combobox values to up direction in wpf - wpf

I have a combobox in WPF. In generally the values from combobox will populate in down/bottom direction. I have a requirement to populate in up direction. How can i do this?
Thanks in advance!

You should change the ControlTemplate for the ComboBox. Here you can find a ControlTemplate example: https://learn.microsoft.com/en-us/dotnet/framework/wpf/controls/combobox-styles-and-templates.
Look for the Popup part and change Placement from Bottom to Top.
<Popup x:Name="Popup"
Placement="Top"
<!-- more stuff here -->
/>

Related

Style in HeaderColumn in Datagrid

Please see this following image of my datagird.
Now want a border in headerColumn. I have tried columnheader style but it did not work for me.
I want following style of header of datagrid.Please see the following image.
How can i achieve this style in datagird.
Thanks
You have to change the DataGrid template, not columnheader. In the default DataGrid template there is:
<sdk:DataGridColumnHeadersPresenter x:Name="ColumnHeadersPresenter" Grid.Column="1"/>
I think you have to edit over there.

How have a list inside a popup control in C#/XAML metro application?

i would like to know :-
How to have a list inside a popup control in metro application ?
Please let me know how can i workaround this
Thanks in Advance.
<Popup x:Name="popup">
<Grid >
<ListBox x:Name="listBox" />
</Grid>
</Popup>
Why not try collapsing the visibility of the main grid when the popup is activated, or knock the opacity back to leave a ghost image behind the popup whilst calling IsHitTestVisible=false on the main grid to render it inactive.

How to align the button at the leftmost side in a listbox control?

I am developing window phone 7 application. I am new to the silverlight. I am dynamically creating the button control and binding these all button controls to the listbox.
<ListBox x:Name="lstButtons" Margin="393,-28,-12,28" Background="Orange">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Button Content="{Binding ElementName}" Width="100" HorizontalAlignment="Right"></Button>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Now I want to display the button control at the leftmost side means I want to display the button control near to the left border of the listbox. I want to display the button control which is aligned to the left. With my above code the the button control appears in the center in the listbox ? How should I align it to the left ? Can you please provide me any code or link through which I can resolve the above issue ? If I am doing anything wrong then please guide me.
Take a look at the sample XAML in the MSDN resource page here. You need to play with the HorizontalAlignment property of the element you are trying to align within the parent, perhaps fine tune the alignment by setting the margin property of the element.
This might not be very helpful, but I have found that using expression blend for layout/ui things like this is the easiest way to do it. You will have to drill into the list template then you can play around with alignments.
For this scenario you need to align the button dynamically. In the following code the button is aligned at the left side in the listbox control. It is aligned close to the left border of the listbox control.
Button AlphabetButton = new Button();
AlphabetButton.Margin = new Thickness(-10,-27,0,0);
AlphabetButton.Width = 80;
AlphabetButton.Height = 80;

WPF resizing TextBlock

I have a textblock in a grid in WPF.
I want the text to dynamically size (font) when resized. At the moment textboxes, comboboxes do this, but the the textblock stays the same. Is it possible?
Instead of trying to manually rig a TextBlock to do this, just edit the default template of a TextBox and remove the border and background, then in the style make it set the IsReadOnly flag. This way you get the textblock sizing, as well as copy-paste for free.
You can use a ViewBox for this.
eg:
<Viewbox Stretch="Uniform">
<TextBlock Text="Test" />
</Viewbox>
use expression blend for getting the default template of TextBox, then you can edit it as you required.

Nonstandard floating layout - grow then stop

Here is the sample pseudo XAML code
<Window>
<Grid Rows="2">
<Listbox Row="0"/>
<Button Row="1"/>
</Grid>
</Window>
Grid doesn't work here, just for example
Listbox is databinded and can have multiple items
Button is placed under the ListBox - immediately under, not on bottom of window
Listbox can grow, moving Button down until Button is on bottom of window. Then Listbox gets vertical scrollbar and scrolls its items, with Button remaining on bottom.
I can't remember seeing such layout, and think it can't be done without binding to ActualHeight/using some converter code, which i'm really bad.
Thanks in advance.
Use a StackPanel instead of your Grid.

Resources