|
Instead of changing the visibility you could control the button's oppacity.
Something like:
DoubleAnimation animation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromMilliseconds(1400)));
yourButton.BeginAnimation(Load.OpacityProperty, animation);
|
|
|
|
|
Paste this into a window...
<Window.Resources>
<Style x:Key="SelectionButton3"
TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ClipToBounds="False">
<Grid.RowDefinitions>
<RowDefinition Height="75"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border BorderThickness="0,1.5,1.5,1.5"
Background="SteelBlue"
Height="35"
Grid.Column="1"
Grid.Row="0"
Margin="-31"
BorderBrush="DarkSlateBlue">
<Border.BitmapEffect>
<DropShadowBitmapEffect ShadowDepth="4"/>
</Border.BitmapEffect>
</Border>
<Rectangle Fill="SteelBlue"
Stroke="DarkSlateBlue"
Grid.Row="0"
Grid.Column="0">
<Rectangle.LayoutTransform>
<RotateTransform Angle="-45" />
</Rectangle.LayoutTransform>
<Rectangle.BitmapEffect>
<DropShadowBitmapEffect ShadowDepth="5"/>
</Rectangle.BitmapEffect>
</Rectangle>
<ContentPresenter x:Name="ContentArea"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Foreground"
Value="LightGray" />
<Setter Property="FontFamily"
Value="Segoe UI" />
</Style>
</Window.Resources>
<Grid Margin="50">
<Button Click="Button_Click"
Style="{StaticResource SelectionButton3}"
Width="185">
</Button>
</Grid>
You see that both the rectangle and the border have drop shadows. How can I make the borders drop shadow only appear when the mouse is over any part of the control?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Wonder why the univote.
removed is not a supported keyword when I try and compile. I was curious, can't help with gui stuff...
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Wonder why the univote.
I think he has a uni-stalker.
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
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
You can do this via animations and the visual state manager.
This[^] manages the states between transitions in a control.
|
|
|
|
|
Hi!
I've loaded a picture into a Pictrue control. When I double click the picture,I've to write some values to a file. What Event Handler do I've to add for double clicking a picture?
|
|
|
|
|
You need the DoubleTap event. Remember that Windows Phone uses taps, rather than clicks.
|
|
|
|
|
I have to write a desktop business application with the required constraint that each function (page) of the app must be completely written in a scripted language.
So my idea is to use uncompiled XAML for scripting the user interface in WPF, and CodeDOM+CSharpCompiler for the code behind, thus making C# a sort of scripted language. I know the WPF navigation model can't be used in uncompiled XAML so I'll have to write a Custom navigation implementation.
My question is: is the above architecture a good choice (considering the constraint I am subject to)? Or it's just too crazy?
Has any of you ever written something similar?
Any suggestion will be greatly appreciated.
|
|
|
|
|
I don't think I quite understand your problem correctly.
If each page needs to be written in a scripting language, why use xaml in the first place?
You could consider using JQuery + Html5.
|
|
|
|
|
it needs to be a standard desktop app (.exe that is, no browser). Unfortunately I can't change this choice of design.
|
|
|
|
|
Get another job/course whoever set the constraints does not live in the real world.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yup, I tried to convince the people in charge to switch to another architecture but they insist it's a winning model because they are using it since the MS-DOS age. Currently the application runs under WinForms, it has a proprietary script language, proprietary virtual machine, proprietary component library, proprietary editor with syntax highlighting and proprietary "form" editor.
But due to WinForms and limited component library the app isn'tt graphically attractive, so that's why a move to WPF was planned. And while we are moving, I would like to eliminate the virtual machine and embrace full .NET languages (via CodeDom/Reflection). But I'm not sure it's the right choice.
|
|
|
|
|
If you have a PHB insisting on this lunacy then you might check out this article, C# Script: The Missing Puzzle Piece[^] Maybe some help.
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
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Thank you, it's more or less what I am trying to do, so it's going to be helpful. The only difference is that the result of my scripted "programs" would be web-like pages to be loaded in a navigational host application. Unfortunately it seems that the native WPF Navigation/Page model can't be used with uncompiled XAML.
|
|
|
|
|
Hi
I'm using prism and MVVM architecture for my WPF application and I have a problem with RaisePropertyChanged,I have a gridview in my view that its itemsource is binded to an ObservableCollection named AllOrderProducts in my viewmodel,the problem is that when I change AllOrderProducts and i use this.RaisePropertyChanged(() => this.AllOrderProducts);
in doesn't refresh the gridview in my view, and I have this problem with other fields or properties in my viewmodel when I use RaisePropertyChanged
can anyone help me with this problem plzz????
|
|
|
|
|
1. I have a binding list of text descriptions bound to a TextBox. If I use CellEditingTemplate in my DataGridTemplateColumn, the data does not show up until I edit the box. If I change to CellTemplate, the data gets filled in properly (but obviously I can't change it). What parameter am I missing to get the data to fill in using CellEditingTemplate?
2. If I have a second list under the same grid, using DataGridTextColumn. It is not editable. It's just a text field. A) How do I move the text so that it lines up with the text description listed in #1. They don't line up on the same line. B) Is there a way to not highlight the field if the user clicks on it? Maybe not, but it is not editable, so it doesn't make sense to highlight it. However, I do want it to scroll with the list, as each text field pertains to the description.
Thanks.
Sutton
|
|
|
|
|
Hello,
I have a DataGrid. Some of the column are delcared in Xaml and some are dynamic and declared in code. I have a collection of these columns but there is a code where i need to clear all DataGrid columns except the one delcared in code (this is done also using AttachedProperty - i have a collection of columns declared in code and i bind it to an attachedProperty, there i clear the DataGrid columns as i specified).
I want to create anothe Boolean attached Property which i will set in Xaml to true if i want to keep the column .
For this i need to keep a list of all Columns that this boolean attached property is true. How can i do it?
BTW, My Class which handles the AttachedProperties is Static
|
|
|
|
|
I have this button style:
<Style x:Key="SelectionButton"
TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ClipToBounds="False">
<Border CornerRadius="7"
Opacity="50"
BorderBrush="MidnightBlue"
BorderThickness=".5"
Background="{StaticResource SelectionButtonBackground}"/>
<ContentPresenter x:Name="ContentArea"
VerticalAlignment="Center"
Margin="{TemplateBinding Padding}"
Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
1) I would like to add an outer glow. I tried added it in here but nothing happend. Can someone show me how to do this this?
2) I would like the button and its border to be completely transparent until the mouse is over it. I also tried that in this template, but I can't get it working.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
The second point should be solvable with a trigger. For the "normal" appearance, use an opacity of 0, and in the IsMouseOver set it to 100% (caveat: Opacity is a double in WPF). Something like
<Style.Triggers>
<Trigger Property="Button.IsMouseOver" Value="true">
<Setter Property = "Opacity" Value="1"/>
</Trigger>
</Style.Triggers>
|
|
|
|
|
I'm trying to draw 4 3D cubes in wpf.When some on click on first cube then messagebox show first cube is clicked and same for other 3.
Can Somebody help me Please.......
Thanks
|
|
|
|
|
Please do not cross post.
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
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
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
}
}
}
|
|
|
|
|