datatemplate

Change ListBoxItem Background Color when mouse is over on the listBoxItem

前提是你 提交于 2019-12-02 02:54:57
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="LeftToRight" Orientation="Horizontal" > <TextBlock Width="150" Height="{TemplateBinding Button.Height}" x:Name=

Get the controls inside DataTemplate control

北战南征 提交于 2019-12-02 02:49:42
问题 I have the following XAML code that used on hub application for windows 8.1: <HubSection Width="780" Margin="0,0,80,0"> <HubSection.Background> <ImageBrush ImageSource="Assets/MediumGray.png" Stretch="UniformToFill" /> </HubSection.Background> <DataTemplate> <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <m:Map Credentials="YOUR_BING_MAPS_KEY"> <m:Map.Children> <!-- Data Layer--> <m:MapLayer Name="DataLayer"/> <!--Common Infobox--> <m:MapLayer> <Grid x:Name="Infobox"

WPF DataTemplate Tutorials

喜欢而已 提交于 2019-12-02 02:29:13
问题 I am stuck in how to use DataTamplete in WPF, someone knows some tutorial or has a colection of turorials that teach how to use it?? I'm using MVVM Pattern, so if you know a tutorial in mvvm examples it will be better. ;) Tks! 回答1: Googling "wpf datatempalte tutorial" give following links. i would recommend #2 Data Templating Overview - MSDN - Microsoft WPF Tutorial | Data Templates A Guided Tour of WPF – Part 4 (Data templates and triggers... 回答2: MSDN explains it well MSDN Data Templating

WPF - using CroppedBitmap in DataTemplate

二次信任 提交于 2019-12-02 01:40:22
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.Windows.Media.Imaging.CroppedBitmap' in markup file. Inner Exception: {"'Source' property is not set."} The

DataTemplates and generic types

我与影子孤独终老i 提交于 2019-12-02 01:33:22
I have a generic class public abstract class BaseViewModel<T> Since I am trying to create a DataTemplate that will be applied to all classes that derive from BaseViewModel, I set the type to BaseViewModel: <DataTemplate DataType="{x:Type vm:BaseViewModel}"> However, this does not work since it looks like xaml does not support generic data types. Are there any work arounds to this? I would create a non-generic version of BaseViewModel and let the generic one inherit from it: public abstract class BaseViewModel { // members that are not T-specific, if any // (not required, but could prove useful

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

*爱你&永不变心* 提交于 2019-12-02 00:42: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 allows me to specify a different binding path for each one. I tried something like this (among other

WPF DataTemplate Tutorials

我的未来我决定 提交于 2019-12-02 00:25:48
I am stuck in how to use DataTamplete in WPF, someone knows some tutorial or has a colection of turorials that teach how to use it?? I'm using MVVM Pattern, so if you know a tutorial in mvvm examples it will be better. ;) Tks! Googling "wpf datatempalte tutorial" give following links. i would recommend #2 Data Templating Overview - MSDN - Microsoft WPF Tutorial | Data Templates A Guided Tour of WPF – Part 4 (Data templates and triggers... MSDN explains it well MSDN Data Templating Overview Things to watch out for are that your itemsource is set correctly and that the properties you are binding

WPF TwoWay Binding of ListBox using DataTemplate [duplicate]

南笙酒味 提交于 2019-12-01 22:41:12
Possible Duplicate: How to make ListBox editable when bound to a List<string>? I'm trying to set a two-binding between a List named "ListStr" object and a ListBox WPF control. Besides I want the items to be editable, so I added a DataTemplate with TextBoxes expecting that it would modify the ListStr items straight away via TextBoxes. But when I'm attempting to edit one of them, it doesn't work... Any Idea ? PS: I've tried to add the Mode=TwoWay parameter, but it's still not working Here is the XAML : <ListBox ItemsSource="{Binding Path=ListStr}" Style="{DynamicResource ResourceKey

Cant get a control from a TabControl DataTemplate

五迷三道 提交于 2019-12-01 19:19:25
I've been googling this for the last 2 days and cant get anywhere, I just cant do anything to any control in a datatemplate of a tabcontrol. First off, the code: private void Window_Loaded(object sender, RoutedEventArgs e) { tabControl1.ItemsSource = new string[] { "TabA", "TabB", "TabC" }; } private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e) { ContentPresenter cp = tabControl1.Template.FindName("PART_SelectedContentHost", tabControl1) as ContentPresenter; DataTemplate dt = tabControl1.ContentTemplate; Grid g = tabControl1.ContentTemplate.FindName("myGrid",

Why DataBinding is not propagating to UserControl

回眸只為那壹抹淺笑 提交于 2019-12-01 15:02:35
This morning I asked a question here and doing a simple working sample gave me a different behavior than expected. Full working sample at GitHub . Main partial code below. In this present case, the command is never propagated to any UserControl, either if the UserControl is use directly as a child of the Window. It also not work if the UserControl is used as a DataTemplate for a ListBox ItemTemplate. I also include a hack button to fix the problem where the Command reach the UserControls. The hack come from StackOverflow . But using the hack does not explain why UserControl does not receive