I have problem. In this link:
http://msdn.microsoft.com/en-us/data/gg638943[^]
we can see that code is automatically generated. But when I drag and drop some entity in the same way, visual studio generate only this:
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Testowy
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
System.Windows.Data.CollectionViewSource taktTimerEntitiesViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("taktTimerEntitiesViewSource")));
// Load data by setting the CollectionViewSource.Source property:
// taktTimerEntitiesViewSource.Source = [generic data source]
}
}
}
I have visual studio 2012. I tried the same in Visual Studio 2010 Express but situation was the same. Can somebody help?
Related
hey there I've just now started making a engine with tutorials while I was doing so I stumbled upon a error.
Here Is What the Error Told:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'ProjectBrowserDialg' could not be found (are you missing a using directive or an assembly reference?) Editor C:\Users\abrus\OneDrive\Documents\cpp_files_me\MehroofEngine\src\MehroofEngine For C++\Editor\MainWindow.xaml.cs 37 Active
this is the code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Editor
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Loaded += OnMainWindowLoaded;
}
private void OnMainWindowLoaded(object sender, RoutedEventArgs e)
{
Loaded -= OnMainWindowLoaded;
OpenProjectBrowserDialog();
}
private void OpenProjectBrowserDialog()
{
var projectBrowser = new ProjectBrowserDialg();
}
}
}
if I forgot something in the code please reply
if not enough information please reply it helps me make better posts.
I have a WPF window with a combo box. The contents of the combo box should be populated from a column in a SQL table. I created a LINQ To SQL Data Context Class in a models folder and set the ItemsSource of the ComboBox to the class (Customers) generated by the data context.. But when I run the program, the contents of the combobox are the types of the items it pulled..
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using eTouchLV.GatekeeperUI.Models;
namespace eTouchLV.GatekeeperUI
{
public partial class MainWindow : Window
{
SQLDataClassDataContext dc = new SQLDataClassDataContext(Properties.Settings.Default.GatekeeperDBConnectionString);
public MainWindow()
{
InitializeComponent();
AssignDataToComponents();
}
private void AssignDataToComponents()
{
this.CheckDBIsValid();
comboCustomers.ItemsSource = dc.Customers;
}
private void CheckDBIsValid()
{
if (!dc.DatabaseExists())
{
MessageBox.Show("Program started on the machine but can't seem to find the database...", "Error connecting to DB on SQL server.");
}
}
}
}
Program:
I just started with C# at work and I did read like a lot of the questions that are about my error here at StackOverflow. Unfortunately I still don't get what I'm doing wrong.
So, I followed this (http://qafriend.com/c-ui-automation-tutorial/automate-using-c-tutorial-guide-part-5) tutorial that is about C# and UI Automation. Everything went fine until I had to write actual code. So my code is this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Automation;
using Automation = System.Windows.Automation;
namespace AutomateCSharp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
static AutomationElement desktopObject = AutomationElement.RootElement;
static Automation.Condition testWindowNameCondition = new PropertyCondition(AutomationElement.NameProperty, "Demo Window For Csharp Automation");
static Automation.Condition textConditionOne = new PropertyCondition(AutomationElement.AutomationIdProperty, "InputOne");
static Automation.Condition textConditionTwo = new PropertyCondition(AutomationElement.AutomationIdProperty, "InputTwo");
static Automation.Condition textConditionTotal = new PropertyCondition(AutomationElement.AutomationIdProperty, "Total");
static AutomationElement testWindow = desktopObject.FindFirst(TreeScope.Children, testWindowNameCondition);
static AutomationElement textOne = testWindow.FindFirst(TreeScope.Descendants, textConditionOne);
static ValuePattern valuetextOne = textOne.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
valuetextOne.SetValue("4");
}
}
And I get the Error: The name 'valuetextOne' does not exist in the current context.
Could someone please tell me what I'm wrong about? Thanks a lot in advance :)
This problem has to do with the fact that functions can't be called inside class bodies directly. Only fields, properties and methods can be written there. What you need to do, is wrap it inside another function, like so:
public partial class MainWindow : Window
{
// Stuff
public void SetValue() => valuetextOne.SetValue("4");
}
And then you call it as:
public void Foo()
{
MainWindow window = Bar();
window.SetValue();
}
I go into more detail here about this.
Whenever I put a breakpoint in the WPF App.XAML.cs file, the breakpoints are not hitting. As if the file is not executed at all. So weird.... There is no the usual 'yellow breakpoint' indicating the breakpoint is not hit. It just runs the program as if the file is not being executed at all
Anybody know why?
here's my App.Xaml.cs code
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Abt.Controls.SciChart;
using Abt.Controls.SciChart.Model.DataSeries;
using Abt.Controls.SciChart.Utility;
using Abt.Controls.SciChart.Visuals;
using Abt.Controls.SciChart.Visuals.Axes;
using Abt.Controls.SciChart.Visuals.Annotations;
using Abt.Controls.SciChart.Visuals.RenderableSeries;
using Abt.Controls.SciChart.ChartModifiers;
using Abt.Controls.SciChart.Numerics.CoordinateCalculators;
namespace Hub
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
CUtilities.WCFCalls = new List<string>();
}
}
}
here's my app.g.cs file
#pragma checksum "..\..\App.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "788CF6544127ABDC6D6160DE3D084FC8"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace Client {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
#line 4 "..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
System.Uri resourceLocater = new System.Uri("/Client;component/app.xaml", System.UriKind.Relative);
#line 1 "..\..\App.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
Client.App app = new Client.App();
app.InitializeComponent();
app.Run();
}
}
}
I seem to remember this happening with older versions of Visual Studio, it's like it would take a second or two for the debugger to hook in to the process or something. I found I could force it manually with Debugger.Break(); In any case try manually deleting the bin/obj folders and doing a rebuild, sometimes it's also the result of the incremental compilation getting itself confused.
I wrote a user control in XAML and after it gets compiled into C# the resulting C# has this line:
using Microsoft.Windows.Themes;
Which throws an error now:
The type or namespace name 'Themes' does not exist in the namespace
'Microsoft.Windows' (are you missing an assembly reference?)
I figured since I can't affect the output of compiled C# (there's nothing to remove from XAML), I would just add that as Reference.
However, the Add Reference dialog does not contain Microsoft.Windows.Themes. Is this not part of .NET?
Here's an example XAML user control that causes this problem:
<UserControl x:Class="GG.UserControls.MainMenu"
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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<StackPanel>
<Menu VerticalAlignment="Top" Background="{x:Null}">
... // Just static menu items.
</Menu>
</StackPanel>
</UserControl>
And C# code behind it:
using System;
using System.Windows.Controls;
namespace GG.UserControls
{
/// <summary>
/// Interaction logic for MainMenu.xaml
/// </summary>
public partial class MainMenu : UserControl
{
public MainMenu()
{
InitializeComponent();
}
}
}
Here's an example of compiled C#:
#pragma checksum "..\..\..\..\UserControls\MainMenu.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "5A85C5B16565514165AD23641F944BC6"
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.17020
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using GG;
using GG.UserControls;
using Microsoft.Windows.Shell;
using Microsoft.Windows.Themes; // <---- WTF?
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
namespace GG.UserControls {
/// <summary>
/// ChangesetHistory
/// </summary>
public partial class MainMenu : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/GG;component/usercontrols/mainmenu.xaml", System.UriKind.Relative);
#line 1 "..\..\..\..\UserControls\MainMenu.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
this._contentLoaded = true;
}
}
}
Microsoft.Windows.Themes is found in the theme-specific PresentationFramework assemblies. You'll want to add a reference to one of the following depending on which one is referenced in your XAML:
PresentationFramework.Aero.dll
PresentationFramework.AeroLite.dll
PresentationFramework.Classic.dll
PresentationFramework.Luna.dll
PresentationFramework.Royale.dll