contentcontrol

Load a Page into a ContentControl

风流意气都作罢 提交于 2019-12-19 11:38:30
问题 I have a ContentControl where I want to load the page myPage2 . My XAML Codefrom this page looks like this: <Page x:Class="ExampleApp.myPage2"> <Grid x:Name="Content" Height="651" Width="941" Background="White"> ... ... </Grid> </Page> I know that I can load a resource from a page with this Code: protected override DataTemplate SelectTemplateCore(object item, DependencyObject container) { var contentControl = (ContentControl)container; return (DataTemplate) contentControl.Resources

Binding a ContentControl to UserControl, and reuse same instance

半世苍凉 提交于 2019-12-18 07:14:29
问题 I'm trying to bind a ContentControl's Content to a UserControl I have instantiated in my ViewModel. I cannot use the method with binding to a ViewModel and then have the UserControl be the DataTemplate of the ViewModel, as I need the Content of the ContentControl to be able to change frequently, using the same instance of the UserControls/Views, and not instantiate the views each time i re-bind. However, when setting the UserControl-property to a UserControl-instance, and then when the view

Binding ContentControl Content for dynamic content

我与影子孤独终老i 提交于 2019-12-17 15:22:40
问题 I'm currently trying to achieve the functionality of a tabcontrol with hidden tabs by using a ListView (as tabs) and a ContentControl with Binding the Content Property. I read a bit on that topic and if I got it right, it should work this way: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="20.0*"/> <ColumnDefinition Width="80.0*"/> </Grid.ColumnDefinitions> <ListBox Grid.Column="0"> <ListBoxItem Content="Appearance"/> </ListBox> <ContentControl Content="{Binding SettingsPage}" Grid

How to set Control Template in code?

旧时模样 提交于 2019-12-17 09:38:03
问题 I have this in XAML <ControlTemplate TargetType="{x:Type Button}"> <Image ...> </ControlTemplate> I want to achieve same in C# code. How can I achieve this? ControlTemplate ct = new ControlTemplate();.. Image img = new Image();.. Now how to assign this Image to Control template? Can we do this or Am I missing any concept here? 回答1: Creating template in codebehind is not a good idea, in theory one would do this by defining the ControlTemplate.VisualTree which is a FrameworkElementFactory.

WPF - Border template with content

こ雲淡風輕ζ 提交于 2019-12-12 09:48:31
问题 Let's assume I have the following control template: <ControlTemplate x:Key="Test"> <Grid> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Width="33" Height="33" CornerRadius="3"/> <ContentControl Content="{TemplateBinding Property=ContentControl.Content}" VerticalAlignment="Center" HorizontalAlignment="Center"/> </Grid> </ControlTemplate> How can I change content of the control in wpf? I've tried something like <Control Template="{StaticResource Test}" BorderBrush=

WPF: Store XAML in Property and Display in ContentControl

浪尽此生 提交于 2019-12-12 04:54:16
问题 I am deserializing a XML file into a class and then trying to display some XAML (stored in a property in the class) in a ContentControl. Here is my XML: <CallSteps> <CallStep> <StepID>20</StepID> <StepName>Intro</StepName> <StepXaml> <![CDATA[<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:uc="clr-namespace:CallTracker.Library.UserControls.BaseUserControls;assembly=CallTracker.Library"> <uc:LabelValueControl Label="TestLabel" Value="356733" /> </StackPanel>

How to conditionally insert a Checkbox in a list item of a customized ListView when using class inheritance?

回眸只為那壹抹淺笑 提交于 2019-12-12 04:24:45
问题 I try to make a customized ListView which fills each list item with some stuff and an initial Checkbox if the concrete inheriting class wishes so. Currently no Checkbox is displayed so I guess my code of the ContentControl stuff is somehow erroneous. <UserControl x:Class="local:MyListView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="some/path/here"> <ListView> <ListView.View> <GridView> <GridViewColumn>

How to change the data template in itemscontrol based on index?

我的未来我决定 提交于 2019-12-11 16:57:31
问题 I am trying to create a dynamic UI for polynomial function. Since I do not know the order beforehand, I want to create it dynamically. I am setting my coefficient list as a items source of items control and planned to change data template based on the index. The template should work like this if (index > 1) { (coefficient text box) + *x ^ (index) + //Polynomial2 } else if (index == 1) { (coefficient text box) + *x + //Polynomial 1 } else if (index == 0) { (coefficient text box) //Polynomial }

WPF: Can not find the Trigger target 'cc'. The target must appear before any Setters, Triggers

元气小坏坏 提交于 2019-12-11 06:37:30
问题 what is wrong about the following code? I get this error during compilation: The property 'TargetName' does not represent a valid target for the 'Setter' because an element named 'cc' was not found. Make sure that the target is declared before any Setters, Triggers or Conditions that use it. How do I have to refactor my code so I can compile it without error? I just want to switch a datatemplate with DataTrigger bound to a value in my PersonViewModel! <ContentControl x:Name="cc" Grid.Column=

WPF in a usercontrol set a controltemplate's content to the value of a dependencyproperty

微笑、不失礼 提交于 2019-12-11 05:08:50
问题 I am pretty new to WPF, (using it for 3 weeks now), so I might be missing something stupid or not understanding what I am doing! I am trying to create a modal type popup window that would cover either the whole application or current control it is in. I want this control to be semi transparent so the user can still see the content behind but not be able to use it. They will then be able to complete what ever is in the modal window before continuing. I do not want to have to repeat code in