|
Thanks Pete - I owe you one. That would help plenty.
|
|
|
|
|
|
OMG! That's awesome Pete! You have inspired me to start looking at putting up a blog. I would really love to share what I know with the world.
Thanks for the information. It's very, very helpful.
Blitz
|
|
|
|
|
You're welcome. Blogging is really good fun.
|
|
|
|
|
|
|
The second code snippet in the link in my response to the last question shows how to create rows and columns at runtime.
|
|
|
|
|
|
The grid rows and columns are created in the code-behind. From the referenced post:
'finds the actual grid used by the list box
Dim d As DependencyObject
d = VisualTreeHelper.GetParent( _
lstItems.ItemContainerGenerator.ContainerFromIndex(0))
While Not (d Is Nothing OrElse d.GetType() Is GetType(Grid))
d = VisualTreeHelper.GetParent(d)
End While
If d Is Nothing Then Exit Sub
'once you have the grid, you need to add the rows and columns
Dim rd As RowDefinition
Dim cd As ColumnDefinition
Dim grd As Grid = CType(d, Grid)
lstItems.SetValue(Grid.IsSharedSizeScopeProperty, True)
For i As Integer = 0 To 63
rd = New RowDefinition
rd.Height = New GridLength(1, GridUnitType.Star)
grd.RowDefinitions.Add(rd)
cd = New ColumnDefinition
cd.Width = New GridLength(1, GridUnitType.Star)
grd.ColumnDefinitions.Add(cd)
Next
'this is just for debugging purposes
grd.ShowGridLines = True
You have the right ItemsPanel and ItemContainerStyle, now you just need to bind to the ItemsSource property to get the items. Since you seem to have something you can bind to in XAML, just move the ItemsSource binding from the inner ItemsControl to the ListBox and get rid of the ItemsControl.
<!-- moved the data binding for AvailableObjects to here -->
<ListBox Name="lstItems" Background="Green" ItemsSource="{Binding Path=AvailableObjects}>
<ListBox.ItemsPanel>
<!-- what you have here is right -->
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<!-- what you have here is right -->
</ListBox.ItemContainerStyle>
<!-- this is wrong, you are adding an items control to the list box
as its only item, you need to do set ItemsSource instead -->
<ItemsControl FontWeight="Normal" ItemsSource="{Binding Path=AvailableObjects}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button
Grid.Row="{Binding Path=YLoc}"
Grid.Column="{Binding Path=XLoc}"
Content="{Binding Path=ObjectText}"
Margin="2,3.5"
/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ListBox>
|
|
|
|
|
|
|
|
Check the Immediate debugging window when the UserControl is loaded. Are there warnings about not being able to perform a binding because the property Strip cannot be found on object of some type or another? If so, that is referring to the ItemContainerStyle and you should bind to Content.Strip and Content.Panel instead.
As far as the grid, I did pull out two lines when I copied from the previous post because I thought they would not be necessary. Apparently I should have tested that assumption first. The lines I pulled out made each row and column part of a SharedSizeGroup since the grid does not always seem to size * columns the way it seems like it should.
for (int strip = 0; strip < _stripsPerPanel; strip++)
{
rd = new RowDefinition();
rd.Height = new GridLength(1, GridUnitType.Star);
rd.SharedSizeGroup = "RowGroup";
grd.RowDefinitions.Add(rd);
}
for (int part = 0; part < _partsPerStrip; part++)
{
cd = new ColumnDefinition();
cd.Width = new GridLength(1, GridUnitType.Star);
cd.SharedSizeGroup = "ColumnGroup";
grd.ColumnDefinitions.Add(cd);
}
|
|
|
|
|
|
|
In the thread above this one, the same situation came up. You will need to use the ItemContainerStyle instead of the ItemTemplate.
|
|
|
|
|
Hi,
I am working on an AddIn to the Microsoft Outlook Office. I have added an HTML Folder to Personal folders section in Outlook 2007. When I click on the folder, im redirecting to specified url. When I specify the internet application (both web and silverlight applications), its working fine. But If I specify an intranet silverlight application its not working. Its working for normal intranet web applications.
Please let me know why it is not working for intranet silverlight applications only?
here is the code..
Outlook.MAPIFolder newView = null;
newView = (Outlook.MAPIFolder)inBox.Folders.Add("TUIPoC", Outlook.OlDefaultFolders.olFolderInbox);
newView.WebViewURL = "http://....";
newView.WebViewOn = true;
TUIPoC is the folder name that i have created.
Please help me.
Thanks in Advance,
AR Reddy
|
|
|
|
|
AR Reddy wrote: If I specify an intranet silverlight application its not working.
How is the Silverlight app hosted? Is it accessible from a regular browser?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hai All
I need to use templates for changing the background color for each date in calendar control . Can any one tell me how to use templates for calendar control. Help me plz.
|
|
|
|
|
|
Even 3rd party one will do.
Thanks
Amit
|
|
|
|
|
<Style x:Key="MultiSelectComboBox" TargetType="{x:Type ComboBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid SnapsToDevicePixels="true" x:Name="MainGrid" Height="Auto" Width="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="0"/>
</Grid.ColumnDefinitions>
<Popup AllowsTransparency="true" IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
Margin="1" x:Name="PART_Popup" Grid.ColumnSpan="2">
<Border x:Name="DropDownBorder" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding Path=ActualWidth, ElementName=MainGrid}">
<ScrollViewer CanContentScroll="true">
<ListBox x:Name="lstBox" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
KeyboardNavigation.DirectionalNavigation="Contained" SelectionMode="Multiple" ItemsSource="{TemplateBinding ItemsSource}"/>
</ScrollViewer>
</Border>
</Popup>
<ToggleButton Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" Grid.ColumnSpan="2"
IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{DynamicResource ToggleButtonStyle1}"/>
<ItemsControl IsHitTestVisible="false" ItemsSource="{Binding Path=SelectedItems, ElementName=lstBox}" Margin="4,0,0,0">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel IsItemsHost="True" Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ToggleButtonStyle1" TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Background="{TemplateBinding Background}" BorderThickness="1,1,1,1" BorderBrush="{TemplateBinding BorderBrush}">
<Grid Width="Auto" Height="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.884*"/>
<ColumnDefinition Width="0.116*"/>
</Grid.ColumnDefinitions>
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" Grid.ColumnSpan="2" VerticalAlignment="Center" Margin="0,0,0,0"/>
<Path d:LayoutOverrides="GridBox" HorizontalAlignment="Center" Margin="4,6,4,6" Fill="#FF000000" Stretch="Fill" Stroke="#FF000000" Data="M0.5,0.5 L28.364,0.5 15.314,22.374998 15.314,22.374999 z" x:Name="down" VerticalAlignment="Center" Width="Auto" Height="Auto" Grid.Column="1"/>
<Path d:LayoutOverrides="GridBox" HorizontalAlignment="Center" Margin="4,6,4,6" Fill="#FF000000" Stretch="Fill" Stroke="#FF000000" Data="M9.3139996,0.5 L9.3139996,0.5 18.8,18.4 0.5,18.4 z" x:Name="up" Visibility="Collapsed" VerticalAlignment="Center" Width="Auto" Height="Auto" Grid.Column="1"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="Visibility" TargetName="down" Value="Collapsed"/>
<Setter Property="Visibility" TargetName="up" Value="Visible"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="#ADADAD"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Grid x:Name="LayoutRoot">
<ComboBox IsSynchronizedWithCurrentItem="True" x:Name="cmbBox" Style="{DynamicResource MultiSelectComboBox}" VerticalAlignment="Top" Height="29.6" Margin="71.2,52,74.4,0"/>
</Grid>
cmbBox.ItemsSource = new List<string>() { "A", "B", "C", "D", "E", "F", "G", "H", "I" };
|
|
|
|
|
i dont know, but you can easyly create it by your own.
create a usercontrol with a grid. add a textbox, a button and
a listbox. listbox height = 0. on button click listbox height = yourvalue.
if you want i can wirte it for you. tell me
best regards tobias schiebel
|
|
|
|
|
My Silverlight play project right now calls for me to use a simple listing of 'things' and display them to the user. Each of these things is going to be a template comprised of an image and two lines of text. One of the lines I need to click on and launch a file...
I was going to play around with a data-bound list box and use a data template, but it really occurred to me that perhaps that is even more than I need because then I need to create an object, stuff data into it in the xaml and data bind to that.
Why not just use a stack panel and inside that stack pan create several nested stack panels for my items. My thought was that I can then simply turn on a scroll bar for the outer stack panel and I would be done. Not elegant but simple for a small non-dynamic list of 10-15 items that doe snot really need to be data-bound as it changes very little, if ever. Using a list box win windows forms I could do this by simply adding list items manually. IN HTML I could mock this up using a set of nested tables and stuff...
What is the simplest way to do this in Silverlight? I'm asking this now with the intent to go home latter today and get back to it having spent some time at it last night (I can't do Dot-net dev on my machine at work (yet)) so I can't play here just now.
Oh, and nope, this is not homework I wish it was, but it's not...
|
|
|
|
|
There's nothing wrong with the StackPanel-in-a-ScrollViewer approach if
that's all you need.
The ListBox and it's ancestor classes
System.Windows.Controls.ItemsControl
System.Windows.Controls.Primitives.Selector
System.Windows.Controls.ListBox
are really geared toward working with collections of data items, where
templating can make things much more flexible.
For static elements that don't need to have templates applied dynamically,
a stackpanel works just fine.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|