datatemplate

Getting value from a control inside DataTemplate windows phone 7

你离开我真会死。 提交于 2019-12-13 04:33:51
问题 Iam working on dataTemplate in windows phone 7. I had customised Listbox with data template. now i need to get the values from the customised listbox. Please check the code is below. <phone:PhoneApplicationPage.Resources> <Style x:Key="Image_List" TargetType="ListBox"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ListBox"> <Grid> <Rectangle Fill="#FF030403" RadiusY="10" RadiusX="10" Stroke="#1BA1E2" StrokeThickness="2"/> <ScrollViewer x:Name="ScrollViewer">

XAML: Custom Binding in DataTemplate for use in GridViewColumn CellTemplate

微笑、不失礼 提交于 2019-12-12 21:58:44
问题 I have the following DataTemplate in resources that I would like to reuse throughout a GridView. <Window.Resources> <DataTemplate x:Key="NumericalDataTemplate" DataType="GridViewColumn.CellTemplate"> <StackPanel Orientation="Horizontal" Height="32"> <TextBlock Text="{Binding MyLength}" VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBlock.Style> <Style TargetType="{x:Type TextBlock}" > <Setter Property="Visibility" Value="Visible" /> <Style.Triggers> <DataTrigger Binding="

DataContext of DataTemplate in ToolTip Style in WPF

▼魔方 西西 提交于 2019-12-12 18:19:41
问题 I can't seem to find the right DataContext for the Grid in the ToolTipStyle Style. Just a blank ToolTip appears. <Window.Resources> <DataTemplate x:Key="ListTemplate"> <StackPanel> <Grid> <TextBlock Text="{Binding Path=Name}"> <TextBlock.ToolTip> <ToolTip Style="{StaticResource ToolTipStyle}" /> </TextBlock.ToolTip> </TextBlock> </Grid> </StackPanel> </DataTemplate> <Style TargetType="ToolTip" x:Key="ToolTipStyle"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <Grid>

Is there something in WPF similar to Style.BasedOn for DataTemplate?

好久不见. 提交于 2019-12-12 13:28:59
问题 At the moment, I have two very large DataTemplate objects to display two sets of items in two ListBoxes. The DataTemplates are referenced in the ContentTemplate property in two Styles that are set in the ItemContainerStyle properties of the two ListBoxes. The items are of the same type and the DataTemplates are identical except for the following control: From DataTemplate1 <TextBlock Style="{StaticResource TextStyle}" FontSize="20" Foreground="White" HorizontalAlignment="Left" Panel.ZIndex="2

WPF DataTemplate Binding

痞子三分冷 提交于 2019-12-12 12:28:11
问题 I discovered when using a ContentTemplate/DataTemplate in a WPF TabControl my Bindings will not work anymore. I have set up a small example to illustrate: <Window x:Class="HAND.BindingExample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="BindingExample" Height="506" Width="656" DataContext="{Binding RelativeSource={RelativeSource Self}}" > <Grid> <TabControl HorizontalAlignment="Left" Height="381"

Problem with the mouse click on toggleButton in WPF

左心房为你撑大大i 提交于 2019-12-12 12:05:07
问题 I made a custom control template that turns a groupbox into an expander (clicking on the header expands/collapses the content of the groupbox). It works fine except that mouse clicks don't always go through: sometimes it doesn't expand/collapse when you click on the header, esp. when you click inside the "o"s in the word "Colors". I organically thought it was caused by the text in the header trapping mouse clicks which prevent them from going through so I played around with the

Distinct item template for first and last item in a ListView

好久不见. 提交于 2019-12-12 07:47:30
问题 I need to style the first and last items of a list view differently. To achieve that, I started working on a solution based on that answer: Use different template for last item in a WPF itemscontrol Basically, I have a custom ItemsTemplateSelector that decide on the template to apply based on the item's index in the list view items (code below). It works properly except that when the list gets updated (an item is added or removed), the templates do not get selected again (for instance,

WPF: How to change the visibility of my ComboBox Items?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 06:48:42
问题 I know that this topic is already answered, but i couldn't solve the problem with the solution that i found. So here is my code: <DataGrid HeadersVisibility="Column" Name="griglia" Grid.Row="2" ItemsSource="{Binding Path=Test}" AutoGenerateColumns="True" IsReadOnly="True" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible"> <DataGrid.ColumnHeaderStyle> <Style TargetType="{x:Type DataGridColumnHeader}">

Constraining item heights in WPF ListBox, with indicator

[亡魂溺海] 提交于 2019-12-12 04:06:07
问题 I have a ListBox control in WPF which contains items of variable height (predominantly a large text block, so it's also affected by word wrapping). Since scrolling behaves badly when the height of an individual item gets too high (especially when close to the height of the ListBox itself), I want to constrain the max height of the individual items. I've done that readily enough, by using a Style to set the MaxHeight of the ListBoxItem container. My problem is that I would like to detect that

vary a xaml template by type

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 03:38:23
问题 Below is a piece of a DataTemplate that defines a strip if commands (buttons with images) for contacting clients. Currently defined for telephone contacts, there are several more commands, so I want to reuse this for other types of contact methods (email, etc.) The way it and the view models behind it are designed, there are only two things that need to vary to do this: The image and tool tip for the ContactCommand button The entire last button It seems the most reusable approach would be to