|
I think you need to post this in the C# .NET this is the WPF / Silverlight venue.
|
|
|
|
|
TheArchitectmc∞ wrote: this is the WPF / Silverlight venue
hmm...ok.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My apologies, this is the right place big guy....
|
|
|
|
|
The title of this forum is WPF / WCF / WF
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Darn I guess I got whacked with the idiot stick today!
|
|
|
|
|
I know the feeling
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Do message headers had to be attached before any content is appended? Is it possible that you've added the message too late in the cycle? Can you attach it earlier?
|
|
|
|
|
I think that the header is addad at the correct time, but I guess there is a problem with deserialization.
Thank you for your reply
Uros
|
|
|
|
|
koleraba wrote: But all Properties of the UserCredentialsHeaderContent are null.
I don't see any place you're calling the deserialization code.
Am I missing something?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No you are not missing it. When I was implementing the custrom header class, I was looking which metod to overrite to deserialize the header, but I did not find anything. I know that serialization should be done in the OnWriteHeaderContent but there is no OnReadHeaderContent. Do you know where the deserialization code should be. Thank you for your reply.
Uros
|
|
|
|
|
koleraba wrote: Do you know where the deserialization code should be.
A ReadHeader method is in your class, but you need to call it.
I modified the parameter type of your code like this:
public static UserCredentialsHeaderContent ReadHeader(MessageHeaders headers)
{
int headerIndex = headers.FindHeader(HEADER_NAME, HEADER_NAMESPACE);
if (headerIndex != -1)
{
XmlNode[] contentNode = headers.GetHeader<XmlNode[]>(headerIndex);
string text = contentNode[0].InnerText;
XmlSerializer deSerializer = new XmlSerializer(typeof(UserCredentialsHeaderContent));
StringReader stringReader = new StringReader(text);
UserCredentialsHeaderContent content = (UserCredentialsHeaderContent)deSerializer.Deserialize(stringReader);
stringReader.Close();
return content;
}
else
{
return null;
}
}
and called it like this
UserCredentialsHeaderContent headercontent = UserCredentialsMessageHeader.ReadHeader(OperationContext.Current.IncomingMessageHeaders);
Works fine.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark thank you for your time. In the mean time I found the same solution and it works fine. But as you said you have to call the deserialization code by your self - there isn't any method that you could override.
Thanks again for your time
Uroš
|
|
|
|
|
How does one override the default listview item background:
clear - for unselected items
blue - for selected items when the listview has keyboard focus
silver - for seleected items when the listview does not have keyboard focus?
|
|
|
|
|
Try using Google: I use the site tage so it only searches microsoft:
'listview WPF C# .NET site:microsoft.com'
You have to make a template for it....
<Style x:Key="{x:Type ListView}" TargetType="ListView">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListView">
<Border Name="Border"
BorderThickness="1"
BorderBrush="{StaticResource SolidBorderBrush}"
Background="{StaticResource WindowBackgroundBrush}">
<ScrollViewer Style="{DynamicResource
{x:Static GridView.GridViewScrollViewerStyleKey}}">
<ItemsPresenter />
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsGrouping"
Value="true">
<Setter Property="ScrollViewer.CanContentScroll"
Value="false"/>
</Trigger>
<Trigger Property="IsEnabled"
Value="false">
<Setter TargetName="Border"
Property="Background"
Value="{StaticResource DisabledBorderBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
~TheArch
|
|
|
|
|
Is there any way to know the user clicked the DataGrid column to change the sorting?
|
|
|
|
|
I never worked with DataGrid but I would take a look at the SortCommand event of the DataGrid.
Greetings
Covean
|
|
|
|
|
I am using Silverlight 3, and there is no SortCommand event with DataGrid. Thanks for your reply.
|
|
|
|
|
Sorry my fault, I didn't mentioned that I answered to a silverlight question.
Sorry for that.
Greetings
Covean
|
|
|
|
|
Guys,
I'm trying a simple animation in code behind with a start/stop button.
However, my animation does not want to stop for some reason (despite MSDN showing me the same as I did).
It's probably something small I did wrong, but I can't find it.
I'm also a litte puzzled with the PropertyPath object.
Many thanks.
private void btn_start_Click(object sender, RoutedEventArgs e)
{
if(sb == null){
sb = new Storyboard();
da = new DoubleAnimation();
da.From = 0;
da.To = 360;
da.Duration = new Duration(new TimeSpan(0, 0, 10));
da.RepeatBehavior = RepeatBehavior.Forever;
rectangle_animation.RenderTransform = new RotateTransform();
rectangle_animation.RenderTransformOrigin = new Point(0.5, 0.5);
rectangle_animation.RenderTransform.BeginAnimation(RotateTransform.AngleProperty, da);
sb.Children.Add(da);
Storyboard.SetTargetProperty(da, new PropertyPath("Background.Opacity"));
sb.Begin(this, true);
}
else{
sb.Resume(this);
}
btn_stop.Visibility = Visibility.Visible;
btn_start.Visibility = Visibility.Hidden;
}
private void btn_stop_Click(object sender, RoutedEventArgs e)
{
if(sb != null){
sb.Pause(this);
}
btn_stop.Visibility = Visibility.Hidden;
btn_start.Visibility = Visibility.Visible;
}
|
|
|
|
|
I think it is that you are using the pause method look at this from MSDN:
This method pauses the storyboard, but has no discernible effect if it
is not active or currently paused. As a side effect, all associated
children are also paused.
A controllable storyboard can pause, resume, seek, stop, and be removed. To
make a storyboard controllable in code, you must use the appropriate
overload of the storyboard's Begin method and specify true to make it
controllable. For an example, see How to: Control a Storyboard After It
Starts.
Try using the stop method instead.
|
|
|
|
|
thanks, in meantime I was able to add a second animation (color).
I probably set the PropertyPath wrong.
I used Background.color as propertypath for the color animation, which puts the window background in color, animates it AND pauses correctly (while the rotation continues).
My goal is however to rotate and change color of the rectangle only. I feel I'm near, but the PropertyPath is still illuding me a little.
(for the record, one of the errors was indeed that you have to use the overloaded Begin method with Controllable set to True.)
|
|
|
|
|
FYI, I got it to work. Here's the code.
The result is that only the Rectangle will turn and change color when starting the animation. They both stop when stopping the animation.
if(sb == null){
sb = new Storyboard();
da = new DoubleAnimation();
da.From = 0;
da.To = 360;
da.Duration = new Duration(new TimeSpan(0, 0, 10));
da.RepeatBehavior = RepeatBehavior.Forever;
rectangle_animation.RenderTransform = new RotateTransform();
rectangle_animation.RenderTransformOrigin = new Point(0.5, 0.5);
ca = new ColorAnimation();
ca.From = Colors.Red;
ca.To = Colors.Blue;
ca.Duration = new Duration(new TimeSpan(0, 0, 10));
ca.RepeatBehavior = RepeatBehavior.Forever;
ca.AutoReverse = true;
if(rectangle_animation.Fill == null){
rectangle_animation.Fill = new SolidColorBrush();
}
this.RegisterName("rectangle_angle", rectangle_animation.RenderTransform);
Storyboard.SetTargetName(da, "rectangle_angle");
Storyboard.SetTargetProperty(da, new PropertyPath(RotateTransform.AngleProperty));
this.RegisterName("rectangle_brush", (SolidColorBrush)rectangle_animation.Fill);
Storyboard.SetTargetName(ca, "rectangle_brush");
Storyboard.SetTargetProperty(ca, new PropertyPath(SolidColorBrush.ColorProperty));
sb.Children.Add(da);
sb.Children.Add(ca);
sb.Begin(this, true);
}
else{
sb.Resume(this);
}
btn_stop.Visibility = Visibility.Visible;
btn_start.Visibility = Visibility.Hidden;
}
private void btn_stop_Click(object sender, RoutedEventArgs e)
{
if(sb != null){
sb.Pause(this);
}
btn_stop.Visibility = Visibility.Hidden;
btn_start.Visibility = Visibility.Visible;
}
|
|
|
|
|
Hey could you comment the code or put some highlights in so theirs can easily identify what your solution was?
Also if you use the pre tag make sure that the code fits on the page, if you see a scroll bar at the bottom you will need to adjust the formatting.
I would like to know what you had to do....
Good to see you got it working....
|
|
|
|
|
Reformat? No way, that would come out more ugly, but here's the code with additional comments.
Note I continued playing with it.
private void btn_start_Click(object sender, RoutedEventArgs e)
{
if(sb == null){
sb = new Storyboard();
da = new DoubleAnimation();
da.From = Convert.ToInt32(txtbox_anglefrom.Text);
da.To = Convert.ToInt32(txtbox_angleto.Text);
string [] timespan = txtbox_duration.Text.Split(new string [] {":"}, StringSplitOptions.None);
da.Duration = new Duration(new TimeSpan(Convert.ToInt32(timespan[0]), Convert.ToInt32(timespan[1]), Convert.ToInt32(timespan[2])));
da.RepeatBehavior = RepeatBehavior.Forever;
da.AutoReverse = true;
rectangle_animation.RenderTransform = new RotateTransform();
rectangle_animation.RenderTransformOrigin = new Point(0.5, 0.5);
ca = new ColorAnimation();
ca.From = Colors.Red;
ca.To = Colors.Blue;
ca.Duration = new Duration(new TimeSpan(Convert.ToInt32(timespan[0]), Convert.ToInt32(timespan[1]), Convert.ToInt32(timespan[2])));
ca.RepeatBehavior = RepeatBehavior.Forever;
ca.AutoReverse = true;
if(rectangle_animation.Fill == null){
rectangle_animation.Fill = new SolidColorBrush();
}
this.RegisterName("rectangle_angle", rectangle_animation.RenderTransform);
Storyboard.SetTargetName(da, "rectangle_angle");
Storyboard.SetTargetProperty(da, new PropertyPath(RotateTransform.AngleProperty));
this.RegisterName("rectangle_brush", (SolidColorBrush)rectangle_animation.Fill);
Storyboard.SetTargetName(ca, "rectangle_brush");
Storyboard.SetTargetProperty(ca, new PropertyPath(SolidColorBrush.ColorProperty));
sb.Children.Add(da);
sb.Children.Add(ca);
sb.Begin(this, true);
txtbox_duration.IsEnabled = false;
txtbox_anglefrom.IsEnabled = false;
txtbox_angleto.IsEnabled = false;
}
else{
sb.Resume(this);
}
btn_stop.IsEnabled = true;
btn_start.IsEnabled = false;
}
private void btn_stop_Click(object sender, RoutedEventArgs e)
{
if(sb != null){
sb.Pause(this);
}
btn_stop.IsEnabled = false;
btn_start.IsEnabled = true;
}
private void btn_close_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btn_restart_Click(object sender, RoutedEventArgs e) {
sb.Stop(this);
sb = null;
this.UnregisterName("rectangle_angle");
this.UnregisterName("rectangle_brush");
btn_stop.IsEnabled = false;
btn_start.IsEnabled = true;
txtbox_duration.IsEnabled = true;
txtbox_anglefrom.IsEnabled = true;
txtbox_angleto.IsEnabled = true;
}
there, I hope that's useful
|
|
|
|
|
Do a search on XAML templates, you can do most of what you are doing with a template and triggers....
Google Friendly search: 'xaml templates WPF C# .NET site:microsoft.com'
|
|
|
|