Laden...

Forenbeiträge von Syl3x Ingesamt 25 Beiträge

23.05.2014 - 17:26 Uhr

Hallo Th69,

danke für die vielen Informationen!!!

den Code der DLL habe ich leider nicht. Habe nur die dll, lib und header datei bekommen.

was genau in der dll steht kann ich nicht sagen. Darum kann ich da auch nicht einfach DatenTypen ändern.

Die dll dient für den zugriff auf die IO eines bestimmten Mainboard. Auf dem System muss ein Windows embedded laufen.. ( 7 oder 8 )Leider hab ich das noch nicht vorbereitet um zu testen, da ich die letzten 2 Tage damit verbracht habe irgendwie auf die Methoden zu zugreifen.

Ich werde mich auf jeden Fall nochmal melden wie und obs geklappt hat.

BESTEN DANK!!!! 👍 👍 👍

23.05.2014 - 15:48 Uhr

Cool Danke Th69 👍

Wie hast du den PInvoke Assistenten denn dazu überreden können die dll anzunehmen?

Die Methode kann ich nun aufrufen!

nun habe ich aber den Nächsten Fehler...

Fehlermeldung:
Es wurde versucht, im geschützten Speicher zu lesen oder zu schreiben. Dies ist häufig ein Hinweis darauf, dass anderer Speicher beschädigt ist.

das kann aber auch daran liegen das dass Programm nicht in der richtigen Umgebung läuft.

Die Umgebung muss ich noch vorbereiten bevor ich testen kann...

sobald ich das gemacht habe melde ich mich Obs geklappt hat oder nicht!

Viele Dank euch!!!! 👍 👍 👍

23.05.2014 - 14:41 Uhr

Das das Grundlagen sind kann gut sein! leider habe ich das bisher aber nicht gebraucht und ich bin auch noch kein ganzes Jahr als AE tätig. X(
So kann ich mich wie die Meissten nur Schritt für Schritt durch die Fehler arbeiten...

Ich habe schond die Typendefinition in Klassen angelegt...
Beim Compilieren meckert er auch schon nicht mehr.

das sieht so aus.

[StructLayout(LayoutKind.Sequential)]
    public class PtOakSensor
    {

        System.Char[]		DevicePath;

		System.UInt16		VID;
		System.UInt16		PID;
		System.UInt16	    REV;
		System.Char[]		SN;
		System.Byte[]	    RFU; 
		System.Char[]		DeviceName;
		System.Char[]		UserDeviceName;
		System.Char[]		UserDeviceName_NV;
		System.UInt16	    NumChannels;
		tChannel[]	        Channel;
    }
    [StructLayout(LayoutKind.Sequential)]
    public class tChannel
    {
        bool		        IsSigned;
		System.Byte		    BitSize;
	    System.Char         UnitExponent; // EVTL Fehler
		System.UInt32		Unit;
		System.Char[]		UnitStr;
		System.Char[]		ChannelName;
		System.Char[]		UserChannelName;
		System.Char[]		UserChannelName_NV;
		System.Byte[]   	RFU; 
    }

Jetzt findet er beim aufruf der Mehthode den Einstiegspunkt nicht.

Fehlermeldung:
Der Einstiegspunkt "Oak_FindSensor" wurde nicht in der DLL "oakw.dll" gefunden.

23.05.2014 - 14:22 Uhr

8o ubbs 😁 Das war keine Absicht Abt!

zu dem PInvoke Interop Assistant: leider funktioniert das nicht... es gibt scheinbar kein Manifest in der DLL.. X(

zumindest laut Fehlermeldung.... 🙄

Ich habe schon versucht eine c++ wrapper dll zu schreiben.. allerdings kann ich damit nicht auf die Methoden zugreifen da man nicht ohne weiteres auf exportierte Methoden zugreifen kann.. ich steh im Moment echt auf dem Schlauch! 🙁

23.05.2014 - 13:23 Uhr

die Fehlermeldungen sehen folgendermaßen aus:

Fehlermeldung:
Fehler 3 Der Typ- oder Namespacename "LPTSTR" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) E:\CSharp Workspace\ntvOrientation\ntvOrientation\API\Controls\GPIOControl.cs 15 76 ntvOrientation

Fehler 9 Der Typ- oder Namespacename "PtOakSensor" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) E:\CSharp Workspace\ntvOrientation\ntvOrientation\API\Controls\GPIOControl.cs 15 191 ntvOrientation

Fehler 2 Der Typ- oder Namespacename "WORD" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) E:\CSharp Workspace\ntvOrientation\ntvOrientation\API\Controls\GPIOControl.cs 15 60 ntvOrientation

Wie oben beschrieben komme ich nicht an die Datentypen ran ?( ?(

🤔

EDIT:
Danke APT.. =) jetzt muss ich nur noch irgendwie den Datentyp PtOakSensor referenzieren!!! 👍

23.05.2014 - 13:13 Uhr

Hallo zusammen,

ich habe folgendes Problem:

Ich muss aus einer dll Mehthoden in c# ausführen. die Header-Datei der in c++ geschriebenen dll sieht folgendermaßen aus:

#pragma once
#include <windows.h>

#define VENDOR_ID_TORADEX 0x1B67
#define MAX_NO_CHANNELS 11

#ifdef __cplusplus	// If used by C++ code, 
extern "C"			// we need to export the C interface
{          
#endif

//---------------------------------------------------------------------------
// differentiate between UNICODE and ASCII versions of the library
//---------------------------------------------------------------------------
#ifdef _UNICODE
	#define tOakString                  tOakString_w
	#define tDevicePathString           tDevicePathString_w
	#define tChannel                    tChannel_w
	#define tOakSensor                  tOakSensor_w
	#define PtOakSensor                 PtOakSensor_w
	#define OAK_HANDLE                  OAK_HANDLE_w
	#define tNotifyFct                  tNotifyFct_w

	#define Oak_Register_Callback       Oak_Register_Callback_w
	#define Oak_Hotplug_Enable          Oak_Hotplug_Enable_w
	#define Oak_NotifyConnectedDevices  Oak_NotifyConnectedDevices_w
	#define Oak_DestroyNotifications    Oak_DestroyNotifications_w
	#define Oak_Feature                 Oak_Feature_w
	#define Oak_Initialize              Oak_Initialize_w
	#define Oak_FindSensor              Oak_FindSensor_w
	#define Oak_GetCurrentInReport      Oak_GetCurrentInReport_w
	#define Oak_GetInReport             Oak_GetInReport_w
	#define Oak_SendOutReport           Oak_SendOutReport_w
#else	// ASCII
	#define tOakString                  tOakString_a
	#define tDevicePathString           tDevicePathString_a
	#define tChannel                    tChannel_a
	#define tOakSensor                  tOakSensor_a
	#define PtOakSensor                 PtOakSensor_a
	#define OAK_HANDLE                  OAK_HANDLE_a
	#define tNotifyFct                  tNotifyFct_a

	#define Oak_Register_Callback       Oak_Register_Callback_a
	#define Oak_Hotplug_Enable          Oak_Hotplug_Enable_a
	#define Oak_NotifyConnectedDevices  Oak_NotifyConnectedDevices_a
	#define Oak_DestroyNotifications    Oak_DestroyNotifications_a
	#define Oak_Feature                 Oak_Feature_a
	#define Oak_Initialize              Oak_Initialize_a
	#define Oak_FindSensor              Oak_FindSensor_a
	#define Oak_GetCurrentInReport      Oak_GetCurrentInReport_a
	#define Oak_GetInReport             Oak_GetInReport_a
	#define Oak_SendOutReport           Oak_SendOutReport_a
#endif


//---------------------------------------------------------------------------
#define ALIGN1 __declspec(align(1))
#define ALIGN2 __declspec(align(2))
#define ALIGN4 __declspec(align(4))
#define ALIGN8 __declspec(align(8))
	//---------------------------------------------------------------------------
	// Type definitions
	//---------------------------------------------------------------------------
	typedef TCHAR	tOakString [24];
	typedef TCHAR	tDevicePathString[256];

	// Data that is available about each single data channel.
	// An array of this type is used as part of the tOakSensor struct below.
	typedef ALIGN8 struct
	{
		ALIGN1	bool		IsSigned;
		ALIGN1	BYTE		BitSize;
				
		ALIGN1	signed char UnitExponent;
		ALIGN4	ULONG		Unit;
		ALIGN8	TCHAR		UnitStr[24];

		ALIGN8	TCHAR		ChannelName[24];
		ALIGN8	TCHAR		UserChannelName[24];
		ALIGN8	TCHAR		UserChannelName_NV[24];

		ALIGN8  BYTE		RFU[64]; // reserved for future use
	} tChannel;

	// Information that is available about a connected sensor
	typedef ALIGN8 struct
	{
		ALIGN8	TCHAR		DevicePath [256];

		ALIGN2	WORD		VID;
		ALIGN2	WORD		PID;
		ALIGN2	WORD		REV;
		ALIGN8	TCHAR		SN[24];

		ALIGN8  BYTE		RFU[64]; // reserved for future use

		ALIGN8	TCHAR		DeviceName[24];
		ALIGN8	TCHAR		UserDeviceName[24];
		ALIGN8	TCHAR		UserDeviceName_NV[24];
		
		ALIGN8	WORD		NumChannels;
		ALIGN8	tChannel	Channel[MAX_NO_CHANNELS];
	} tOakSensor;
	typedef tOakSensor *PtOakSensor, *OAK_HANDLE;

	// The following line of code defines a type named tNotifyFct.
	// Functions of this type are needed as Callback functions (see "Oak_Register_Callback" below).
	// a variable of type tNotifyFct is a pointer to a function that takes a tOakSensor as an argument, and has no return value.
	// A Callback function must look e.g. like this:
	//
	//		void __stdcall SensorWasJustAttached(PtOakSensor Sensor, LPARAM UserParam)
	//		{
	//				/* do necessary actions when a sensor was attached / removed */
	//		}
	//
	//	IMPORTANT: it is strongly recommended to code the Callback function in a way, that it can be called 
	//             more than once for the same sensor!
	//			   Given you want to keep a list of connected sensors, verify in the "OnConnect"
	//			   function if the sensor is already in the list, before adding it.
	typedef void  (__stdcall * tNotifyFct)(PtOakSensor,LPARAM);

	//---------------------------------------------------------------------------
	// Functions to detect sensors
	//---------------------------------------------------------------------------
	// Register a Notify function that will be called, when a device is connected that matches all the filter parameters
	// to ignore a filter parameter, set it to 0 or NULL respectively
extern "C" __declspec(dllexport) void Oak_Register_Callback( tNotifyFct OnConnect, tNotifyFct OnDisconnect,
									  WORD PID, WORD REV, LPTSTR SN, 
									  LPTSTR DeviceName, LPTSTR ChannelName, 
									  LPTSTR UserDeviceName, LPTSTR UserChannelName,
									  LPARAM UserParam);

	// Call once to enable live notifications when a sensor is
	// inserted or removed
extern "C" __declspec(dllexport) void Oak_Hotplug_Enable(void);

	// Call notify function for all currently connected devices that match the registered filter criteria
	// (as if all sensors just has been plugged in)
extern "C" __declspec(dllexport) void Oak_NotifyConnectedDevices(void);

	// Clear all callback functions that are registered to be called on Connect/Disconnect of an Oak Sensor device
extern "C" __declspec(dllexport) void Oak_DestroyNotifications(void);

	//---------------------------------------------------------------------------
	// Functions to communicate with the sensors
	//---------------------------------------------------------------------------

	// Send and Receive a Feature Report to/from the sensor device
	//		- "RptBuf" will be sent to the sensor. 
	//		- The function then waits until the sensor has the result ready ( if there is any). 
	//		- "RptBuf" will finally be overwritten by the sensor's answer.
extern "C" __declspec(dllexport) bool Oak_Feature (LPTSTR DevicePath, BYTE RptBuf[33], bool ExpectResult);

	//---------------------------------------------------------------------------
	// Functions to Read Sensor values
	//---------------------------------------------------------------------------
	// Toradex recommends to use standard windows functions: 
	//  DeviceHandle = Createfile (DevicePath, ...);
	//  ReadFile(DeviceHandle, ReadBuffer, ...);
	//  CloseHandle(DeviceHandle);

	//---------------------------------------------------------------------------
	// Functions only needed for debug purposes
	//---------------------------------------------------------------------------
	// initialize debug stuff
extern "C" __declspec(dllexport) void Oak_Initialize(void);


	//---------------------------------------------------------------------------
	// Blocking functions that return directly with a result
	//---------------------------------------------------------------------------
	// Search for a sensor and result a structure containing information about it.
	// if the provided filters fit for more than one sensor, only one (random) sensor is returned.
	// The function returns true, if a sensor matched the provided filters.
extern "C" __declspec(dllexport) bool Oak_FindSensor(
									  WORD PID, WORD REV, LPTSTR SN,					// filters to be set
									  LPTSTR DeviceName, LPTSTR ChannelName,			// 0 or NULL acts as wildcard.
									  LPTSTR UserDeviceName, LPTSTR UserChannelName,
									  PtOakSensor SensorFound);						// this is the return value

	// Get current device state (USB communication using Control Endpoint)
	// - this function only works for Windows Versions XP and higher
	// - do not use this function to continously read data from the sensor - as it always returns the last
	//   report received, reports may be lost.
extern "C" __declspec(dllexport) bool Oak_GetCurrentInReport (LPTSTR DevicePath, BYTE RptBuf[33], BYTE InReportLength);

	// Wait for a report to be received and return it.
	// The function returns anyway, after "Timeout_ms" has elapsed.
	// - do not set the Timeout_ms close to the sensor's report rate. We found that reports may get lost if you do.
extern "C" __declspec(dllexport) bool Oak_GetInReport (LPTSTR DevicePath, BYTE RptBuf[33], BYTE InReportLength, WORD Timeout_ms);

	// Waits for sending a report and sent it.
	// The function returns anyway, after "Timeout_ms" has elapsed.
	// - do not set the Timeout_ms close to the sensor's report rate. We found that reports may get lost if you do.
extern "C" __declspec(dllexport) bool Oak_SendOutReport (LPTSTR DevicePath, BYTE RptBuf[33], BYTE OutReportLength, WORD Timeout_ms);


#ifdef __cplusplus
}
#endif

wenn ich jetzt mittels dllimport die mehtode folgendermaßen einarbeiten will, bekomme ich Fehler.

[DllImport("oakw.dll", CharSet = CharSet.Auto)]
        public static extern bool Oak_FindSensor(WORD pid, WORD reference, LPTSTR sn, LPTSTR deviceName, LPTSTR channelName, LPTSTR userDeviceName, LPTSTR userChannelName, LPTSTR userParam,PtOakSensor sensorFound);

wie kann ich die Datentypen WORD, LPTSTR und PtOakSensor referenzieren das ich die Methoden benutzen kann?

Kann mir evtl jemand bei dem Problem helfen?

07.03.2014 - 13:38 Uhr

Vielen Dank MrSparkle =)

Werde es mal mit der OpenGL variante probieren da OpenGL in meinem CE Image installiert ist. (hab ich gerade vom Support erfahren)

Gruß
Syl3x

06.03.2014 - 17:51 Uhr

Hallo,

ich muss eine Anwendung für ein Embedded System schreiben in dem ein 3D Würfel dargestellt und rotiert werden muss. in WPF habe ich es nach einigen testen hinbekommen. Da das ganze nun auf .NET compact Framework 3.5 laufen muss kann ich kein WPF verwenden. Hat jemand zufällig eine Idee oder sogar schon ähnliches gemacht?

ich bin für jede Hilfe und Ansatz Dankbar!

Gruß
Syl3x

18.02.2014 - 08:44 Uhr

Also es Funktioniert auf jeden fall so!!



StreamSocket s = new StreamSocket();
DataReader dr = new DataReader(s.InputStream);
DateWriter dw = new DataWriter(s.OutputStream);

// schreiben
dw.WriteBytes(new byte[1] { (byte)  2);
await dw.StoreAsync();

// Lesen (1Byte)
await dr.LoadAsync(1);
vat tmp = dr.ReadByte();


ich hab leider nicht ganz nachvollziehen können warum es bei mir erst nicht funktioniert hat...
war wohl eine Mischung aus mehreren Umständen...

jetzt gehts =)

14.02.2014 - 10:08 Uhr

Hallo,

ich habe eine Windows Phone 8 Anwendung die mit einem Sensor über BlueTooth kommunizieren soll... die Befehle die dich vom Phone aus absende kommen auch an dem Sensor an allerdings kann ich den Stram der Daten des Sensors nicht empfangen.. er sendet garantiert.... ich suche jetzt schon 3 Tage 😦


rivate async void ReadData()
        {
            List<byte> buffer = new List<byte>();

            while (!stopReading)    
{
                try
                {
                 
                    //if (_dataReader == null) _dataReader = new DataReader(_Socket.InputStream);
                    //await _dataReader.LoadAsync(4);
                    //var messageLen = (uint)_dataReader.ReadInt32();
                    //Debug.WriteLine(messageLen);

                    //await _dataReader.LoadAsync(messageLen);
                    //string message = _dataReader.ReadString(messageLen);
                    //byte byteMessage;
                    //byte.TryParse(message, out byteMessage);
                    //Debug.WriteLine(message);

                    await _dataReader.LoadAsync(1);  

                    var stringLength = _dataReader.ReadByte();

                    await _dataReader.LoadAsync(stringLength);

                    var text = _dataReader.ReadString(stringLength);

                    if (SetStatusText != null)
                        SetStatusText(text, false);

                    byte b = Convert.ToByte(text);
}catch (Exception ex)
{}
}
}

kennt jemad vielleicht das problem und kennt eine Lösung?

22.01.2014 - 09:42 Uhr

JUHU =)

Danke jogibear9988,

so klappts =)

21.01.2014 - 16:31 Uhr

Da hast du natürlich vollkommen recht,

aber

WARUM?

das Testfenster ist folgendermaßen aufgebaut


<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:UI="clr-namespace:NTV.UI.UI;assembly=NTV.UI"
        x:Class="TestOberfläche.MainWindow"
        xmlns:NTV="clr-namespace:TestOberfläche"
        Title="MainWindow" Height="350" Width="525">
    <Window.DataContext>
        <NTV:mainWindowViewModel/>
    </Window.DataContext>
    <Grid>
        <Button Content="OK" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
        <Button Content="Cancel" HorizontalAlignment="Left" Margin="10,35,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>
        <Button Content="OK Cancel" HorizontalAlignment="Left" Margin="10,60,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_2"/>
        <UI:NtvTextBox Name="texst" HorizontalAlignment="Left" Margin="10,140,0,0" VerticalAlignment="Top" Width="157" Watermark="Ihr Text" TagName="MeinTagName" HelpText="Hier werden Sie geholfen" IsMultiLingual="True">
            <UI:NtvTextBox.InputBindings>
                <KeyBinding Key="F1" CommandParameter="{Binding ElementName=texst}" Command="{Binding Path=GetHelpText}"></KeyBinding>
            </UI:NtvTextBox.InputBindings>
        </UI:NtvTextBox>
        <Label Content="{Binding Path=HelpText}" HorizontalAlignment="Left" Margin="10,168,0,0" VerticalAlignment="Top" Width="497"/>
    </Grid>
</Window>

Das ViewModel sieht so aus....


sing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace TestOberfläche
{
    public class mainWindowViewModel
    {
        public mainWindowViewModel()
        {
            GetHelpText = new DelegateCommand(GetHelpTextClick);
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void RaisePropertyChanged(string propertyName)
        {
            // take a copy to prevent thread issues
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private string P_myWatermark;
        public string myWatermark
        {
            get
            {
                return P_myWatermark;
            }
            set
            {
                P_myWatermark = value;
                RaisePropertyChanged("myWatermark");
            }
        }

        private string P_HelpText;
        public string HelpText
        {
            get
            {
                return P_HelpText;
            }
            set
            {
                P_HelpText = value;
                RaisePropertyChanged("HelpText");
            }
        } 

        private ICommand C_GetHelpText;
        public ICommand GetHelpText
        {
            get
            {
                return C_GetHelpText;
            }
            set
            {
                C_GetHelpText = value;
                RaisePropertyChanged("GetHelpText");
            }
        }
        private void GetHelpTextClick(object o)
        {
            if (o is NTV.UI.UI.NtvTextBox)
            {
                NTV.UI.UI.NtvTextBox text = (NTV.UI.UI.NtvTextBox)o;
                HelpText = text.HelpText;
            }
        }

        

    }
}

für gewöhnlich funktionieren die Bindings bei mir so....

ich stehe gerade echt auf dem Schlauch!! 🙁

21.01.2014 - 16:04 Uhr

HI MrSparkle,

läßt sich das überhaupt kompilieren, wenn das GetHelpText-Property keine Instanz des ICommand-Interfaces zurück gibt?

Tut es doch... command wird im Konstruktor des Viewmodels erstellt


        public mainWindowViewModel()
        {
            GetHelpText = new DelegateCommand(GetHelpTextClick);
        }

Erstell dir am besten erstmal ein einfaches Projekt und versuch dort, zuerst die Commands und dann die InputBindings zu erstellen.

es ist schon das Testprojekt... 🙁

im Ausgabefenster kommt folgende Fehlermeldung:> Fehlermeldung:

System.Windows.Data Error: 40 : BindingExpression path error: 'GetHelpText' property not found on 'object' ''MainWindow' (Name='')'. BindingExpression:Path=GetHelpText; DataItem='MainWindow' (Name=''); target element is 'KeyBinding' (HashCode=5580417); target property is 'Command' (type 'ICommand')

hab jetzt folgendes schon geändert:

 <KeyBinding Key="F1" CommandParameter="{Binding ElementName=texst}" Command="{Binding Path=GetHelpText,RelativeSource={RelativeSource AncestorType=Window} }"></KeyBinding>

da vorher die Meldung kam das er das Property am Steuerelement selbt nicht findet...

hat aber sonst keine veränderung gebracht.

21.01.2014 - 10:39 Uhr

Hallo,

Ich habe mit eine TextBox mit ein paar extra Properties erstellt. Nun möchte ich das inputBinding benutzen um einen Hilfe-Text an zu zeigen. Ich kann zwar ein Binding erstellen allerding reagiert es nicht.. wenn ich nun von der orginal TextBox das Inputbinding benutze komme ich zwar in das Command an aber wie leite ich es nun weiter?

Die Erweiterte TextBox


<Grid>
<TextBlock Padding="5" VerticalAlignment="Center" FontFamily="SEGOEWP" FontStyle="Italic" Foreground="Gray" Text="{Binding Path=Watermark, RelativeSource={RelativeSource AncestorType=UserControl}}"></TextBlock>
        <TextBox x:Name="waterMarkTextBox" Margin="0,0,0,-2">
            <TextBox.InputBindings>
                <KeyBinding Key="F1" Command="{Binding Path=FireHelpKeyIsPressed}"</KeyBinding>
            </TextBox.InputBindings>
            <TextBox.Style>
                <Style TargetType="{x:Type TextBox}">
                    <Style.Triggers>
                        <Trigger Property="Text" Value="">
                            <Setter Property="Background" Value="Transparent" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </TextBox.Style>
        </TextBox>
    </Grid>

Das Command dazu


private ICommand C_FireHelpKeyIsPressed;
        public ICommand FireHelpKeyIsPressed
        {
            get
            {
                return C_FireHelpKeyIsPressed;
            }
            set
            {
                C_FireHelpKeyIsPressed = value;
                RaisePropertyChanged("FireKeyPressed");
            }
        }
        private void FireHelpKeyIsPressedClick(object o)
        {
         ?????   :what:
        }

im MainWindow


<UI:NtvTextBox Name="texst" HorizontalAlignment="Left" Margin="10,140,0,0" VerticalAlignment="Top" Width="157" Watermark="Ihr Text" TagName="MeinTagName" HelpText="Hier werden Sie geholfen" IsMultiLingual="True">
            <UI:NtvTextBox.InputBindings>
                <KeyBinding Key="F1" CommandParameter="{Binding ElementName=texst}" Command="{Binding Path=GetHelpText}"></KeyBinding>
            </UI:NtvTextBox.InputBindings>
        </UI:NtvTextBox>

und das Command im ViewModel


private ICommand C_GetHelpText;
        public ICommand GetHelpText
        {
            get
            {
                return C_GetHelpText;
            }
            set
            {
                C_GetHelpText = value;
                RaisePropertyChanged("GetHelpText");
            }
        }
        private void GetHelpTextClick(object o)
        {
            if (o is Natev.UI.UI.NtvTextBox)
            {
                Natev.UI.UI.NtvTextBox text = (Natev.UI.UI.NtvTextBox)o;
                HelpText = text.HelpText;
            }
        }

Das KeyBinding im MainWindow funktioniert nicht.
Wie kann ich da am besten vorgehen?

17.01.2014 - 09:17 Uhr

Hallo MrSparkle,

Vielen Dankt für deine Antwort, ich werde es dann wohl mit IsReadOnly lösen müssen...

Der erste Test hat gezeigt das es gut funktioniert!

DANKE!!

16.01.2014 - 17:21 Uhr

Hallo zusammen,
ich habe ein paar Steuerlemente "TextBoxen" deren Parameter IsEnabeld=false ist,

jetzt möchte ich trotzdem ein Event geworfen bekommen wenn man darauf klickt!


<TextBox BorderBrush="#FF3E3E3E" Height="23" Margin="10,232,10,0" TextWrapping="Wrap" Text="{Binding Path=AreaAreaID}" IsEnabled="{Binding Path=configurationIsEnable}" VerticalAlignment="Top" TabIndex="3">
                            <TextBox.InputBindings>
                                <MouseBinding MouseAction="LeftClick" Command="{Binding Path=AreaIDHelpText}"></MouseBinding>
                            </TextBox.InputBindings>
                        </TextBox>

gibts da eine Möglichkeit?

12.12.2013 - 14:02 Uhr

hehehe stimmt habs gerade oben bei geschrieben!!

mein Fehler!!!!

12.12.2013 - 13:56 Uhr

Versuch mal so =)

<Button HorizontalAlignment="Left" Command="{Binding Path=youCommandPath}" Margin="181,298,0,0" VerticalAlignment="Top" Width="30" Height="30" Background="{x:Null}">
    <Image Source="{Binding Path=youImageProperty}"></Image>
</Button>
private BitmapImage P_youImageProperty;
public BitmapImage youImageProperty
{
    get
    {
         return P_youImageProperty;
     }
     set
     {
           P_youImageProperty= value;
           RaisePropertyChanged("youImageProperty");
      }
}

oder

<Button Command="{Binding Path=YouPath}" Width="25" Height="25" Margin="0,10,40,0" VerticalAlignment="Top" HorizontalAlignment="Right" Background="{x:Null}" BorderBrush="#FF3E3E3E">
    <Image Source="Media/Images/minimize.png"></Image>
</Button>

OK Doch nicht... habs erst anders herum verstanden =(
wer lesen kann ist klar im Vorteil =D
also Nicht wie oben!!!

29.11.2013 - 12:47 Uhr

Hallo,

Ich habe eine Anwendung in C# mit WPF nach dem MVVM Pattern Programmiert...
Jetzt muss diese Anwendung auch auf einem Tablett PC laufen... Eine WPF Anwendung ohne MVVM hat dafür ja Events.. StylusDown.. Aber wie realisiere ich das ganze jetzt nach dem MVVM Pattern?

Google hat mir da mal gar nicht weiter geholfen.. und ich bin schon den ganzen Morgen am Suchen!

Vielleicht kann mir jemand von Euch helfen!?!?!?!

28.11.2013 - 12:52 Uhr

zunächst legst du ein Property an an was du die Listbox binden kannst...

public ObservableCollection<ListBoxModel> ConnectionList = new ObservableCollection<ListBoxModel>();

dann hast du irgendein Objekt wie folgendes....

namespace Projectname.Api.Models
{
    public class ListBoxModel
    {
        public int Id { get; set; }
        public string Name { get; set; }
    }
}

Die erstellten Objekte pakst du in die ObservableCollection mit Foreach oder sonst wie!!

In Diesem Beispiel wollen wir dem "Namen" anzeigen

<ListBox HorizontalAlignment="Left" Height="427" VerticalAlignment="Top" Width="266"
         x:Name="LbxMenu" Background="{x:Null}" BorderBrush="{x:Null}"
         ItemTemplate="{DynamicResource MetroListBoxItemTemplate}"
         ItemContainerStyle="{DynamicResource MetroListBoxItemStyle}"
         DisplayMemberPath="Name"     <!-- HIER Name anzeigen-->
         ItemsSource="{Binding ConnectionList}"/>

so sollte es schon gehen!!!

28.11.2013 - 11:45 Uhr

Hallo

Versuch mal

<ListBox HorizontalAlignment="Left" Height="427" VerticalAlignment="Top" Width="266"
         x:Name="LbxMenu" Background="{x:Null}" BorderBrush="{x:Null}"
         ItemTemplate="{DynamicResource MetroListBoxItemTemplate}"
         ItemContainerStyle="{DynamicResource MetroListBoxItemStyle}"
         DisplayMemberPath="Dein Property Name"     <!-- HIER -->
         ItemsSource="{Binding Menu}"/>
25.11.2013 - 12:08 Uhr

Kurz zur erläuterung =)

 <Button Command="{Binding ButtonConnectClickCommand}" x:Name="ButtonConnect" HorizontalAlignment="Left" Margin="10,124,0,0" VerticalAlignment="Top" Width="50" Height="50" BorderBrush="#FF313131" Background="{x:Null}">
            <Image x:Name="test123" Source="{Binding ButtonConnectBackground}"/>
        </Button>

Kein Click Event ... ich denke das meinst du!!!

mache es ja über Commands

folgender Code steht in der MainWindowViewModel.cs

 

  public MainWindowViewModel()
        {
            _DatabaseControl = Api.Controls.DatabaseControl.GetInstance;
            _DatabaseControl.DatabaseUpdate += _DatabaseControl_DatabaseUpdate;
            _DatabaseControl.DatabaseCommunicationError += _DatabaseControl_DatabaseCommunicationError;

            ConnectionList = new ObservableCollection<Database.Connection>();
            CreateConnectionList();
            ButtonConnectBackground = Helper.Images.ConnectImage;
            ButtonConnectClickCommand = new DelegateCommand(ButtonConnectClick);
        }


#region Commands

// Command erstellen
            private ICommand C_ButtonConnectClickCommand;
            public ICommand ButtonConnectClickCommand
            {
                get
                {
                    return C_ButtonConnectClickCommand;
                }
                set
                {
                    C_ButtonConnectClickCommand = value;
                }
            }

// Code der ausgeführt wird
            private void ButtonConnectClick(object obj)
            {
                if (_WrenchControl == null)
                {
                    if (SelectedConnection != null)
                    {
                        conProWin = new UI.Controls.ConnectionProcessWindow();
                        conProWin.Show();
                        conProWin.ViewModel.SetMessage("Verbindung wird hergestellt...");
                        _WrenchControl = Api.Controls.WrenchControl.GetInstance(SelectedConnection);
                        _WrenchControl.CommandResult += _WrenchControl_CommandResult;
                        _WrenchControl.ConnectionClosed += _WrenchControl_ConnectionClosed;
                        _WrenchControl.ConnectionConnected += _WrenchControl_ConnectionConnected;
                        _WrenchControl.ConnectionFailed += _WrenchControl_ConnectionFailed;
                        _WrenchControl.ConnectionIsProduced += _WrenchControl_ConnectionIsProduced;
                        _WrenchControl.ConnectionStateUpdate += _WrenchControl_ConnectionStateUpdate;
                        _WrenchControl.ErrorMessage += _WrenchControl_ErrorMessage;
                        _WrenchControl.NewResult += _WrenchControl_NewResult;
                        _WrenchControl.RealTimeResult_Event += _WrenchControl_RealTimeResult_Event;
                        _WrenchControl.SuccessMessage += _WrenchControl_SuccessMessage;
                        _WrenchControl.UpdateWrenchControl += _WrenchControl_UpdateWrenchControl;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    _WrenchControl.RefreshWrechControl(SelectedConnection);
                }

                ButtonConnectBackground = Helper.Images.DisconnectImage;
                _WrenchControl.SetCommand(Api.Helper.Commands.ConnectCommand);
            }

        #endregion
25.11.2013 - 11:32 Uhr

Hallo Coffeebean,

Danke für die schnelle Antwort...

habs jetzt folgendermaßen gelöst...

weiss aber nicht obs so 100%ig ist.. bin noch ziemlich neu im Beruf... hab erst vor 4 monaten die Umschulung beendet...

    <Window.DataContext>
        <STW:ConnectionProcessWindowViewModel/>
    </Window.DataContext>
namespace ST_Wrench_FullScreen.UI.Controls
{
    /// <summary>
    /// Interaktionslogik für ConnectionProcessWindow.xaml
    /// </summary>
    public partial class ConnectionProcessWindow : Window
    {
        //[Dependency]
        public ConnectionProcessWindowViewModel ViewModel
        {
            get { return (ConnectionProcessWindowViewModel)DataContext; }
            set { DataContext = value; }
        }

        public ConnectionProcessWindow()
        {
            InitializeComponent();
        }
    }
}

und

  private ICommand C_ButtonConnectClickCommand;
            public ICommand ButtonConnectClickCommand
            {
                get
                {
                    return C_ButtonConnectClickCommand;
                }
                set
                {
                    C_ButtonConnectClickCommand = value;
                }
            }
            private void ButtonConnectClick(object obj)
            {
                if (_WrenchControl == null)
                {
                    if (SelectedConnection != null)
                    {
                        conProWin = new UI.Controls.ConnectionProcessWindow();
                        conProWin.Show();
                        conProWin.ViewModel.SetMessage("test");
                        _WrenchControl = Api.Controls.WrenchControl.GetInstance(SelectedConnection);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    _WrenchControl.RefreshWrechControl(SelectedConnection);
                }

                ButtonConnectBackground = Helper.Images.DisconnectImage;
                _WrenchControl.SetCommand(Api.Helper.Commands.ConnectCommand);
            }
25.11.2013 - 10:11 Uhr

public List<ImagedConnectionTreeViewItem> ConnectionList
        {
            get { return (List<ImagedConnectionTreeViewItem>)GetValue(ConnectionListProperty); }
            set { SetValue(ConnectionListProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ConnectionList.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ConnectionListProperty =
            DependencyProperty.Register("ConnectionList", typeof(List<ImagedConnectionTreeViewItem>), typeof(UserControl), new PropertyMetadata(new List<ImagedConnectionTreeViewItem>()));

und


<my:ImagedConnectionTreeViewControl x:Name="tvConnectionList" ItemsSource="{Binding ConnectionList, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}">
25.11.2013 - 09:55 Uhr

Hallo,

Ich habe eine Anwendung die so unübersichtlich geworden ist das ich sie gern in MVVM umbauen würde. Bisher bin ich auch gut klar gekommen.

Zwei Fenster (Main) öffnet (DialogFenster "für Statusnachrichten")

Jetzt weiß ich nicht wie ich es am besten anstellen soll -> Nachrichten an ein zweites Fenster zu senden um diese als Nachricht anzuzeigen

    
<Window.DataContext>
        <STW:ConnectionProcessWindowViewModel/>
</Window.DataContext>

            private ICommand C_ButtonConnectClickCommand;
            public ICommand ButtonConnectClickCommand
            {
                get
                {
                    return C_ButtonConnectClickCommand;
                }
                set
                {
                    C_ButtonConnectClickCommand = value;
                }
            }
            private void ButtonConnectClick(object obj)
            {
                if (_WrenchControl == null)
                {
                    if (SelectedConnection != null)
                    {
                        conProWin = new UI.Controls.ConnectionProcessWindow();
                        conProWin.ShowDialog();
                       // an dieser Stelle und auch später müsste ich nachrichten an das Fenster schicken 
                       // um den Verbindungsvorgang für den Benutzer zu Dokumentieren ... 
                        _WrenchControl = Api.Controls.WrenchControl.GetInstance(SelectedConnection);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    _WrenchControl.RefreshWrechControl(SelectedConnection);
                }

                ButtonConnectBackgroundProperty = Helper.Images.DisconnectImage;
                _WrenchControl.SetCommand(Api.Helper.Commands.ConnectCommand);
            }

Wäre super wenn Ihr mir helfen könntet