Till now I have a combo-box control which displays all the available region language in the UI as a combo-box items.
its in WPF and MVVM
<ComboBox
x:Name="cbLanguage"
Grid.Row="1"
Height="30"
Width="200"
HorizontalAlignment="Center"
VerticalAlignment="Top"
ItemsSource="{Binding LocalLanguages,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
SelectedIndex="0">
But I saw this window and thought this looks much more legant and modern.
Can I do similar kind of window in WPF.
I tried to change the Combobox with list-box, List-view but no result.
Any help if there is any control in WPF which can do this.
This solves many problem specially if the combo box have more than 10 items user has to scroll through the all and then select the last index. But in this way user can select any locals as all are displayed in the UI. Even user can have the option to display alphabetically.
arraging items in 3 columns can be achieved by using UniformGrid as ItemsPanel
<ComboBox.ItemsPanel>
<ItemsPanelTemplate >
<UniformGrid Columns="3"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
modify ItemTemplate to change items apperance and have green color for selected item
i think it is necessary to modify ComboBox template to have custom header and footer in a dropDown (Edit Template-Edit a Copy in Visual Studio designer)
In WPF combobox is basically a Popup when the toggle button is pressed.
You could implement your own popup or you could have a look at the template of the ComboBox. Here is a link to ComboBox template
Related
on Windows 8.1 below code indicates the selected item of GridView. But on Windows Phone Xaml same code doesn't work like that. There isn't any visual indicator for selected item at all.(or i couldn't get it to work) How can i make it work like this on Windows Phone App too?
<GridView
x:Name="productColorChoices"
SelectionMode="Single"
ItemTemplate="{StaticResource productColorChoice_ItemTemplate}">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid
Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
If you go look at the GridViewItem default style template you'll see towards the bottom you have these objects in there;
SelectedBorder
SelectedCheckMarkOuter
SelectedCheckMark
SelectedEarmark
Which is what makes up the visuals for that selected outline/checkmark thingy on the GridView items. They all get shown according to the VisualState for Selected
Now, if you go and look at the phone's default style template for the GridViewItem's (which I couldn't find the default one for with a quick google search and I don't have a phone project open to go dig through) then you can compare. If these types of elements don't exist in the phone templates then you can go add them the same way using pretty much the same objects and the same storyboards in the same VisualState.
Hope this helps, cheers.
In WPF, is there any way to disable the scroll behavior of the ComboBox that auto-scrolls to the top of the list whenever a user reaches the end of the list? I'd rather that the list stayed at the end and the user have to manually scroll back to the top.
Heres the XAML for the ComboBox:
<ComboBox x:Name="CellProviderCombo" HorizontalAlignment="Left" Height="65" Margin="14,405,0,0" VerticalAlignment="Top" Width=" 327" Header="Cell Provider" PlaceholderText="Choose Cell Provider" DataContext="{StaticResource GlobalVars}" ItemsSource="{Binding GlobalShopInfo.CellProviders}" DisplayMemberPath="Name" SelectedValuePath="Name" IsDoubleTapEnabled="False"/>
As I said, if you scroll past the last element in the combobox it simply starts over at the bottom and the scroll bar shoots back up to the top automatically.
Turns out that the ComboBox in WPF is not the same ComboBox used in Windows Apps Windows.UI.Xaml.
The ComboBox used in Windows Apps uses a Carousel instead of a StackPanel to display its items. One of the effects this has is making it so when you reach the end of the list, it simply loops back to the top. The solution is to manually change the ItemsPanelTemplate to a StackPanel as follows:
<ComboBox x:Name="MyComboBox"> //Add other properties in this line as well if needed
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
Hope this helps anyone who has a similar issue.
I have a ListView and I bind to an ObservableCollection<Folder> and when I hover over a ListViewItem, there is a second selection thing appearing underneath (or ontop of) the item text which prevents me from being able to "activate" the selected item because it doesn't appear to be receiving my click.
As you can probably see, the structure is:
ListView > ItemTemplate > DataTemplate > ListViewItem. But I'm guessing I have that double-selection thing because there are basically 2 "item templates" (DataTemplate and ItemTemplate). But if I get rid of DataTemplate, it throws a runtime error. If I get rid of ItemTemplate, it throws an error. I can't win. How do I get rid of this thing?
Update:
This gives me the desired effect:
<StackPanel x:Name="folderContainer" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="175" Background="Khaki" Margin="0, 18, 0, 0">
<ListView x:Name="folderList" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Folder}" BorderBrush="{x:Null}" BorderThickness="0">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock x:Name="folderItem" Text="{Binding Name}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
With the ListViewItem you where including a specialized wrapper primarily used the ListView to contain unknown item(s) presented by the binding of the ItemsSource when there is default template used. It helps to show that unknown item on the screen, its the purpose of the ListViewItem. For example if someone bound a list of strings, the strings have no xaml style on hover, hence there needs to be a container control to achieve all things graphical in those situations.
Why the two Shadows?
The actual ListViewItem is at its heart (or actually its property), a content control containing what I surmise you had was a textbox control. That is now two controls thanks to the DataTemplate you provided.
Hence you had a wrapper, with a content containing a texbox control. So there are two things which take up space, one is the ListViewItem and the other is the textbox. By hovering over each item, each's style kicked off to show the padding of the control as a selectable region in the Zorder fashion whereas both are seen.
Nothing more nothing less.
Since you knew what is to go into the content control, there was no need to use the ListViewItem wrapper, it was redundant, and you used the actual textbox; hence with only it's style to show the padding of the single control on hover.
When my app is snapped displaying a GridView isn't the best way to present the information. I want to present it in a ListView instead. I also want to change the item template as well.
I currently have a UserControl that accepts the DataContext as the item template so I can simply create a new view and use that instead and it should work. So I'm basically looking to swap local:NormalDetailView with local:SnappedDetailView
Originally I thought about having both the ListView and GridView in there at the same time and adjusting the visibility based on snapped mode. But I had doubts about the performance about this technique.
Lastly, this is a LayoutAwarePage so I do have all that XAML stuff at the bottom about VisualStateManager.VisualStateGroups etc.
<GridView x:Name="GalleryGridView"ItemsSource="{Binding ListOfItems}">
<GridView.ItemTemplate>
<DataTemplate>
<local:NormalDetailView VerticalAlignment="Center" Width="250" Height="250" DataContext="{Binding}"/>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
The performance is just fine if you use both a gridview and a listview, and adjust visibility depending on view state. This is exactly what the "split-application" template in Visual Studio does.
Just generate an app based on this template and take a look at ItemsPage.xaml and ItemsPage.xaml.cs. The other templates may also do this, but I haven't used them so I don't know for sure.
I need to a collection of groupboxes varying on the user selection. for example; there will be 7 groupboxes, the user can enable however many they want and in what order they want. So i want the selected groupbox B to appear at the bottom of the previously selected groupbox A yet when A is unselected B moves up the form to where A was.
In my mind i want it to behave similar to HTML items.
This will be done in WPF, coding in C#.
You can stack these groupboxes in a stackpanel with orientation=vertical. You can then set the Visibility of the groupboxex to the users decision and wpf will make the rest for you "by magic".
Little sample here:
<StackPanel Orientation="Vertical">
<GroupBox x:Name="First" Visibility="Visible" Header="First">
<Label>First</Label>
</GroupBox>
<GroupBox x:Name="Second" Visibility="Collapsed" Header="Second">
<Label>Second</Label>
</GroupBox>
<GroupBox x:Name="Third" Visibility="Visible" Header="Third">
<Label>Third</Label>
</GroupBox>
</StackPanel>
Put your GroupBoxes in a collection of some kind and databind that collection to a cusomised ListView. Whenever the selected state of a GroupBox changes update the view of that ListView to sort them based on your requirements. Unfortunately I am not good enough to provide a working sample in the time I have, sry.