datatemplate

Find an element in DataTemplate applied to TabItem

爷,独闯天下 提交于 2019-12-02 12:28:25
I got a problem trying to find an element declared in DataTemplate, that after was applied like a ContentTemplate to TabItem object. I saw that there is already some solutions in regard of this problem, but no one of them actually works in my case, and I would like to understand why (obviously I make mistake in some place) Here is a sample code: <DataTemplate x:Key="TabItemDataTemplate"> <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="templateGrid"> <Grid.RowDefinitions> <RowDefinition Height="6.0*"> </RowDefinition> <RowDefinition Height="6" ></RowDefinition>

WPF: How to set bool to true from DataTemplate for Button?

血红的双手。 提交于 2019-12-02 08:59:46
I know it is possible to do this by working with ICommand, but since this is the only place in my whole project where this is needed, I am asking myself, if there is maybe a better solution than implementing RelayCommand and ICommand and an additional method in my otherwise property-only class? Maybe my scenario may help here: I have a ListView which is bound to a list of properties (this is a custom-class I made to display those). I have a button in eacht row of entries, that I want to set the "IsToDelete"-Property to true. If "IsToDelete" is true, all the controls I show in my ListView will

How to access data from another datatemplate in wpf?

徘徊边缘 提交于 2019-12-02 08:25:38
I have 2 Datatemplates. One contain a grid , second one contain a button. I need to send command parameters of button as selected grid items. How can i do this ? <ObjectDataProvider x:Key="Datas" ObjectType="{x:Type ViewModel:UserControlViewModel}"></ObjectDataProvider> <DataTemplate x:Key="SourceGrid"> <WPFToolKit:DataGrid x:Name="SourceDataGrid" ItemsSource="{Binding Source={StaticResource Datas},Path=SourceGridData}" CanUserSortColumns="True" GridLinesVisibility="None" IsSynchronizedWithCurrentItem="True" SelectionUnit="FullRow"></WPFToolKit:DataGrid> </DataTemplate> <DataTemplate x:Key=

Access XAML Control In DataTemplate From CodeBehind?

微笑、不失礼 提交于 2019-12-02 08:25:27
问题 I have a control that I am unable to access in the codebehind, and I believe it is because it is defined in a DataTempalte. The overall control is a slide show carousel. Each slide can be an Image or a MediaElement (video), the contents of which are defined in an ItemSource binding. The carousel is on a timer to switch from one slide to the next. Each time the slide changes I fire an event to that effect. When I hit a slide with a video I'd like to stop the slide timer (done that) and start

Change ListBoxItem Background Color when mouse is over on the listBoxItem

断了今生、忘了曾经 提交于 2019-12-02 06:48:32
问题 I need to set change background color for list item when mouse is over. Here is my code: <DataTemplate x:Key="ListBoxSubCategoryListTemplate" DataType="{x:Type ListBoxItem}"> <StackPanel> <Button x:Name="btnSubCategoryList" Template="{StaticResource subCategoryListItems}" Content="{Binding Path=sub_category_name}" Background="Transparent" Height="25"/> </StackPanel> </DataTemplate> <ControlTemplate x:Key="subCategoryListItems" TargetType="{x:Type Button}"> <StackPanel FlowDirection=

in WPF I need to have a collection of a collection of drawing objects

只谈情不闲聊 提交于 2019-12-02 05:04:11
I have a WPF project that draws several things in a panel. For the next release I need to add another type of thing to draw in addition to the existing things. Currently I have a grid that contains an ItemsControl which contains an ItemsPanel and an ItemsSource. The existing ItemsSource looks something like this: <ItemsControl.ItemsSource> <CompositeCollection> <CollectionContainer Collection="{Binding Source={StaticResource MainWindowResource}, Path=DottedLines, Mode=OneWay}"/> <CollectionContainer Collection="{Binding Source={StaticResource MainWindowResource}, Path=BarrierLines, Mode=OneWay

How to programmatically bind a (dependency) property of a control that's inside a DataTemplate?

南楼画角 提交于 2019-12-02 04:21:11
The TextBlock resides in a DataTemplate , thus I can't refer to it by its name. So how do I bind its (e.g.) Text property programmatically? XAML: <UserControl x:Class="MyNameSpace.MyCustomControl" ... > ... <ListBox ItemsSource="{Binding Path=ItemsSource}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> ... </UserControl> Code: public partial class MyCustomControl : UserControl { ... public static readonly DependencyProperty DataSourceProperty = DependencyProperty.Register("DataSource",

dynamic datatemplate with valueconverter

China☆狼群 提交于 2019-12-02 04:13:58
I want to show data in a wpftoolkit datagrid where the data is a collection of public class Thing { public string Foo { get; set; } public string Bar { get; set; } public List<Candidate> Candidates { get; set; } } public class Candidate { public string Name { get; set; } public CandidateType CandidateType { get; set; } } public enum CandidateType { Type1, Type2, Type42 } where the number of candidates in Candidates list is configurable at runtime. Desired grid layout looks like this Foo | Bar | Candidate 1 | Candidate 2 | ... | Candidate N Thus it seems I cannot create a DataTemplate for the

WPF - using CroppedBitmap in DataTemplate

筅森魡賤 提交于 2019-12-02 03:30:54
问题 The following xaml works ok inside a Window : <Border Width="45" Height="55" CornerRadius="10" > <Border.Background> <ImageBrush> <ImageBrush.ImageSource> <CroppedBitmap Source="profile.jpg" SourceRect="0 0 45 55"/> </ImageBrush.ImageSource> </ImageBrush> </Border.Background> </Border> But when I use the equivalent code in a DataTemplate I get the following error in run-time: Failed object initialization (ISupportInitialize.EndInit). 'Source' property is not set. Error at object 'System

Is it possible to create a template for a GridViewColumn, without fixed data binding?

风格不统一 提交于 2019-12-02 02:59:49
问题 Is this possible? I have a ListView and I want to create a template for the columns, so that each column that I mark as a 'cellTextBox' displays with a textbox in it (and also calls the TextBox_LostFocus() on the LostFocus event). I'd really like to use a single template rather than defining a DockPanel and TextBox for every single column. However, each column is going to be bound to a different column in the data source. In other words, I'd like a "cookie cutter" for GridViewColumns that