Click here to Skip to main content
15,885,757 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
Mycroft Holmes14-Jun-16 14:44
professionalMycroft Holmes14-Jun-16 14:44 
GeneralRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
Kevin Marois14-Jun-16 15:15
professionalKevin Marois14-Jun-16 15:15 
GeneralRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
Mycroft Holmes14-Jun-16 16:27
professionalMycroft Holmes14-Jun-16 16:27 
AnswerRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
U. G. Leander16-Jun-16 1:34
professionalU. G. Leander16-Jun-16 1:34 
QuestionHow to Change WPF Textbox SpellCheck Language to UK English Pin
Dave M121:-)4-Jun-16 22:33
Dave M121:-)4-Jun-16 22:33 
AnswerRe: How to Change WPF Textbox SpellCheck Language to UK English Pin
Gerry Schmitz5-Jun-16 6:56
mveGerry Schmitz5-Jun-16 6:56 
GeneralRe: How to Change WPF Textbox SpellCheck Language to UK English Pin
Dave M121:-)6-Jun-16 0:06
Dave M121:-)6-Jun-16 0:06 
QuestionResources not showing up in WPF control put in Winform Pin
pgmr_648044-Jun-16 5:36
pgmr_648044-Jun-16 5:36 
I am trying to put a WPF Control in a winform for a project at work. I have done before for small controls and it worked well. I even put the DiagramDesignerPart1 in a winform as a practice run and did ok but some of the resources were missing and I did not notice or did not think it was a big deal.

Now I am trying to put the DiagramDesignerPart4 in a winform panel and the resources are missing at runtime.

The control shows all the resources at design time but when I run they are missing.

Also if I set the project to startup project that window runs fine and the resources all show up.

I have searched and searched for the answer and have not been able to get anything to work for me.

I did the following

1) I added the project to my project
2) Created a WPF Control and called it DiagramEditor and copied the xaml code into that to change it from a application to a control
3) I created a themes/generic.xaml file to put the info that was in app.xaml there

First I had a problem with the program crashing runtime using the static resources and the error was that it could not find the resources.

Then I changed to DynamicResources and it runs but none of the resources are showing up.


Generic.xaml

XML
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DiagramDesigner">


    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/Shared.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/ToolBar.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/GroupBox.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/Expander.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Styles/ScrollBar.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/ApplicationToolbar.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/DesignerItem.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/ToolboxItem.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Toolbox.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Connection.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Stencils/FlowChartStencils.xaml"/>
        <ResourceDictionary Source="/DiagramDesigner;component/Resources/Stencils/ShapeStencils.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type local:DiagramEditor}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:DiagramEditor}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>



DiagramEditor.xaml
XML
<UserControl x:Class="DiagramDesigner.DiagramEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:s="clr-namespace:DiagramDesigner"
             xmlns:c="clr-namespace:DiagramDesigner.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="850" d:DesignWidth="1000">

    <UserControl.Resources>
        <ContextMenu x:Key="DesignerCanvasContextMenu">
            <MenuItem Header="Paste" Command="{x:Static ApplicationCommands.Paste}">
                <MenuItem.Icon>
                    <Image Source="/Resources/Images/Paste.png" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="Select All" Command="{x:Static s:DesignerCanvas.SelectAll}"/>
        </ContextMenu>
        
    </UserControl.Resources>
  
    <Grid>

        <Grid Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <ContentControl Content="{DynamicResource  MyToolbar}"/>
       
            <Grid Grid.Row="1" Margin="0,10,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="265"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <!-- Toolbox -->
                <StackPanel Grid.Column="0" Margin="0,0,5,0">
                    <Expander Header="Flow Chart" Content="{DynamicResource FlowChartStencils}" IsExpanded="True"/>
                    <Expander Header="Shapes" Content="{DynamicResource ShapeStencils}" IsExpanded="True"/>
                </StackPanel>
                <!-- GridSplitter -->
                <GridSplitter Focusable="False" Width="2" Background="LightGray"
                    VerticalAlignment="Stretch" HorizontalAlignment="Right"/>
                <!-- Designer -->
                <GroupBox Header="Diagram" Grid.Column="1" Margin="3,0,0,0">
                    <ScrollViewer HorizontalScrollBarVisibility="Auto"
                      VerticalScrollBarVisibility="Auto">
                        <s:DesignerCanvas Focusable="true" x:Name="MyDesigner"
                            Background="{DynamicResource WindowBackgroundBrush}"
                            Margin="10" FocusVisualStyle="{x:Null}"
                            ContextMenu="{DynamicResource DesignerCanvasContextMenu}"/>
                    </ScrollViewer>
                </GroupBox>
            </Grid>
        </Grid>

    </Grid>
</UserControl>


code to put on winform

C#
System.Windows.Forms.Integration.ElementHost elementHost1 = new System.Windows.Forms.Integration.ElementHost();
      DiagramEditor diagramEditor = new DiagramEditor();

  private void LoadControls()
      {
          elementHost1.Dock = DockStyle.Fill;
          //elementHost1.Height = 850;
          //elementHost1.Width = 1000;
          elementHost1.BackColorTransparent = true;
          elementHost1.Child = diagramEditor;

          panel1.Controls.Add(elementHost1);
      }

AnswerRe: Resources not showing up in WPF control put in Winform Pin
Gerry Schmitz5-Jun-16 8:09
mveGerry Schmitz5-Jun-16 8:09 
GeneralRe: Resources not showing up in WPF control put in Winform Pin
pgmr_648045-Jun-16 9:15
pgmr_648045-Jun-16 9:15 
QuestionTwo-Dimensional Datagrid Help Pin
madusanka8931-May-16 3:13
madusanka8931-May-16 3:13 
AnswerRe: Two-Dimensional Datagrid Help Pin
CHill6031-May-16 5:11
mveCHill6031-May-16 5:11 
GeneralRe: Two-Dimensional Datagrid Help Pin
Gerry Schmitz31-May-16 5:37
mveGerry Schmitz31-May-16 5:37 
GeneralRe: Two-Dimensional Datagrid Help Pin
CHill6031-May-16 5:42
mveCHill6031-May-16 5:42 
QuestionThe name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". Pin
indian14326-May-16 10:24
indian14326-May-16 10:24 
AnswerRe: The name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". C:\users\abdul.aleem\desktop\testwpfapplication\testwpfvbapplication\view\mainwindow.xaml Pin
Richard Deeming26-May-16 10:55
mveRichard Deeming26-May-16 10:55 
GeneralRe: The name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". Pin
indian14326-May-16 12:17
indian14326-May-16 12:17 
QuestionRequest Entity Too Large Pin
Mycroft Holmes25-May-16 21:57
professionalMycroft Holmes25-May-16 21:57 
AnswerRe: Request Entity Too Large Pin
Gerry Schmitz26-May-16 7:45
mveGerry Schmitz26-May-16 7:45 
GeneralRe: Request Entity Too Large Pin
Mycroft Holmes26-May-16 14:28
professionalMycroft Holmes26-May-16 14:28 
GeneralRe: Request Entity Too Large Pin
Mycroft Holmes26-May-16 17:58
professionalMycroft Holmes26-May-16 17:58 
QuestionHow to bind a nested Property of an attached Property Pin
Member 808505724-May-16 4:47
Member 808505724-May-16 4:47 
QuestionWPF Binding Question Pin
#realJSOP24-May-16 4:12
mve#realJSOP24-May-16 4:12 
AnswerRe: WPF Binding Question Pin
#realJSOP24-May-16 5:02
mve#realJSOP24-May-16 5:02 
QuestionBinding the x,y location on a Canvas with a ItemsControl Pin
Kenneth Haugland19-May-16 17:38
mvaKenneth Haugland19-May-16 17:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.