|
I've experimented for HOURS on this
Anyway, that doesn't work in the context of the code I linked to
(a DataTemplate for an ItemsControl ItemsTemplate)...tried it already,
and tried it again.
I do appreciate the help, thanks!
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My fault... I misread your post, I guess I was working a bit too late...
Anyway, I just recreated a solution based on your code in a previous post. I do not entirely understand what you're trying to do... When I click the Test button, button 3 moves to the first column and a 6th button is added to the grid. Like this:Screenshot[^].
Is this what is supposed to happen? If not, could you explain a bit more about what should happen.
Dawn is nature's way of telling you to go to bed.
|
|
|
|
|
Timmy Kokke wrote: Is this what is supposed to happen?
Yes
I was demonstrating to the OP how changing the data would reflect
in the UI - the test showed you can change the cell position of existing
objects in the collection and add items to the collection.
The code I posted works like I wanted it to....I just didn't like the way
I did the binding from the data object's Row and Col properties to the
Grid.Row and Grid.Column attached properties, and I could't figure out
a better way, so I started this new thread.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Saturday, November 15, 2008 12:51 PM
|
|
|
|
|
The reason why this does not work is because the ItemsControl wraps your object in a container. To get the binding you want you will need to make an StyleSelector to assign to the ItemContainerStyleSelector property of the Items control. Something like this should work:
Public Overrides Function SelectStyle(ByVal item As Object,
ByVal container As System.Windows.DependencyObject)
As System.Windows.Style
Dim matElem As Obs = TryCast(item, Obs)
Dim ret As New Style()
If matElem IsNot Nothing Then
ret.Setters.Add(New Setter(Grid.RowProperty, matElem.PositionY))
ret.Setters.Add(New Setter(Grid.ColumnProperty, matElem.PositionX))
End If
Return ret
End Function
|
|
|
|
|
Excellent Gideon, thank you!
StyleSelector is news to me
I actually needed bindings, not just setters for the initial value, but I'm
much more comfortable setting them in the item style selector than in the
grid ArrangeOverride like I was doing in my hacked solution. This is a much
more appropriate place to set the bindings and I was able to remove the silly
IsBoundToUI flag from the data object class.
Here's what I did:
public class ObsItemStyleSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
Obs obs = item as Obs;
ContentPresenter cp = container as ContentPresenter;
if (null != obs && null != cp)
{
Binding binding = new Binding("Row");
binding.Source = obs;
cp.SetBinding(Grid.RowProperty, binding);
binding = new Binding("Col");
binding.Source = obs;
cp.SetBinding(Grid.ColumnProperty, binding);
}
return null;
}
}
That works well!
Thanks again,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Can someone tell me how to play an swf file via WPF?
Please I need it asap
Thanks
Happy Programming!
Regards,
ctrlnick !
|
|
|
|
|
You need to embed the flash player in your WPF application. You'd use the WindowsFormsHost to put the control in - and you'd have to wrap the ActiveX control.
|
|
|
|
|
I tried, Can you show me sample code?
Happy Programming!
Regards,
ctrlnick !
|
|
|
|
|
|
|
|
I'd use the 3D features of WPF to do this - it will look much better. I'm a little bit busy with the WPF folder browser, so I don't really have time to knock up an implementation right now but if you can wait until next week I'll get back to you on this one.
|
|
|
|
|
|
Geez. What's with you guys and all the pressure? Only kidding.
|
|
|
|
|
A little less chit-chatting and a little more work Pete!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry - but I was cranking out code at 10 past 1 this morning, so I feel properly self-righteous.
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Here is some xaml that will animate an ellipse across the text...basically using visual brush to set the fill property of a TextBlock. Then I animate the Left and Top property of ellipse contained in the visual brush. Since a visual brush can be anything you could put image or video here also, basically any visual you want. Enjoy...
<Window x:Class="TextClippingSomething.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="500">
<Window.Resources>
<Storyboard x:Key="Storyboard1" RepeatBehavior="Forever" AutoReverse="True">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:03" Storyboard.TargetName="MyEllipse" Storyboard.TargetProperty="(Canvas.Left)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:03" Value="100"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:03" Storyboard.TargetName="MyEllipse" Storyboard.TargetProperty="(Canvas.Top)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="20"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="15"/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="20"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="15"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</EventTrigger>
</Window.Triggers>
<Grid>
<TextBlock Text="This is my Text" FontSize="60" FontWeight="Black" RenderTransformOrigin="0.5,0.5" x:Name="textBlock">
<TextBlock.Foreground>
<VisualBrush Stretch="UniformToFill">
<VisualBrush.Visual>
<Canvas>
<Rectangle Width="100" Height="50" Fill="Red"/>
<Ellipse x:Name="MyEllipse" Canvas.Left="0" Canvas.Top="20" Height="10" Width="10" Fill="Aqua"/>
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</TextBlock.Foreground>
</TextBlock>
</Grid>
</Window>
|
|
|
|
|
Hi
How can we change button states in WPF ?
Thank you
|
|
|
|
|
Mohammad Dayyan wrote: change button states
Well I suppose that you could click on the button with a mouse like everyone else....
What is it exactly that you are try to do?
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
|
|
|
|
|
My purpose has been changing the Mouse States styles !
|
|
|
|
|
Mohammad Dayyan wrote: Mouse States styles
Ah, then you should look at how to add Triggers to your style for the MouseEnter, MouseLeave, etc events
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
|
|
|
|
|
Hi all,
i'm a new one in Wpf and i like it so much ,i'm studying and learning about WPF from one month and from 5 months i 'm studying about programmer so i'm poor of knowledge and experience.
I will develop a project within 2 or 3 months in my companyWork and so i will ask some advice about the right software,tools and else to develop in easy way(it's only way that i can run now).
I will give you more precise details ,the project will be based on a Big database on a server and after i will create a application (multithreading) where employees can connect to the database and Add,Delete,Edit the database everyday then i will use many DataGrid so to develop this database i been studying about these software:
- SqlServer _to develop the database
- NHibernate _as Orm to mapping the Database
-WPF _for graphic interface and else...
now i'm in doubt and confuse too,NHibernate is a great ORM but not so friendly with WPF (i saw some news about that) as they are not so easy to use (for me) so i will ask you some useful idea to help me to develop my future project in right way .
Thanks so much for your attention .
Any kind of comments are useful to understand better .
Bye
|
|
|
|
|
I'd say start with something smaller and simpler.
Make a small desktop application that mirrors the sort of functionality that you are looking for.
1. Make a simple SQL Compact database.
2. Use SQLMetal.exe to produce a dbml file from the database
3. Write a small simple WPF app that allows you to work with this database.
ORM bears no relation to WPF as far as I know. ORM is a process of mapping databases to CLR objects irrespective of the UI technology slapped on top of it all.
|
|
|
|
|
Hi Jammer,
thanks to reply me i will follow your advice, i don't know where download SqlMetal.exe as never i used it i will try better to search it.
I already done a project using NHibernate with WPF and a database with SqlServer .I got a trouble when i should populate a DataGrid with NHibernate i couldn't delete and edit a record (but i think it is fault of my knowledge) i used also M-V-VM as pattern i like it but i fell confuse because i learn everything so fast instead i like understand in depth.
After i will try try SqlMetal.exe as you advice me.
If you have other advice you can tell me everything to refresh my mind.
Thanks for your kindness
Have a good time.
Bye
|
|
|
|