|
Try something and then post whatever you have tried here. Maybe after looking at some of your code, someone can help you.
|
|
|
|
|
.cs
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
drawcube();
drawcube2();
}
private void drawcube()
{
Model3DGroup cube = new Model3DGroup();
Point3D p0 = new Point3D(3, 3, 3);
Point3D p1 = new Point3D(5, 3, 3);
Point3D p2 = new Point3D(5, 3, 5);
Point3D p3 = new Point3D(3, 3, 5);
Point3D p4 = new Point3D(3, 5, 3);
Point3D p5 = new Point3D(5, 5, 3);
Point3D p6 = new Point3D(5, 5, 5);
Point3D p7 = new Point3D(3, 5, 5);
//front side triangles
cube.Children.Add(CreateTriangleModel(p3, p2, p6));
cube.Children.Add(CreateTriangleModel(p3, p6, p7));
//right side triangles
cube.Children.Add(CreateTriangleModel(p2, p1, p5));
cube.Children.Add(CreateTriangleModel(p2, p5, p6));
//back side triangles
cube.Children.Add(CreateTriangleModel(p1, p0, p4));
cube.Children.Add(CreateTriangleModel(p1, p4, p5));
//left side triangles
cube.Children.Add(CreateTriangleModel(p0, p3, p7));
cube.Children.Add(CreateTriangleModel(p0, p7, p4));
//top side triangles
cube.Children.Add(CreateTriangleModel(p7, p6, p5));
cube.Children.Add(CreateTriangleModel(p7, p5, p4));
//bottom side triangles
cube.Children.Add(CreateTriangleModel(p2, p3, p0));
cube.Children.Add(CreateTriangleModel(p2, p0, p1));
ModelVisual3D model1 = new ModelVisual3D();
model1.Content = cube;
this.mainViewport.Children.Add(model1);
}
private void drawcube2()
{
Model3DGroup cube2 = new Model3DGroup();
Point3D p0 = new Point3D(4, 4, 4);
Point3D p1 = new Point3D(5, 4, 4);
Point3D p2 = new Point3D(5, 4, 5);
Point3D p3 = new Point3D(4, 4, 5);
Point3D p4 = new Point3D(4, 5, 4);
Point3D p5 = new Point3D(5, 5, 4);
Point3D p6 = new Point3D(5, 5, 5);
Point3D p7 = new Point3D(4, 5, 5);
//front side triangles
cube2.Children.Add(CreateTriangleModel(p3, p2, p6));
cube2.Children.Add(CreateTriangleModel(p3, p6, p7));
//right side triangles
cube2.Children.Add(CreateTriangleModel(p2, p1, p5));
cube2.Children.Add(CreateTriangleModel(p2, p5, p6));
//back side triangles
cube2.Children.Add(CreateTriangleModel(p1, p0, p4));
cube2.Children.Add(CreateTriangleModel(p1, p4, p5));
//left side triangles
cube2.Children.Add(CreateTriangleModel(p0, p3, p7));
cube2.Children.Add(CreateTriangleModel(p0, p7, p4));
//top side triangles
cube2.Children.Add(CreateTriangleModel(p7, p6, p5));
cube2.Children.Add(CreateTriangleModel(p7, p5, p4));
//bottom side triangles
cube2.Children.Add(CreateTriangleModel(p2, p3, p0));
cube2.Children.Add(CreateTriangleModel(p2, p0, p1));
ModelVisual3D model = new ModelVisual3D();
model.Content = cube2;
this.mainViewport1.Children.Add(model);
}
private Model3DGroup CreateTriangleModel(Point3D p0, Point3D p1, Point3D p2)
{
MeshGeometry3D mesh = new MeshGeometry3D();
mesh.Positions.Add(p0);
mesh.Positions.Add(p1);
mesh.Positions.Add(p2);
mesh.TriangleIndices.Add(0);
mesh.TriangleIndices.Add(1);
mesh.TriangleIndices.Add(2);
Vector3D normal = CalculateNormal(p0, p1, p2);
mesh.Normals.Add(normal);
mesh.Normals.Add(normal);
mesh.Normals.Add(normal);
Material material = new DiffuseMaterial(
new SolidColorBrush(Colors.Red));
GeometryModel3D model = new GeometryModel3D(
mesh, material);
Model3DGroup group = new Model3DGroup();
group.Children.Add(model);
return group;
}
private Vector3D CalculateNormal(Point3D p0, Point3D p1, Point3D p2)
{
Vector3D v0 = new Vector3D(
p1.X - p0.X, p1.Y - p0.Y, p1.Z - p0.Z);
Vector3D v1 = new Vector3D(
p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z);
return Vector3D.CrossProduct(v0, v1);
}
}
}
|
|
|
|
|
.Xaml file
<Window x:Class="Cube.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Viewport3D Name="mainViewport" ClipToBounds="True">
<Viewport3D.Camera>
<PerspectiveCamera
FarPlaneDistance="50"
LookDirection="-11,-10,-9"
UpDirection="0,1,0"
NearPlaneDistance="1"
Position="11,10,9"
FieldOfView="90" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight
Color="White"
Direction="-2,-3,-1" />
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
<Viewport3D Name="mainViewport1" ClipToBounds="True">
<Viewport3D.Camera>
<PerspectiveCamera
FarPlaneDistance="50"
LookDirection="-7,-6,-5"
UpDirection="1,2,3"
NearPlaneDistance="4"
Position="10,8,9"
FieldOfView="50" />
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight
Color="White"
Direction="-1,-2,-3" />
</ModelVisual3D.Content>
</ModelVisual3D>
</Viewport3D>
<my:TrackballDecorator HorizontalAlignment="Right" Margin="0,56,-154,72" Name="trackballDecorator1" Width="77" xmlns:my="clr-namespace:_3DTools;assembly=3DTools" />
</Grid>
</Window>
|
|
|
|
|
Hi. please am creating an application in which i created a list collection and successfully binded it to a datagrid. but the problem am having is to pull data back from the datagrid and use it to form the elements of the same list collection when a user clicks the SAVE button after making changes to the datagrid.
Thanks in advance.
the XAML is shown below:
<Grid Background="CornflowerBlue">
<DataGrid AutoGenerateColumns="False" Height="530" HorizontalAlignment="Left" Margin="12,12,0,0" Name="gridBeveragesAndJuices" VerticalAlignment="Top" Width="573"
HorizontalGridLinesBrush="Cyan" RowBackground="#FF12AD12" VerticalGridLinesBrush="Cyan" Foreground="Cyan" EnableColumnVirtualization="False"
EnableRowVirtualization="False" CanUserDeleteRows="True" CanUserAddRows="True" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" AlternatingRowBackground="DodgerBlue" FontSize="13">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Foreground" Value="DodgerBlue" />
<Setter Property="BorderBrush" Value="Yellow" />
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Width="287" Header=" ITEMS"
Binding="{Binding Path=ITEMS8, Mode=TwoWay, NotifyOnTargetUpdated=True}" x:Name="ItemsColumn" />
<DataGridTextColumn Width="286" Header=" PRICE"
Binding="{Binding Path=PRICE8, Mode=TwoWay, NotifyOnTargetUpdated=True}" x:Name="PriceColumn"/>
</DataGrid.Columns>
</DataGrid>
<Button Content="Cancel" Height="23" HorizontalAlignment="Left" Margin="67,578,0,0" Name="btnCancel" VerticalAlignment="Top" Width="75" />
<Button Content="Save" Height="23" HorizontalAlignment="Left" Margin="256,578,0,0" Name="btnSave" VerticalAlignment="Top" Width="75" Click="btnSave_Click" />
<Button Content="Exit" Height="23" HorizontalAlignment="Left" Margin="444,578,0,0" Name="btnExit" VerticalAlignment="Top" Width="75" />
</Grid>
And below is the code behind:
public partial class BeveragesAndJuices : Window
{
public BeveragesAndJuices()
{
InitializeComponent();
gridBeveragesAndJuices.ItemsSource = Source8;
}
public class Values8
{
public string ITEMS8 { get; set; }
public decimal PRICE8 { get; set; }
}
public List<Values8> Source8 = new List<Values8>
{
new Values8(){ITEMS8 = "Lacasera ", PRICE8 = 290}, new Values8(){ITEMS8 = "Cran-Orange Chiller ", PRICE8 = 290}, new Values8(){ITEMS8 = "Festive Fruity Flavored Milk ", PRICE8 = 290},
new Values8(){ITEMS8 = "Homemade Iced Coffee ", PRICE8 = 290}, new Values8(){ITEMS8 ="Lemon Cucumber Seltzer " , PRICE8 = 290}, new Values8(){ITEMS8 = "Fizzy Water ", PRICE8 = 290},
new Values8(){ITEMS8 ="Haunted (Black Cauldron) Punch " , PRICE8 = 290}, new Values8(){ITEMS8 ="Lemon Ginger Iced Green Tea " , PRICE8 = 290}, new Values8(){ITEMS8 ="Orange Creamsicle Shake " , PRICE8 = 290},
new Values8(){ITEMS8 = "Blueberry Blast Smoothie ", PRICE8 = 290}, new Values8(){ITEMS8 ="Shamrock Milk Mixer " , PRICE8 = 290}, new Values8(){ITEMS8 = "Pomegranate Punch ", PRICE8 = 290},
new Values8(){ITEMS8 ="anned Milo " , PRICE8 = 290}, new Values8(){ITEMS8 ="Viju Milk " , PRICE8 = 290}, new Values8(){ITEMS8 = "5 Alive ", PRICE8 = 290},
new Values8(){ITEMS8 ="Cherry Vanilla Smoothie " , PRICE8 = 290}, new Values8(){ITEMS8 = "Boysenberry-Banana Blast ", PRICE8 = 290}, new Values8(){ITEMS8 = "Vanilla Iced Mochaccino ", PRICE8 = 290},
new Values8(){ITEMS8 ="Choco-Nana Milk Mixer " , PRICE8 = 290}, new Values8(){ITEMS8 = "Fresh Fruit Pudding Milk Mixer ", PRICE8 = 290}, new Values8(){ITEMS8 ="Luscious Licuado " , PRICE8 = 290},
new Values8(){ITEMS8 = "Frosty Pine-Orange Yogurt Smoothie ", PRICE8 = 290}, new Values8(){ITEMS8 = "Mocha-ccino Freeze ", PRICE8 = 290}, new Values8(){ITEMS8 ="Lite Iced Mocha " , PRICE8 = 290},
new Values8(){ITEMS8 ="Nectarine Whirl " , PRICE8 = 290}, new Values8(){ITEMS8 ="Strawberries and Cream Smoothie " , PRICE8 = 290}, new Values8(){ITEMS8 ="Strawberry Light Lemonade " , PRICE8 = 290}
};
private void btnSave_Click(object sender, RoutedEventArgs e)
{
//clear the elements of the source
Source8.Clear();
//get the items on the datagrid and use them to form new elements of the
//Source8
foreach(DataGridRow Row in gridBeveragesAndJuices)
{
//this where am stuck, foreach flags an error
//that DataGridRow does not have a definition for GetEnumerator
}
}
}
|
|
|
|
|
Go back and start again, you have completely the wrong idea of how WPF is designed to work. Under no circumstances should you be looping through a xaml control.
WPF is all about binding, first you make your class observable by implementing INotifyChange (this is really easy) then you have an ObservableCollection of your class (system.Collections.Object) which you bind to your datagrid.
When an item is changed in your collection set a flag. When the user saves \then iterate the COLLECTION not the control.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have this Border with a Drop Shadow. I would like to Color and ShadowDepth values of the DropShowEffect with a MouseOver trigger, except I can't seem to figure out where to put the trigger.
Anyone know how to do this?
<Border CornerRadius="35,7,7,35">
<Border.Background>
<LinearGradientBrush StartPoint="0,0"
EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="Goldenrod"
Offset="0" />
<GradientStop Color="White"
Offset=".5" />
<GradientStop Color="Gold"
Offset="1" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect Color="LightGray"
ShadowDepth="5"
RenderingBias="Quality"/>
</Border.Effect>
</Border>
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Hello,
How do i use ResourceDictionary?
I created a xaml file with resourceDictionary with ImageSource
Than in my UserControl i must to mention a key for the resourceDictionary (otherwise it doesn't compile):
<ResourceDictionary x:Key="resourceDictionary">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AQUA.ClientServices.Presentation;component/Images/ImageResources.xaml">
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
But when i am trying to use one of the resources in the dictionary it says the resource key can't be found
|
|
|
|
|
Have you inserted this code within your App.xaml file? If not, place in App.xaml file and remove the key attribute all together
<Application x:Class="MyWpfApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/AQUA.ClientServices.Presentation;component/Images/ImageResources.xaml">
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Hopefully that will help
"You get that on the big jobs."
|
|
|
|
|
I right my application using PRISM and my user control is a module.
How can i define to use the resource dictionary in the scope of the userControl ?
|
|
|
|
|
I don't do PRISM but I still think you want to get rid of the x:key. Also the / in front of AQUA doesn't look right either. Try removing that as well.
"You get that on the big jobs."
|
|
|
|
|
I was thinking about creating a WPF app. The main window would have a background like this[^].
Any reason not to use an image of some kind, or is it better to try to do the graphic in XAML?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Hi there I want a great HTML editor in WPF. So for this what I did is that I added a WebBrowser to WPF window and navigated it to the html page with the TinyMCE html editor in it. However when I rin the app, the browser control shows the script warning as follows:
http://s13.postimage.org/rod6itsjb/brerr.png[^]
XAML
<Window x:Class="TinyMceWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" >
<Grid>
<WebBrowser Name="webBrowser1" Margin="0,0,0,54" />
<Button Content="Get Html" Height="31" HorizontalAlignment="Left" Margin="22,0,0,17" Name="btnGetHtml" VerticalAlignment="Bottom" Width="108" Click="btnGetHtml_Click" />
</Grid>
</Window>
XAML.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 TinyMceWpf
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
webBrowser1.Navigate(new Uri(@"C:\Users\MAHESH\Desktop\TechNode\WPF\MytTechDos\TinyMceWpf\TinyMceWpf\TinyMceWpf\edit.html"));
}
private void btnGetHtml_Click(object sender, RoutedEventArgs e)
{
string editHtml = this.webBrowser1.InvokeScript("getContent").ToString();
MessageBox.Show(editHtml);
}
}
}
So here how can I suppress the script error message of the web-browser control?
I found many solutions online some that uses SupressScriptErrors property which I did not find in WOF WebBrowser control and the others that used Reflection. I tried many of them.
I tried Wolfie5's Relflection solution at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/4f686de1-8884-4a8d-8ec5-ae4eff8ce6db/[^]. But did not worked for me.
Also I tried another Reflection solution that I explained in greated details here:
http://stackoverflow.com/questions/10030300/script-warning-in-wpf-webbrowser#comment12832540_10030300[^]
I did not get any help on these forums. SO Code Project is my last resort.
Please help. I am stuck here. Thank you.
|
|
|
|
|
I have a asp application that calls a web service sessionservice.asmx. When it tries to make the service call I get the error: error: the remote server returned the error: NotFound. I believe the problem is the wrong endpoint address in the serverreference.clientconfig file. What is the proper endpoint to use when running from the debugger?
|
|
|
|
|
|
I just created a new WPF app. I set up some folder, then added a resource dictionary called AppResources in the Resources folder.
In my window, all I have is
<Window x:Class="MyApp.Views.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2"
Height="400"
Width="400">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources\AppResources.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
</Grid>
</Window>
The compiler is complaining with
"The file 'Resources\AppResources.xaml' is not part of the project or its 'Build Action' property is not set to 'Resource'."
The file IS part of the project and its Action property IS set to Resource.
I'v been in this project for all of 5 minutes and I can't even get past this.
Anyone know WTF is wrong here??????
Everything makes sense in someone's mind
|
|
|
|
|
That did it.
Thank you
Everything makes sense in someone's mind
|
|
|
|
|
Kevin, you (and the rest of us) are benefiting from some excellent support here, while thanks are appreciated it would be better to upvote the useful answers!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You are right. I will do so from now on.
Everything makes sense in someone's mind
|
|
|
|
|
after adding items to list, still it show "-1" as their index
|
|
|
|
|
Nope. No idea. No code. Throw us a rope here mate; actually give us some code to look at.
|
|
|
|
|
http://www.microsoft.com/design/toolbox[^]
Its very useful site i guess for silverlight startup.I want similar website which could elaborate WPF developments..
I wanna develop some application in wpf..But i am getting confused in many things..
If i could get a simple elaboration by videos then it will be great..
|
|
|
|
|
The basic concepts are the same, do the Silverlight training, this will supply the conceptual framework and allow you to step into WPF.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have binded two simple text strings into a ListBox. works fine. But, I'm having trouble binding a text string and a checkbox to a listbox. The text shows up, but not the checkboxes. I did the code almost the same. It compiles fine. Can anyone tell me why?
List<ExternalAlarmEntry> eaentry = new List<ExternalAlarmEntry>();
CheckBox[] eaCB = new CheckBox[64];
void CreateExternalAlarmTable()
{
ExternalAlarmTable.Height = 120;
for (byte i = 0; i < 5; i++)
{
eaCB[i] = new CheckBox();
eaCB[i].IsChecked = false;
eaentry.Add(new ExternalAlarmEntry()
{
ZoneNum = "Zone " + (i + 1),
ExternalAlarm = eaCB[i]
});
}
ExternalAlarmTable.ItemsSource = eaentry;
}
public class ExternalAlarmEntry
{
public string ZoneNum { get; set; }
public CheckBox ExternalAlarm;
}
|
|
|
|
|
You don't bind UI elements like this. Change the ExternalAlarm property into a boolean (and make it a property, not a field), then use this in your list box ItemTemplate. The ItemTemplate would look something like this:
<DataTemplate x:Key="myItemsTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition />
<Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding ExternalAlarm}" Grid.Column="0" />
<TextBlock Text="{Binding ZoneNum}" Grid.Column="1" />
</Grid>
</DataTemplate> Your list box will look like this
<ListBox ItemTemplate="{StaticResource myItemsTemplate}" x:Name="ExternalAlarmTable" />
|
|
|
|
|
Obviously, I'm not getting it. I've been in the embedded world for 25 years. And, some of the Windows programming isn't making sense quite yet. I guess I'll have to get the exact code working before I can analyze each piece before I understand how it works.
I already have a Grid broken down into subgrids. One of the subgrids, I would like to contain this ListBox. How do I incorporate your WPF code into my subgrid? Here is the previous WPF code in which you said my method isn't going to work.
Also, in my C# code, I will populate the ListBox based on the system the user selects. If he selects system 'A', the box will have 5 entries. If he selects system 'B', the box will have 64 entries. That was the previous code I sent you. I can't do it all in WPF.
<DataGrid Grid.Column="0" Grid.Row="1" Height="150" Width="300"
CanUserAddRows="false"
AutoGenerateColumns ="false"
HorizontalAlignment="Left"
RowHeight ="20"
Margin="15,10,0,0"
VerticalAlignment="Top"
Name="ExternalAlarmTable"
CanUserSortColumns="False"
CanUserResizeColumns="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Header = "Zone #"
Width = "SizeToHeader"
Binding = "{Binding ZoneNum}"
IsReadOnly="true"/>
<DataGridTextColumn Header = "External Alarm Setting"
Binding = "{Binding ExternalAlarm}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
|
|
|
|
|