Click here to Skip to main content
15,171,873 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
Mycroft Holmes14-Jun-16 15:44
professionalMycroft Holmes14-Jun-16 15:44 
GeneralRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
Kevin Marois14-Jun-16 16:15
professionalKevin Marois14-Jun-16 16:15 
GeneralRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
Mycroft Holmes14-Jun-16 17:27
professionalMycroft Holmes14-Jun-16 17:27 
AnswerRe: WPF/MVVM Tabbed UI - Handle Menu Commands Pin
U. G. Leander16-Jun-16 2:34
professionalU. G. Leander16-Jun-16 2:34 
QuestionHow to Change WPF Textbox SpellCheck Language to UK English Pin
Dave M121:-)4-Jun-16 23:33
MemberDave M121:-)4-Jun-16 23:33 
AnswerRe: How to Change WPF Textbox SpellCheck Language to UK English Pin
Gerry Schmitz5-Jun-16 7:56
mveGerry Schmitz5-Jun-16 7:56 
GeneralRe: How to Change WPF Textbox SpellCheck Language to UK English Pin
Dave M121:-)6-Jun-16 1:06
MemberDave M121:-)6-Jun-16 1:06 
QuestionResources not showing up in WPF control put in Winform Pin
pgmr_648044-Jun-16 6:36
Memberpgmr_648044-Jun-16 6: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 9:09
mveGerry Schmitz5-Jun-16 9:09 
GeneralRe: Resources not showing up in WPF control put in Winform Pin
pgmr_648045-Jun-16 10:15
Memberpgmr_648045-Jun-16 10:15 
QuestionTwo-Dimensional Datagrid Help Pin
madusanka8931-May-16 4:13
Membermadusanka8931-May-16 4:13 
AnswerRe: Two-Dimensional Datagrid Help Pin
CHill6031-May-16 6:11
mveCHill6031-May-16 6:11 
GeneralRe: Two-Dimensional Datagrid Help Pin
Gerry Schmitz31-May-16 6:37
mveGerry Schmitz31-May-16 6:37 
GeneralRe: Two-Dimensional Datagrid Help Pin
CHill6031-May-16 6:42
mveCHill6031-May-16 6:42 
QuestionThe name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". Pin
indian14326-May-16 11:24
Memberindian14326-May-16 11: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 11:55
mveRichard Deeming26-May-16 11:55 
GeneralRe: The name "employeeviewmodel" does not exist in the namespace "clr-namespace:testwpfvbapplication.viewmodel". Pin
indian14326-May-16 13:17
Memberindian14326-May-16 13:17 
QuestionRequest Entity Too Large Pin
Mycroft Holmes25-May-16 22:57
professionalMycroft Holmes25-May-16 22:57 
AnswerRe: Request Entity Too Large Pin
Gerry Schmitz26-May-16 8:45
mveGerry Schmitz26-May-16 8:45 
GeneralRe: Request Entity Too Large Pin
Mycroft Holmes26-May-16 15:28
professionalMycroft Holmes26-May-16 15:28 
GeneralRe: Request Entity Too Large Pin
Mycroft Holmes26-May-16 18:58
professionalMycroft Holmes26-May-16 18:58 
QuestionHow to bind a nested Property of an attached Property Pin
Member 808505724-May-16 5:47
MemberMember 808505724-May-16 5:47 
QuestionWPF Binding Question Pin
#realJSOP24-May-16 5:12
mva#realJSOP24-May-16 5:12 
AnswerRe: WPF Binding Question Pin
#realJSOP24-May-16 6:02
mva#realJSOP24-May-16 6:02 
QuestionBinding the x,y location on a Canvas with a ItemsControl Pin
Kenneth Haugland19-May-16 18:38
mvaKenneth Haugland19-May-16 18: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.