contentpresenter

WPF DataGridCell Template with TextBlock - Binding?

余生长醉 提交于 2019-12-05 12:22:08
i replace the ContentPresenter in the DataGridCell 's Template with a TextBlock an now i search for the correct Binding to the content. The normal way is Text="{TemplateBinding Content} for the TextBlock - it doesn't work. Also Text="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Content, Mode=TwoWay}" doesn't work correct. Any other ideas? Suppose you have changed the DataGridCell Template to the following <ControlTemplate TargetType="{x:Type DataGridCell}"> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="

How to bundle View, ViewModel and DataTemplate in a WPF application for easy reuse?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 07:49:27
Situation: I'd like to create a flexible application which is ViewModel driven. The basic flow is like this: Design the main ViewModel Create a UserControl as View and a DataTemplate for the main ViewModel to select this View If there are sub components, the are modelled by sub ViewModels Create a UserControl as View and a DataTemplate for the sub ViewModel to select this View If a sub view model needs to be presented, it is done via a DataTemplate. This approach can also be seen here (option 8). So the main window xaml looks something like this: <Window> <!-- somehow I need to add the mapping

Changing content of Window (WPF)

拥有回忆 提交于 2019-12-03 06:55:34
I've created a simple WPF application which has two Windows. The user fills in some information on the first Window and then clicks Ok which will take them to the second Window. This is working fine but I'm trying to incorporate both Windows into a single Window so just the content changes. I managed to find this Resource management when changing window content which seems like it is what I'm after. However, I've search for ContentPresenter but couldn't find much help for how I need to use it. For example, if I use a ContentPresenter, where do I put the existing XAML elements that are in the

Color Animation ContentPresenter

£可爱£侵袭症+ 提交于 2019-12-02 03:51:01
问题 I can't create an animation, or customize a color in ContentPresenter (NormalTextDay), this error appears in my XAML: 'System.Windows.Media.Animation.ColorAnimation' animation object can not be used to animate property 'Foreground' it is because of incompatible type 'System.Windows.Media.Brush <Style x:Key="CalendarDayButtonStyle" TargetType="{x:Type CalendarDayButton}"> <Setter Property="MinWidth" Value="5"/> <Setter Property="MinHeight" Value="5"/> <Setter Property="FontSize" Value="10"/>

WPF: TextTrimming on a ContentPresenter

落花浮王杯 提交于 2019-11-30 19:02:51
Is there a simple way to just get TextTrimming to work with a ContentPresenter? I have implict styles for TextBlock and AccessText that have TextTrimming set to CharacterEllipsis, but it's not picked up by the ContentPresenter. I can change the ContentPresenter to an AccessText or TextBlock and set it there, but then the template only handles text content. Any suggestions? Thanks! Implicit Styles for elements that derive from UIElement, but not Control, are not applied if the element is defined in a control's Template unless the implict Style is defined in the application Resources. The same

Changing the Foreground colour of a contentpresenter in a listbox

有些话、适合烂在心里 提交于 2019-11-30 11:20:55
I have created the following style for a listbox that will have an image displayed next to some text: <Style x:Key="ImageListBoxStyle" TargetType="{x:Type ListBox}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.CanContentScroll" Value="True"/> <Setter Property="ItemContainerStyle"> <Setter.Value> <!-- Simple ListBoxItem - This is used for each Item in a

WPF: TextTrimming on a ContentPresenter

我与影子孤独终老i 提交于 2019-11-30 03:39:50
问题 Is there a simple way to just get TextTrimming to work with a ContentPresenter? I have implict styles for TextBlock and AccessText that have TextTrimming set to CharacterEllipsis, but it's not picked up by the ContentPresenter. I can change the ContentPresenter to an AccessText or TextBlock and set it there, but then the template only handles text content. Any suggestions? Thanks! 回答1: Implicit Styles for elements that derive from UIElement, but not Control, are not applied if the element is

How do I Change the FontFamily on a ContentPresenter?

a 夏天 提交于 2019-11-29 22:52:12
I have a custom template for an expander that is close to the code below. I had to change some of the code to take out custom classes, brushes, etc.. <Style TargetType="{x:Type Expander}"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="VerticalContentAlignment" Value="Top" /> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="FontFamily" Value="Tahoma" /> <Setter Property="FontSize" Value="12" /> <Setter Property="Foreground" Value="Black" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="Margin" Value="2,0,0,0" />

Changing the Foreground colour of a contentpresenter in a listbox

两盒软妹~` 提交于 2019-11-29 16:38:21
问题 I have created the following style for a listbox that will have an image displayed next to some text: <Style x:Key="ImageListBoxStyle" TargetType="{x:Type ListBox}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/> <Setter Property="ScrollViewer.CanContentScroll" Value="True"/> <Setter

WPF 4 ContentPresenter TextWrapping style is not applied to implicitedly generated TextBlock

依然范特西╮ 提交于 2019-11-29 06:24:10
If I assign a piece of text to the Content property of a ContentPresenter , a TextBlock control is generated by the ContentPresenter at render time to contain that text. If I create a style that applies to TextBlock properties and assign it to that ContentPresenter , the does not appear to apply to the implicitly generated TextBlock s. <Style x:Key="SampleStyle"> <Setter Property="TextBlock.TextWrapping" Value="Wrap"/> </Style> <ContentPresenter Content="This is a Test piece of text." Style="{StaticResource SampleStyle}"/> Is there a way to apply this style successfully to the autogenerated