datatemplate

Applying transforms from DataTemplates in WPF

泄露秘密 提交于 2019-12-25 14:12:49
问题 I've created a DataTemplate for my objects in a ResourceDictionary file. The template is basically an image that is loaded from the disk. Now, what happens is that I want to align the image to a specific point on my Canvas but not by its upper left point but its center point, that's why I want to apply a translate transform for X = -Width / 2 and Y = -Height / 2 but I don't know how to apply them via the DataTemplate. Any help will be appreciated, thanks! 回答1: Try using databinding on Canvas'

Accessing DataTemplate from ResourceDictionary in code behind

[亡魂溺海] 提交于 2019-12-25 09:00:45
问题 I am trying to convert a vendor provided VB solution to C# . I need to load a DataTemplate from a custom ResourceDictionary XAML into a c# class. I cannot determine how to get the DataTemplate. I am able to create a ResourceDictionary and load the XAML but am stumped from there. Here is my XAML [EditorResources]. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:PropertyEditing="clr-namespace

Command binding is not propagating for control into a DataTemplate of ItemTemplate

我与影子孤独终老i 提交于 2019-12-25 07:59:57
问题 For Command "CommandZoomIn", CanExecute and Execute do not occurs for controls defined into the ListBox ItemTemplate. GraphLcView method "CanExecute" and "Execute" are both called when GraphLcView UserControl is defined directly as child of AnalysisView, but both methods are never called when they are added as Item DataTemplate of a ListBox ItemTemplate. The button with the command is defined in my top level window into a Ribbon. Simplified hierarchy: (Working) Top Level window ->

WPF Textbox TwoWay binding in datatemplate not updating the source even on LostFocus

旧街凉风 提交于 2019-12-25 03:32:30
问题 I have an ObservableCollection<string> Tags as part of a custom object. I bind it to a DataTemplate in order to show all tags to the user with the following code: <StackPanel DockPanel.Dock="Top" Margin="15,0,15,0" Orientation="Horizontal"> <Label Content="Tags:" FontSize="14" Foreground="{StaticResource HM2LightTextBrush}"/> <Grid> <ItemsControl Name="PanelPreviewNoteTags" ItemsSource="{Binding ElementName=lbNotesQuickView, Path=SelectedItem.Tags}" Margin="3,0" Visibility="Collapsed">

Set MaxHeight of textblock embedded within data template of ListBox

孤街浪徒 提交于 2019-12-25 01:59:37
问题 how do i access a textblock inside a data template, within a ListBox & set the textblock's 'MaxHeight'? Code-behind as well? I have @ Page.xaml: <ListBox ItemsSource="{Binding}" DataContext="" x:Name="NewsList" SelectionChanged="NewsList_SelectionChanged" SelectionMode="Single" Width="580" Height="360" VerticalAlignment="Top" HorizontalAlignment="Center" > <ListBox.ItemTemplate> <DataTemplate> <!-- table within each ListBox item--> <!-- control horizontal scrollbar w width @ following line-->

DataTemplate on DataGridColumnHeader WPF C#

谁说胖子不能爱 提交于 2019-12-24 23:05:08
问题 I am having trouble getting a DataTemplate to apply to all columns in a datagrid with dynamically generated columns. The ItemsSource is bound to a DataTable property in the VM. Everything other than the template is working just fine. This is all just initial proof of concept right now, so data is garbage, but need help with the proof of concept. Code as follows: View: <DataGrid AutGenerateColumns="true" ItemsSource={Binding xxx} etc...> <DataGrid.Columns> <DataGridTemplateColumn>

Get the UI object from a data object

你说的曾经没有我的故事 提交于 2019-12-24 16:19:05
问题 I have a class (MockWI) that I have defined the following DataTemplate in app.xml <DataTemplate DataType="{x:Type local:MockWI}"> <Button Content="{Binding Name}"/> </DataTemplate> In my code I need to find the UI object that an instance of MockWI has. Right now I do this: Button elt = new Button { Content = myMockWI}; But that gives me a button in a button. I want to just get the button that is the MockWI called myMockWI. Something like this: Button elt = GetUIControlFromVar(myMockWI); Is

DependencyProperty's value is null when method in attached property's class is called

自闭症网瘾萝莉.ら 提交于 2019-12-24 14:22:29
问题 we have been working a complete day on this problem and have it all summed up to a small example. We are currently converting a project from Silverlight to WPF, in Silverlight both versions work, in WPF only one does. We have a simple control with a string-type dependencyproperty like this: public class MyControl : Control { public String Text { get { return (String)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } public static readonly DependencyProperty TextProperty =

Silverlight, DataTemplate, Binding to click event

可紊 提交于 2019-12-24 14:07:15
问题 Good day, I'm getting desperate here. Consider the following use case. I have a listbox which item's are custom templated control. It has several buttons for which this custom control has event handlers in code behind. Whenever button is clicked I call a method of the object my custom control is bound to through the DataContext. So, when user clicks stop, I call _context.stopDownload() and object does the rest. But, I have one button which should start the playback of the content. I am trying

Datatemplates while using theme does not work - WPF

旧街凉风 提交于 2019-12-24 12:27:57
问题 I am using the theme DarkExpression from WPF Futures. It does not seem to work well with datatemplates. Scenario 1: Here is how it looks like without datatemplates: Code: <ListView Name="playlistListView" ItemsSource="{Binding PlaylistList}" Margin="0" SelectionChanged="DatabindedPlaylistListView_SelectionChanged" Background="{x:Null}" Opacity="0.98"> <ListView.View> <GridView> <GridViewColumn Width="Auto" DisplayMemberBinding="{Binding Name}"> <GridViewColumnHeader HorizontalContentAlignment