|
I'm not sure I understand this. You're trying to use a computer to record some sort of value for you? and this virtual studio ZHAMEL that you make refernce to, this contains properties and values vis a vis teh interwebs? I have additional questions for you in order for me to help you. I should mention that I've never seen a computer do this before.
|
|
|
|
|
Hi there Mr. Mountain........ I've got a thread flying straight toward you......
|
|
|
|
|
|
XAML doesn't do this ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
To have your C# code change XAML properties at design time you need to create a separate DLL that talks specifically to the designer for your control. This DLL needs to be named [control name].VisualStudio.Design.Dll and deployed wherever your control.dll is.
Example:
internal class Metadata : IRegisterMetadata {
public void Register() {
AttributeTableBuilder builder = new AttributeTableBuilder();
builder.AddCustomAttributes(typeof(Button), new FeatureAttribute(typeof(TaskProvider)));
MetadataStore.AddAttributeTable(builder.CreateTable());
}
}
class TaskProvider : Microsoft.Windows.Design.Interaction.PrimarySelectionTaskProvider
{
public TaskProvider()
{
}
protected override void Activate(Microsoft.Windows.Design.Model.ModelItem item)
{
if (String.IsNullOrEmpty((String)item.Properties["StringProperty"].ComputedValue))
item.Properties["StringProperty"].SetValue(Guid.NewGuid().ToString());
base.Activate(item);
}
}
|
|
|
|
|
Hello Friends,
I have a IList collection which consists of IList collection how can i bind them in wpf and get the data...
eg: I have a Ilist<patient> pat
this patient class consists of firstname, lastname and Ilist add.
so now i want to bind the pat to list box and the list box should even display the values of the add IList....
can any one find solution for this.....
cheers
chandu
|
|
|
|
|
I must use only one object data provider in my wpf window. I have two methods that return two collections in code-behinded file. How can I bind those two methods to datagrid? (I'm using third-party datagrid but I think that the binding will be the same.) If I use the methodname in object data provider, i'm able to bind the datagrid. but I want to use one method for one datagrid..
// xmlns:igDP="http://infragistics.com/DataPresenter"
...
<Grid>
<Grid.Resources>
<ObjectDataProvider x:Key="myDataProvider"
ObjectType="{x:Type vm:myViewModel}"
/>
</Grid.Resources>
......
<igDP:XamDataGrid Margin="8,138,8,70" x:Name="mygrid"
DataSource="{Binding Source={StaticResource myDataProvider}, Path=myViewModel.GetDataMethod1}">
</igDP:XamDataGrid>
if I do like that, it will work..
<ObjectDataProvider x:Key="myDataProvider"
ObjectType="{x:Type vm:myViewModel}"
MethodName="GetDataMethod1"/>
I want something like that below but it doesn't work.
<Grid>
<Grid.Resources>
<ObjectDataProvider x:Key="myDataProvider"
ObjectType="{x:Type vm:myViewModel}"
/>
</Grid.Resources>
......
<igDP:XamDataGrid Margin="8,138,8,70" x:Name="mygrid1"
DataSource="{Binding Source={StaticResource myDataProvider}, Path=myViewModel.GetDataMethod1}">
</igDP:XamDataGrid>
<igDP:XamDataGrid Margin="8,138,8,70" x:Name="mygrid2"
DataSource="{Binding Source={StaticResource myDataProvider}, Path=myViewModel.GetDataMethod2}">
</igDP:XamDataGrid>
Any idea? Thanks in advance.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
|
|
|
|
|
Could the two methods not do the binding instead of the XAML? As far as I know (which isn't far I admit !) an ObjecDataProvider can only execute one method.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Thanks. I will export two public properties and use it in datagrid. Thanks again for your reply, Jammer.
|
|
|
|
|
No problem, the xamDataGrid is a great control.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
|
DragSource is not an event. It's a UIElement of some kind.
The author doesn't show how it's defined in his sample code
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oh for goodness sake ... I've gone and made an arse of myself in public AGAIN!
I really shouldn't be trying new things on a Sunday afternoon after a large meal and a few pints ... all the blood is in my stomach!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hello people!
I am a bit new to WPF (worked with WinForms till now). What am I trying to do is a sort of texture mapping.
When I was warking with WinForms I was using Directx SDK.
In my program I am getting a byte array that represents pixels in RGB format. for example byte[] arr = {r1,b1,g1,r2,b2,g2...rn,bn,gn};
So each 3 array cells represent one pixel. Then I was creating a MemoryStream. I had pre-written BMP file header, so I just write my header into the stream and then write my array there as well. So now I've got a Stream that represents a BMP image.
Now I've got my image in the stream. Then, in WinForms+ DirectX SDK I was creating a triangle primitive and was drawing my BMP image on this primitive ( texture mapping);
Now I want to do the same thing in WPF. I still have my byte[] arr ;
Here is the code of what I've done:
First of all this is my "Primitive class"
class PpiSegment : ModelVisual3D
{
MeshGeometry3D segmentMesh;
DiffuseMaterial segmentMaterial;
BitmapImage segmentTexture;
ImageSource segmentTextureSource;
ImageBrush segmentBrush;
// I get 3 points coordinates in the Constructor
public Segment(Point3D leftPoint, Point3D rightPoint, Point3D middlePoint)
{
segmentMesh = new MeshGeometry3D();
segmentMaterial = new DiffuseMaterial();
segmentTexture = new BitmapImage();
segmentBrush = new ImageBrush();
this.Content = new GeometryModel3D();
(this.Content as GeometryModel3D).Geometry = CreateTriangleCoords(leftPoint, rightPoint, middlePoint);
}
/* middle(center)
* /\
* / \
* / \
* / \
* left -------- right
*
*/
internal Geometry3D CreateTriangleCoords(Point3D leftPoint, Point3D rightPoint, Point3D middlePoint)
{
segmentMesh.Positions.Add(leftPoint);
segmentMesh.Normals.Add((Vector3D)leftPoint);
segmentMesh.TextureCoordinates.Add(new Point(1.0, 1.0));
segmentMesh.Positions.Add(rightPoint);
segmentMesh.Normals.Add((Vector3D)rightPoint);
segmentMesh.TextureCoordinates.Add(new Point(1.0, 1.0));
segmentMesh.Positions.Add(middlePoint);
segmentMesh.Normals.Add((Vector3D)middlePoint);
segmentMesh.TextureCoordinates.Add(new Point(0.0, 0.0));
segmentMesh.TriangleIndices.Add(2);
segmentMesh.TriangleIndices.Add(1);
segmentMesh.TriangleIndices.Add(0);
segmentMesh.Freeze();
return segmentMesh;
}
-----------------------------------------------------------------------------------------------------------
and now to the interresting part:
Here I am giving a BMP stream as an Image for the Brush.
//This Stream WAS INITIALIZED Before.
public Stream bitmapStream = new MemoryStream();
//On the first run of my class I call for this function to initialize the "StreamSource" parameter of
"segmentTexture"
public void SetTexture()
{
segmentTexture.BeginInit();
segmentTexture.StreamSource = bitmapStream;
segmentTexture.EndInit();
segmentTextureSource = segmentTexture;
segmentBrush.ImageSource = segmentTextureSource;
segmentMaterial.Brush = segmentBrush;
(this.Content as GeometryModel3D).Material = segmentMaterial;
this.Transform = new TranslateTransform3D(0.0, 0.0, 0.0);
}
Ok, I've got my image loaded. BUT! Now I need to change the image!
So I create somewhere a NEW stream and I amtrying to pass it like I did it before..
public void SetNewTexture(Stream newStream)
{
//I dont need Init/EndInit functions any more... (Don't I?)
segmentTexture.StreamSource = newStream;
segmentTextureSource = segmentTexture;
segmentBrush.ImageSource = segmentTextureSource;
segmentMaterial.Brush = segmentBrush;
(this.Content as GeometryModel3D).Material = segmentMaterial;
this.Transform = new TranslateTransform3D(0.0, 0.0, 0.0);
}
}
But! When I do that NOTHING happens... Image on my triangle primitive doesnt change...
-------------------------------------------------------------------------------------------------------------------------------
Here How I use my Segment class.. maybe its the problem....
class SegmentsBuilder
{
private ModelVisual3D _mv3D;
public PpiSegment[] segmentsArray;
//I am getting a "modelVisual3D" parameter from Window1.xaml
public SegmentsBuilder(ModelVisual3D modelVisual3D)
{
_mv3D = modelVisual3D;
segmentsArray = new PpiSegment[General.numberOfSegments];
}
//I am creating a circle from some number of triangles with textures on them
public void BuildSegments()
{
Point3D leftPoint, rightPoint, middlePoint;
double theta = MathHelper.DegToRad(360.0 / General.numberOfSegments);
double R = 0.95;
middlePoint = new Point3D(0.0, 0.0, General.ppiZCoordinate);
// create a list of triangles
for (int i = 0; i < General.numberOfBeems; i++)
{
//left
leftPoint = new Point3D();
leftPoint.X = R * Math.Cos((double)(i + 1) * theta);
leftPoint.Y = R * Math.Sin((double)(i + 1) * theta);
leftPoint.Z = General.ppiZCoordinate;
//right
rightPoint = new Point3D();
rightPoint.X = R * Math.Cos((double)(i) * theta);
rightPoint.Y = R * Math.Sin((double)(i) * theta);
rightPoint.Z = General.ppiZCoordinate;
segmentsArray[i] = new PpiSegment(rightPoint,leftPoint, middlePoint);
_mv3D.Children.Add(segmentsArray[i]);
}
}
public void UpdateTexture(int segment, Stream texture)
{
segmentsArray[segment].SetNewTexture(texture);
}
So here are my questions...
1)What do I do wrong? Why nothing happens over there?...
2)As I said before I am WPF noobie, so maybe there is another way of doing texture mapping, or doing my task (drawing a bitmap on the triangle)
Any help/ideas/opinions are really welcome... :]
|
|
|
|
|
Am I right in understanding that the bitmap was visible but did not change when you updated the bitmap?
I tried using a MemoryStream and only got it to change by recreating the BitmapDecoder and setting the ImageSource each time, even though it was set not to cache the result.
I also tried using WriteableBitmap in that case just changing the ImageSource on the ImageBrush was enough for it to update. The WriteableBitmap class is improved in 3.5 sp1 and allows access via pointers (don't for get to use AddDirtRect). You can also just write the whole array if you want.
If your not not updating the bitmap I may have misunderstood, if it doesn't show up at all I would check the texture coordinates and test by setting the BackMaterial to a SolidColor. You may also want to check if any of the materials, images e.t.c are Frozen.
|
|
|
|
|
thank you very much! You did understand me right, it just wasnt updating The WriteableBitmap is the solution ;]
|
|
|
|
|
Hi all,
I m new to WPF. I m developing one application in which i want to read XAML file and iterate thru each control element and find the name and value of that control and write to another xml file.
So kindly need yr suggesion..
Thanks
Krishnraj
|
|
|
|
|
the class XamlReader let's you read the root element from a xaml file (with Read method)
then you could iterate thru the logical tree using LogicalTreeHelper
Good Luck
|
|
|
|
|
Hi yanairon,
Thank u very much for replying
OK Now i got the idea.
Again Thanks
Rana Krishnraj
|
|
|
|
|
Hello,
I would like to set the object as a startup object in WPF. Normally, we used to use "this.StartupUri" for that. but I have to use the Uri of XAML file here. I don't like that. I want to set like this.Startup = new MyView(); in App.
Any idea?
Thanks in advance.
Edit: My WPF project should be XBAP-compatible. So, I can't use "Show()" or "Run()" method....
|
|
|
|
|
Michael Sync wrote: this.Startup = new MyView(); in App
Would the Application.MainWindow property work for you?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Wes Aday wrote: Would the Application.MainWindow property work for you?
I just tried but not working. It doesn't show anything on the screen unless we call "Show". But I can't use it "Window" class in Xbap..
I'm not sure why we don't have this.Startup or this.StartUpObject even we have this.StartupUri.
|
|
|
|
|
Hi Michael,
You would need to modify app.g.i.cs file.
Then find StartupURI property of application and modify as:
this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative);
Hope this helps.
Vinay
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Vinay Srivastava wrote: this.StartupUri = new System.Uri("Window1.xaml", System.UriKind.Relative);
Actually, we would like to use with Unity framework.. I have successfully ported Unity framework for Silverlight.. I want to use the code below at that startup..
this.Startup = container.Resolve<shell>();
How can I do that?
In Silverlight, we can do like that..
private void Application_Startup(object sender, StartupEventArgs e) {
IUnityContainer container = new UnityContainer()
.RegisterType<ILogger, TraceLogger>()
.RegisterType<IStoplightTimer, RealTimeTimer>();
this.RootVisual = (UIElement)container.Resolve<StoplightView>();
}
Ref: http://michaelsync.net/2008/07/11/unity-application-block-unity-for-silverlight-and-stoplight-quickstart[^]
|
|
|
|
|
Hello friends...
i have a listview filled with data in it .
and i have a textbox with some string in it.
how can i find that string in the listview and color that particular cell.
can you help me out..
cheers
chandu
|
|
|
|