Search Results

Search found 69 results on 3 pages for 'itemspanel'.

Page 1/3 | 1 2 3  | Next Page >

  • WPF change ItemsPanel and ItemTemplate in code behind

    - by Tijs Hendriks
    Hi, I have the following list in XAML: <ListView Name="ListViewBack" Margin="3" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsPanel="{StaticResource IconListPanelTemplate}" ItemTemplate="{StaticResource IconListDataTemplate}"> </ListView> Now I would like to be able to change the ItemsPanel and ItemTemplate from the List to the Grid version. I've tried this using the following code: ListViewBack.ItemsPanel = Resources["IconGridPanelTemplate"] as ItemsPanelTemplate; ListViewBack.ItemTemplate = Resources["IconGridDataTemplate"] as DataTemplate; But nothing happens when excecuted. Any idea's? Thanks!

    Read the article

  • How add a ItemsPanel dynamically to listbox.

    - by Subhen
    Hi, I have a list Box which contains few Images in the itemsTemplate , like below: <ListBox.ItemTemplate> <DataTemplate> <StackPanel x:Name="stackPanelItems" Orientation="Horizontal"> <Image Source="{Binding strAlbumcoverImage}" Height="40" Width="40"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> Now onClick of a button I want to change the view and for that I want to add the wrap panel to the ListBox ItemsPanelas following: <ListBox.ItemsPanel> <ItemsPanelTemplate> <controlsToolkit:WrapPanel></controlsToolkit:WrapPanel> </ItemsPanelTemplate> </ListBox.ItemsPanel> Do I need to define the ItemsPanel Style in App.XAML and then assign it. Not quite sure about it. Thanks, Subhen

    Read the article

  • ItemsPanel vs Grid vs GridSplitter

    - by bitbonk
    I am currently trying to build a ControlTemplate for an ItemsControl that uses the Grid as its ItemsPanel where each item is stacked horizontally and delimited with a GridSplitter. The basic goal is to have a dynamic bindable ItemsControl where all items stack up in a row and where each item can be resized with a splitter. There are two things I can't wrap my head around: How is the GridSplitter supposed to end up automatically between each item? How do I set Grid.Column for each item.

    Read the article

  • WinRT ControlTemplate ItemsPanel

    - by user1427149
    I'm new to WinRT and am trying to create a standard gridview which has a group heading with a number of tiles beneath it. That bit is easy. I'm trying to modify it so that beneath the grid of tiles I can also add a footer using the containers style: <GridView x:Name="itemGridView" AutomationProperties.AutomationId="ItemGridView" AutomationProperties.Name="Grouped Items" Margin="116,0,40,46" ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}" ItemTemplate="{StaticResource Project200x200ItemTemplate}" SelectionMode="None" IsItemClickEnabled="True" ItemClick="ItemView_ItemClick"> <GridView.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </GridView.ItemsPanel> <GridView.GroupStyle> <GroupStyle> <GroupStyle.HeaderTemplate> <DataTemplate> <Grid Margin="1,0,0,6"> <Button AutomationProperties.Name="Group Title" Content="{Binding Name}" Click="Header_Click" Style="{StaticResource TextButtonStyle}" FontWeight="{Binding IsSelected, ConverterParameter=FontWeight, Converter={StaticResource BooleanToFontWeightConverter}}" /> </Grid> </DataTemplate> </GroupStyle.HeaderTemplate> <GroupStyle.Panel> <ItemsPanelTemplate> <VariableSizedWrapGrid Background="Red" Orientation="Vertical" Margin="0,0,40,0" /> </ItemsPanelTemplate> </GroupStyle.Panel> <GroupStyle.ContainerStyle> <Style TargetType="GroupItem"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <StackPanel> <ContentPresenter/> <ItemsPresenter/> <TextBlock Text="*** End of group ***"/> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> </GroupStyle.ContainerStyle> </GroupStyle> </GridView.GroupStyle> </GridView> This almost works but after adding the container style, the grid of tiles no longer shows... the group header and 'End of group' textblock is showing, but I've lost the tile grid. Can anyone spot what I'm doing wrong...?

    Read the article

  • WPF: HierarchicalDataTemplate ItemsPanel

    - by Echilon
    I have a TreeView which uses a custom ItemsPanel to show the first level of items in a StackPanel, but I need to show subitems in a StackPanel too. The problem is, the second level of items are shown in a WrapPanel, and as HierarchicalDataTemplate doesn't have an itemsPanel property I'm not sure how to do this. This is my xaml: <TreeView x:Name="treGlobalCards"> <TreeView.ItemsPanel> <ItemsPanelTemplate> <StackPanel IsItemsHost="True" Orientation="{Binding Orientation,RelativeSource={x:Static RelativeSource.TemplatedParent}}" MaxWidth="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"/> </ItemsPanelTemplate> </TreeView.ItemsPanel> <TreeView.ItemTemplate> <HierarchicalDataTemplate x:Key="CardTypeTemplate" ItemsSource="{Binding Cards}"> <TextBlock Text="{Binding Path=CardType}"/> </HierarchicalDataTemplate> </TreeView.ItemTemplate> </TreeView>

    Read the article

  • When using ItemsControl ItemsControl.ItemsPanel is set to Canvas, ContenPresenter comes in and break

    - by code-zoop
    I am using an ItemsControl where the ItemsPanel is set to Canvas (see this question for more background information). The ItemsControl is performing as I want, and it works like a charm when adding a child element manually by putting it into ItemsControl.Items: <ItemsControl> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas IsItemsHost="True" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.Items> <Button Canvas.Left="500" Content="Button Text" /> </ItemsControl.Items> </ItemsControl> Note the Canvas.Left property on the Button. This works like a charm, and the Button is placed 500 pixels from the left of the ItemsControl left side. Great! However, When I am defining a ItemsSource binding to a List, the Canvas.left doesn't have any effect: <ItemsControl ItemsSource="{Binding Elements}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas IsItemsHost="True" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button Canvas.Left="500" Content="Button Text" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> By inspecting the application during run time, I see one difference. The container ContentPresenter has been added between the Canvas and the button.. How can I set the Canvas.Left property on the ContentPresenter itself? Or is there another way to solve this problem? Thanks to all!

    Read the article

  • How to obtain the panel within a treeview (WPF)

    - by sperling
    How can one obtain the panel that is used within a TreeView? I've read that by default TreeView uses a VirtualizingStackPanel for this. When I look at a TreeView template, all I see is <ItemsPresenter />, which seems to hide the details of what panel is used. Possible solutions: 1) On the treeview instance ("tv"), from code, do this: tv.ItemsPanel. The problem is, this does not return a panel, but an ItemsPanelTemplate ("gets or sets the template that defines the panel that controls the layout of the items"). 2) Make a TreeView template that explicitly replaces <ItemsPresenter /> with your own ItemsControl.ItemsPanel. I am providing a special template anyways, so this is fine in my scenario. Then give a part name to the panel that you place within that template, and from code you can obtain that part (i.e. the panel). The problem with this? see below. (I am using a control named VirtualTreeView which is derived from TreeView, as is seen below): , use following: -- [sorry folks about poor formatting here, this is my first post, I tried 4 spaces for code... doesn't seem to work?] [I stripped out all clutter here for visibility...] The problem with this is: this immediately overrides any TreeView layout mechanism. Actually, you just get a blank screen, even when you have TreeViewItems filling the tree. Well, the reason I want to get a hold of the panel is to take some part in the MeaureOverride, but without going into all of that, I certainly do not want to rewrite the book of how to layout a treeview. I.e., doing this the step #2 way seems to invalidate the point of even using a TreeView in the first place. Sorry if there is some confusion here, thanks for any help you can offer.

    Read the article

  • WP7: Why does a ListBox.ItemsPanel break my ElementName data binding?

    - by iguanaNet
    I have a Windows Phone 7 ListBox that binds to a list of integers. I am using the default MVVM Light template, so there is a ViewModel class that contains data and a simple RelayCommand. Here is the ListBox: <ListBox ItemsSource="{Binding MyData}"> <ListBox.ItemTemplate> <DataTemplate> <Button Content="{Binding}"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <cmd:EventToCommand Command="{Binding ElementName=ContentGrid, Path=DataContext.TestCommand}" CommandParameter="{Binding}" /> </i:EventTrigger> </i:Interaction.Triggers> </Button> </DataTemplate> </ListBox.ItemTemplate> </ListBox> This displays a vertical list of integers inside buttons. If you click any of them, the following command code executes and shows a pop-up: new RelayCommand<int>(i => MessageBox.Show("Test" + i)); However, if I simply add the following XAML to change to a horizontal list, the databinding fails. Nothing happens when you click the button and no error messages are written to the Output window. <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> I have tried some other types of binding for the EventToCommand. For example, specifying my ViewModel as a static resource. It works, but is less ideal than the example above. Why does that ItemsPanel break the databinding?

    Read the article

  • Adventures in Windows 8: Placing items in a GridView with a ColumnSpan or RowSpan

    - by Laurent Bugnion
    Currently working on a Windows 8 app for an important client, I will be writing about small issues, tips and tricks, ideas and whatever occurs to me during the development and the integration of this app. When working with a GridView, it is quite common to use a VariableSizedWrapGrid as the ItemsPanel. This creates a nice flowing layout which will auto-adapt for various resolutions. This is ideal when you want to build views like the Windows 8 start menu. However immediately we notice that the Start menu allows to place items on one column (Smaller) or two columns (Larger). This switch happens through the AppBar. So how do we implement that in our app? Using ColumnSpan and RowSpan When you use a VariableSizedWrapGrid directly in your XAML, you can attach the VariableSizedWrapGrid.ColumnSpan and VariableSizedWrapGrid.RowSpan attached properties directly to an item to create the desired effect. For instance this code create this output (shown in Blend but it runs just the same): <VariableSizedWrapGrid ItemHeight="100" ItemWidth="100" Width="200" Orientation="Horizontal"> <Rectangle Fill="Purple" /> <Rectangle Fill="Orange" /> <Rectangle Fill="Yellow" VariableSizedWrapGrid.ColumnSpan="2" /> <Rectangle Fill="Red" VariableSizedWrapGrid.ColumnSpan="2" VariableSizedWrapGrid.RowSpan="2" /> <Rectangle Fill="Green" VariableSizedWrapGrid.RowSpan="2" /> <Rectangle Fill="Blue" /> <Rectangle Fill="LightGray" /> </VariableSizedWrapGrid> Using the VariableSizedWrapGrid as ItemsPanel When you use a GridView however, you typically bind the ItemsSource property to a collection, for example in a viewmodel. In that case, you want to be able to switch the ColumnSpan and RowSpan depending on properties on the item. I tried to find a way to bind the VariableSizedWrapGrid.ColumnSpan attached property on the GridView’s ItemContainerStyle template to an observable property on the item, but it didn’t work. Instead, I decided to use a StyleSelector to switch the GridViewItem’s style. Here’s how: First I added my two GridViews to my XAML as follows: <Page.Resources> <local:MainViewModel x:Key="Main" /> <DataTemplate x:Key="DataTemplate1"> <Grid Background="{Binding Brush}"> <TextBlock Text="{Binding BrushCode}" /> </Grid> </DataTemplate> </Page.Resources> <Page.DataContext> <Binding Source="{StaticResource Main}" /> </Page.DataContext> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}" Margin="20"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <GridView ItemsSource="{Binding Items}" ItemTemplate="{StaticResource DataTemplate1}" VerticalAlignment="Top"> <GridView.ItemsPanel> <ItemsPanelTemplate> <VariableSizedWrapGrid ItemHeight="150" ItemWidth="150" /> </ItemsPanelTemplate> </GridView.ItemsPanel> </GridView> <GridView Grid.Column="1" ItemsSource="{Binding Items}" ItemTemplate="{StaticResource DataTemplate1}" VerticalAlignment="Top"> <GridView.ItemsPanel> <ItemsPanelTemplate> <VariableSizedWrapGrid ItemHeight="100" ItemWidth="100" /> </ItemsPanelTemplate> </GridView.ItemsPanel> </GridView> </Grid> The MainViewModel looks like this: public class MainViewModel { public IList<Item> Items { get; private set; } public MainViewModel() { Items = new List<Item> { new Item { Brush = new SolidColorBrush(Colors.Red) }, new Item { Brush = new SolidColorBrush(Colors.Blue) }, new Item { Brush = new SolidColorBrush(Colors.Green), }, // And more... }; } } As for the Item class, I am using an MVVM Light ObservableObject but you can use your own simple implementation of INotifyPropertyChanged of course: public class Item : ObservableObject { public const string ColSpanPropertyName = "ColSpan"; private int _colSpan = 1; public int ColSpan { get { return _colSpan; } set { Set(ColSpanPropertyName, ref _colSpan, value); } } public SolidColorBrush Brush { get; set; } public string BrushCode { get { return Brush.Color.ToString(); } } } Then I copied the GridViewItem’s style locally. To do this, I use Expression Blend’s functionality. It has the disadvantage to copy a large portion of XAML to your application, but the HUGE advantage to allow you to change the look and feel of your GridViewItem everywhere in the application. For example, you can change the selection chrome, the item’s alignments and many other properties. Actually everytime I use a ListBox, ListView or any other data control, I typically copy the item style to a resource dictionary in my application and I tweak it. Note that Blend for Windows 8 apps is automatically installed with every edition of Visual Studio 2012 (including Express) so you have no excuses anymore not to use Blend :) Open MainPage.xaml in Expression Blend by right clicking on the MainPage.xaml file in the Solution Explorer and selecting Open in Blend from the context menu. Note that the items do not look very nice! The reason is that the default ItemContainerStyle sets the content’s alignment to “Center” which I never quite understood. Seems to me that you rather want the content to be stretched, but anyway it is easy to change.   Right click on the GridView on the left and select Edit Additional Templates, Edit Generated Item Container (ItemContainerStyle), Edit a Copy. In the Create Style Resource dialog, enter the name “DefaultGridViewItemStyle”, select “Application” and press OK. Side note 1: You need to save in a global resource dictionary because later we will need to retrieve that Style from a global location. Side note 2": I would rather copy the style to an external resource dictionary that I link into the App.xaml file, but I want to keep things simple here. Blend switches in Template edit mode. The template you are editing now is inside the ItemContainerStyle and will govern the appearance of your items. This is where, for instance, the “checked” chrome is defined, and where you can alter it if you need to. Note that you can reuse this style for all your GridViews even if you use a different DataTemplate for your items. Makes sense? I probably need to think about writing another blog post dedicated to the ItemContainerStyle :) In the breadcrumb bar on top of the page, click on the style icon. The property we want to change now can be changed in the Style instead of the Template, which is a better idea. Blend is not in Style edit mode, as you can see in the Objects and Timeline pane. In the Properties pane, in the Search box, enter the word “content”. This will filter all the properties containing that partial string, including the two we are interested in: HorizontalContentAlignment and VerticalContentAlignment. Set these two values to “Stretch” instead of the default “Center”. Using the breadcrumb bar again, set the scope back to the Page (by clicking on the first crumb on the left). Notice how the items are now showing as squares in the first GridView. We will now use the same ItemContainerStyle for the second GridView. To do this, right click on the second GridView and select Edit Additional Templates, Edit Generate Item Container, Apply Resource, DefaultGridViewItemStyle. The page now looks nicer: And now for the ColumnSpan! So now, let’s change the ColumnSpan property. First, let’s define a new Style that inherits the ItemContainerStyle we created before. Make sure that you save everything in Blend by pressing Ctrl-Shift-S. Open App.xaml in Visual Studio. Below the newly created DefaultGridViewItemStyle resource, add the following style: <Style x:Key="WideGridViewItemStyle" TargetType="GridViewItem" BasedOn="{StaticResource DefaultGridViewItemStyle}"> <Setter Property="VariableSizedWrapGrid.ColumnSpan" Value="2" /> </Style> Add a new class to the project, and name it MainItemStyleSelector. Implement the class as follows: public class MainItemStyleSelector : StyleSelector { protected override Style SelectStyleCore(object item, DependencyObject container) { var i = (Item)item; if (i.ColSpan == 2) { return Application.Current.Resources["WideGridViewItemStyle"] as Style; } return Application.Current.Resources["DefaultGridViewItemStyle"] as Style; } } In MainPage.xaml, add a resource to the Page.Resources section: <local:MainItemStyleSelector x:Key="MainItemStyleSelector" /> In MainPage.xaml, replace the ItemContainerStyle property on the first GridView with the ItemContainerStyleSelector property, pointing to the StaticResource we just defined. <GridView ItemsSource="{Binding Items}" ItemTemplate="{StaticResource DataTemplate1}" VerticalAlignment="Top" ItemContainerStyleSelector="{StaticResource MainItemStyleSelector}"> <GridView.ItemsPanel> <ItemsPanelTemplate> <VariableSizedWrapGrid ItemHeight="150" ItemWidth="150" /> </ItemsPanelTemplate> </GridView.ItemsPanel> </GridView> Do the same for the second GridView as well. Finally, in the MainViewModel, change the ColumnSpan property on the 3rd Item to 2. new Item { Brush = new SolidColorBrush(Colors.Green), ColSpan = 2 }, Running the application now creates the following image, which is what we wanted. Notice how the green item is now a “wide tile”. You can also experiment by creating different Styles, all inheriting the DefaultGridViewItemStyle and using different values of RowSpan for instance. This will allow you to create any layout you want, while leaving the heavy lifting of “flowing the layout” to the GridView control. What about changing these values dynamically? Of course as we can see in the Start menu, it would be nice to be able to change the ColumnSpan and maybe even the RowSpan values at runtime. Unfortunately at this time I have not found a good way to do that. I am investigating however and will make sure to post a follow up when I find what I am looking for!   Laurent Bugnion (GalaSoft) Subscribe | Twitter | Facebook | Flickr | LinkedIn

    Read the article

  • Why can't the style I have within a control template use templatebinding?

    - by Justin
    I have this control template that I am writing: <Style TargetType="{x:Type controls:InfoBar}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type controls:InfoBar}"> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"> <StackPanel> <Grid> <Grid.Resources> <Style TargetType="{x:Type TextBlock}"> <Setter Property="FontFamily" Value="{TemplateBinding FontFamily}" /> <Setter Property="FontSize" Value="{TemplateBinding FontSize}" /> <Setter Property="Foreground" Value="{TemplateBinding Foreground}" /> </Style> </Grid.Resources> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <ItemsControl Grid.Column="0" ItemsSource="{TemplateBinding LeftInfoBarTextBlockCollection}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> <ItemsControl Grid.Column="1" ItemsSource="{TemplateBinding MiddleInfoBarTextBlockCollection}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> <ItemsControl Grid.Column="2" ItemsSource="{TemplateBinding RightInfoBarTextBlockCollection}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </Grid> </StackPanel> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> This section of xaml is throwing member is not valid because it does not contain a valid type name. exceptions for the template bindings on FontFamily, FontSize and Foreground. <Grid.Resources> If I change it to this: <Grid.Resources> It will build, but when I debug it, I get this XmlParseExeption: Set property 'System.Windows.Setter.Value' threw an exception. If I change controls:InfoBar to Control, which InfoBar inherits from, I get the same exception. What am I doing wrong?

    Read the article

  • WPF ListBox's scrollviewer customizable so that there is no Scrollbar, only RepeatButtons

    - by John
    Hi I would like to customize the scrollbars of a listbox's scrollviewer in such a way that the scrollbar only consists of a RepeatButton for scrolling up and a Repeatbutton for scrolling down. Nothing else. There should be no scrollbar (track) between the buttons. One button should be to the left of the ItemsPanel (scroll up) and the other on the right of the ItemsPanel. Is that possible?

    Read the article

  • Adding a selection box into an ItemsControl?

    - by Jens
    I have a WPF ItemsControl with a Canvas ItemPanel. Drawing from an internal source, it displays lots of automatically generated Rectangles. As of now, it looks like this: <Window // .. NameSpaces > <Window.Resources> <DataTemplate x:Key="binTemplate"> <Rectangle x:Name="Rect" VerticalAlignment="Bottom" Canvas.Left="10" StrokeThickness="0"> // .. Databinding Height, Width, etc </Rectangle> </DataTemplate> </Window.Resources> <DockPanel x:Name="LayoutRoot" LastChildFill="True"> <ItemsControl ItemsSource="{Binding Bins}" ItemTemplate="{StaticResource binTemplate}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas MouseDown="Canvas_MouseDown" MouseMove="Canvas_MouseMove" MouseUp="Canvas_MouseUp"> <Rectangle x:Name="Selection" Canvas.Left="0" Canvas.Top="0" Visibility="Hidden" /> </Canvas> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> </DockPanel> </Window> I now try to implement a selection box, too.. well.. select my Rectangles. =) I tried just adding the box into the ItemsControl PanelTemplate, and controlling it with the Canvas mouse events, but it appears I am not allowed to do so. The error message is "Cannot explicitly modify Children collection of Panel used as ItemsPanel for ItemsControl. ItemsControl generates child elements for Panel." What is the preferred way to implement such behavior? I thought about overlaying another canvas (using negative Margin) and drawing the selection box in there, but that seems like a bad hack. Thanks in advance!

    Read the article

  • Scrollable Wrappanel in Silverlight

    - by Matt
    How do I make a Wrappanel scrollable? Here's the XAML that I've been using but I get errors with it. <ItemsControl x:Name="lbMedia"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <c:WrapPanel></c:WrapPanel> </ScrollViewer> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <im:MediaManagerItem></im:MediaManagerItem> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>

    Read the article

  • Setting Canvas properties in an ItemsControl DataTemplate

    - by atsjoo
    I'm trying to databind to this ItemsControl: <ItemsControl ItemsSource="{Binding Path=Nodes, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> By using this DataTemplate, I'm trying to individually position my Node elements correctly: <DataTemplate DataType="{x:Type Model:EndNode}"> <Controls:EndNodeControl Canvas.Left="{Binding Path=XPos}" Canvas.Top="{Binding Path=YPos}" /> </DataTemplate> However, it's not working as expected. All my node elements are drawn on top of each other in the same position. Any suggestions on how to accomplish this?

    Read the article

  • MVVM-Light Loaded Evented Executing Twice

    - by user275561
    Let me show the code first, The Control <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Controls:MatrixGrid x:Name="matrixGrid"> <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <cmd:EventToCommand Command="{Binding MatrixLoaded}" CommandParameter="{Binding ElementName=matrixGrid}" /> </i:EventTrigger> </i:Interaction.Triggers> </Controls:MatrixGrid> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> In The ViewModel Class I have public RelayCommand<MatrixGrid> MatrixLoaded { get; private set; } In The Constructor of the View Model I have MatrixLoaded = new RelayCommand<MatrixGrid>(MatrixGridAction); Now When I put a Breakpoint on the Function MatrixGridAction, The breakpoint is hit twice. Am I doing something wrong or is this a bug?

    Read the article

  • Displaying a collection of controls in a specific way in WPF

    - by Alvaro
    I have a collection of controls "MyCollection" wich changes in the Runtime. And I have to follow some constraints for that, for example: If my parameter "MyCollection.Count = 4" the property "NumberOfcolumns" will have the value 2, in order to create new Lines, and show the controls Two per Two. This is how I'm displaying my collection : <ItemsControl ItemsSource="{Binding MyCollection}" BorderThickness="0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" > <ItemsControl.ItemsPanel> <ItemsPanelTemplate > <UniformGrid Columns="{Binding NumberOfColumns}" VerticalAlignment="Center" HorizontalAlignment="Center" Background="Transparent"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> The problem is that my controls have different sizes, and as In UniformGrids, Cells are uniform... My design is not really pretty, because I have little controls shown in big Cells !! Can someone help me to solve this problem ? NB: Please give me a detailled solution if possible, not something like : "Use WrapPanel..."

    Read the article

  • XamlParseException using Silverlight Toolkit control in Expression Blend

    - by Dan Auclair
    I am having a strange issue opening up my UserControl in Expression Blend when using a Silverlight Toolkit control. My UserControl uses the toolkit's ListBoxDragDropTarget as follows: <controlsToolkit:ListBoxDragDropTarget mswindows:DragDrop.AllowDrop="True" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"> <ListBox ItemsSource="{Binding MyItemControls}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <controlsToolkit:WrapPanel/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> </controlsToolkit:ListBoxDragDropTarget> Everything works as expected at runtime and looks fine in Visual Studio 2008. However, when I try to open my UserControl in Blend I get XamlParseException: [Line: 0 Position: 0] and I can not see anything in the design view. More specifically Blend complains: The element "ListBoxDragDropTarget" could not be displayed because of a problem with System.Windows.Controls.ListBoxDragDropTarget: TargetType mismatch. My silverlight application is referencing System.Windows.Controls.Toolkit from the Nov. 2009 toolkit release, and I've made sure to include these namespace declarations for the ListBoxDragDropTarget: xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit" xmlns:mswindows="clr-namespace:Microsoft.Windows;assembly=System.Windows.Controls.Toolkit" If I comment out the ListBoxDragDropTarget control wrapper and just leave the ListBox I can see everything fine in the design view without errors. Furthermore, I realized this is happening with a variety of Silverlight Toolkit controls because if I comment out ListBoxDragDropTarget and replace it with <controlsToolkit:BusyIndicator /> the same exact error occurs in Blend. What is even weirder is that if I start a brand new silverlight application in blend I can add these toolkit elements without any kind of error, so it seems like something dumb that is happening with my project references to the toolkit assemblies. I'm pretty sure this has something to do with loading the default styles for the toolkit controls from its generic.xaml, since the error has to do with the TargetType and Blend is probably trying to load up the default styles. Has anyone encountered this issue before or have any ideas as to what may be my problem?

    Read the article

  • Custom activity in WF 4.0: WorkflowItemsPresenter wont show converted array

    - by lotusnote
    Hi There, we have an Array which is converted via a Binded Converter: else if (TTools.IsOfBaseClass(value.GetType(), typeof(System.Activities.Presentation.Model.ModelItemCollection))) { OurBaseClass[] test = (value as ModelItemCollection).GetCurrentValue() as OurBaseClass[]; List<OurBaseClass> listOfArray = new List<OurBaseClass>(); foreach (OurBaseClass item in test) { listOfArray.Add(item); } return listOfArray; } the convertion works well but it is not shown in our dynamically gui gui code with bindings: <sap:WorkflowItemsPresenter xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:sap="clr-namespace:System.Activities.Presentation;assembly=System.Activities.Presentation" Grid.Column="0" Name="MyArray" Items="{Binding Path=ModelItem.MyArray}" MinWidth="150" Margin="0"> <sap:WorkflowItemsPresenter.SpacerTemplate > <DataTemplate> <TextBlock Foreground="DarkGray" Margin="30">..</TextBlock> </DataTemplate> </sap:WorkflowItemsPresenter.SpacerTemplate> <sap:WorkflowItemsPresenter.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" HorizontalAlignment="Center" Margin="0"/> </ItemsPanelTemplate> </sap:WorkflowItemsPresenter.ItemsPanel> </sap:WorkflowItemsPresenter> Why is the gui not shown as a List??? it works well without converter. Thanks

    Read the article

  • XAML itemscontrol visibility

    - by Sam
    Hello, I have a ItemsControl in my XAML code. When some trigger occur i want to collapse the full itemsControl, so all the elements. <ItemsControl Name="VideoViewControl" ItemsSource="{Binding Videos}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel ItemHeight="120" ItemWidth="160" Name="wrapPanel1"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <views:VideoInMenuView /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> The trigger: <DataTrigger Value="videos" Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}, Path=DataContext.VideosEnable}"> <Setter Property="ScrollViewer.Visibility" Value="Visible" TargetName="test1" /> <Setter Property="ScrollViewer.Visibility" Value="Collapsed" TargetName="test2" /> <Setter Property="WrapPanel.Visibility" Value="Collapsed" TargetName="wrapPanel1" /> </DataTrigger> When I add the last setter the program crashes. Without this last setter it works fine but no visibility change.... What is wrong with this code? What is the write method to collapse all the elements of a ItemsControl with a trigger?

    Read the article

  • How to Set focus on the 1st Item of Nested Listbox in Silverlight?

    - by Subhen
    Hi , I have a List box which contains another lisbox Inside it. <ListBox x:Name="listBoxParent"> <ListBox.ItemTemplate> <DataTemplate> <Image x:Name="thumbNailImagePath" Source="/this.jpg" Style="{StaticResource ThumbNailPreview}" /> <TextBlock Margin="5" Text="{Binding Smthing}" Style="{StaticResource TitleBlock_Artist}" /> </StackPanel> <StackPanel Style="{StaticResource someStyle}" > <ListBox x:Name="listBoxChild" Loaded="listBoxChild_Loaded" BorderThickness="0"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Margin="5" Text="{Binding myText}" Width="300"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> <ListBox.ItemsPanel> </ListBox.ItemsPanel> </ListBox> Now while I try to focus to the child List Box : public void listBoxChild_Loaded(object sender, RoutedEventArgs e) { var myListBox = (ListBox)sender; myListBox .ItemsSource = PageVariables.eOUTData;//listboxSongsData; myListBox .SelectedIndex = 0; myListBox .Focus(); } Thanks, Subhen

    Read the article

  • WPF - Byte Array to Hex View (similar to Notepad++ HEX-Editor plugin)

    - by tenfour
    I am using an ItemsControl to display a List<byte> in hex. The ItemsPanelTemplate is a UniformGrid with a fixed number of columns: <ItemsControl HorizontalAlignment="Left" VerticalAlignment="Top" ItemsSource="{Binding}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <UniformGrid Columns="16"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding StringFormat='\{0:X2\}'}" Margin="5,5,5,0"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> I'd like to prefix each row with an 'Address' column, just like you'd see with the Notepad++ 'HEX-Editor' plugin. That is, since I have 16 columns, each row should be prefixed something like this: 0000 [00 01 02 .... 0F] 0010 [10 11 12 .... 1F] 0020 [20 21 22 .... 2F] ... Any suggestions?

    Read the article

  • Silverlight 3 - Data Binding Position of a rectangle on a canvas

    - by Blounty
    Hi Everyone, I am currently trying to bind a collection of objects to a Canvas in Silverlight 3 using an ItemsControl as below: <ItemsControl x:Name="ctrl" ItemsSource="{Binding myObjectsCollection}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <Canvas></Canvas> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Rectangle Stroke="LightGray" Fill="Black" StrokeThickness="2" RadiusX="15" RadiusY="15" Canvas.Left="{Binding XAxis}" Height="25" Width="25"> </Rectangle> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> Unfortunately it seems the binding on the Canvas.Left is being ignored. From what i have learned here it would appear this is due to the items being placed inside a content presenter not the actual canvas i have specified in the items panel. Is there a way i can use data binding to determine the position of elements on a canvas?

    Read the article

  • Binding WPF ComboBox in XAML - Why is it Empty?

    - by mdiehl13
    I am trying to learn how to bind my simple database (.sdf) to a combobox. I created a dataset with my tables in it. I then dragged a table from the DataSource onto my control. There are no build warnings/errors, and when it runs, the ComboBox is empty. <UserControl x:Class="OurFamilyFinances.TabItems.TransactionTab" 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:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" d:DesignHeight="414" d:DesignWidth="578" xmlns:my="clr-namespace:OurFamilyFinances" Loaded="UserControl_Loaded_1"> <UserControl.Resources> <my:FinancesDataDataSet x:Key="financesDataDataSet" /> <CollectionViewSource x:Key="accountViewSource" Source="{Binding Path=Account, Source={StaticResource financesDataDataSet}}" /> </UserControl.Resources> <Grid> <ComboBox DisplayMemberPath="Name" Height="23" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource accountViewSource}}" Margin="3,141,0,0" Name="accountComboBox" SelectedValuePath="ID" VerticalAlignment="Top" Width="120"> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate> </ComboBox.ItemsPanel> </ComboBox> </Grid> The paths that is shows are correct, the selectedPath is "ID" and the displaypath is "Name". If I do this in Linq to Sql, the combo box does populate: this.accountComboBox.ItemsSource = from o in db.Account select new { o.ID, o.Name }; But I would like to learn how to do this in XAML. I have dragged datagrids from the DataSource as well, but they are not populated either. Any idea?

    Read the article

  • Stackpanel add item animation

    - by grzegorz_p
    Hello, I've been struggling a while with marquee-style image scrolling control. At a moment, I stuck up with templated ItemsControl: <Window.Resources> <DataTemplate x:Key="itemsTemplate"> <Image Source="{Binding AbsolutePath}"></Image> </DataTemplate> </Window.Resources> <ItemsControl ItemTemplate="{StaticResource itemsTemplate}" x:Name="ic" ItemsSource="{Binding ElementName=mainWindow, Path=DataItems}" VirtualizingStackPanel.IsVirtualizing="True"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Vertical" VerticalAlignment="Bottom" VirtualizingStackPanel.IsVirtualizing="True" > </VirtualizingStackPanel> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> ItemsControl is bound to ObservableCollection, so I can add items at runtime. As soon as item goes off-screen it's removed from ObservableCollection. The last thing to do is implementing custom item add behavior (smooth slide-in instead of insert-translateothers behavior). Shall I derive from StackPanel to achieve such effect or just perform DoubleAnimation on currently adding item? Any suggestions appreciated.

    Read the article

  • Windows Phone 7 ListBox uncustomizable?

    - by Roy
    I've just recently started development using Visual Studio 2010 Express for Windows Phone and I put in a ListBox. I can't seem to manipulate the formatting. No matter what I do, the background is black/gray, the selected items have a blue border, and there is padding between the items in the listbox (i'm using images). Here is my code: Xaml: <Grid x:Name="ContentGrid" Grid.Row="1"> <Grid Name="gallery"> <Grid.RowDefinitions> <RowDefinition Height="370" /> <RowDefinition Height="150" /> </Grid.RowDefinitions> <Border BorderBrush="Red" Width="450" CornerRadius="4" BorderThickness="2" Background="Red" Margin="10,30,20,10" Padding="6,6,6,6"> <Image Grid.Row="0" Grid.Column="0" Height="360" x:Name="imgPreview"/> </Border> <ListBox x:Name="lbScrollGallery" Grid.Row="1" Grid.Column="0" Padding="0" VerticalAlignment="Top" Width="450" SelectionChanged="ScrollerSelectionChanged" d:LayoutOverrides="HorizontalAlignment" ScrollViewer.HorizontalScrollBarVisibility="Hidden"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Image Width="100" Height="100" Stretch="Fill" Name="imgSource" VerticalAlignment="Center" Source="{Binding Path=Url}" /> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> </Grid> Is there some way I can customize the listbox? Like change the background to red or make the padding between different items 0?

    Read the article

1 2 3  | Next Page >