|
I have a WPF project containing a RichTextBox .
I want the text not to wrap. I can force this by setting the PageWidth for the contained FlowDocument to be a large number. However, I really want the PageWidth to adjust itself to the length of the longest line (paragraph), so that the horizontal scroll bar thumb will have an appropriate length.
I tried setting PageWidth to Auto , but this did not prevent wrapping.
Thanks for your suggestions!
tfhain
|
|
|
|
|
i am developing an wpf applition,
in which s seprate window is used for to show some extra details from main window..
if i click one button it will open up the extra window..
the thing here is if i click anyother place in the screen, i have to close that extra widnow????
can any one help me regarding this, thanks now itslef.
|
|
|
|
|
To close a window you can use the Close[^] method.
e.g.,
yourWindowObject.Close();
|
|
|
|
|
i am using an WPF application..
here the visual children count is comming as 0..
even i am having number of childrens there. how to get the visual childer?
|
|
|
|
|
If you're getting 0 as a visual children count, this means you're probably looking in the wrong place. Try to get the count AFTER youc call InitializeComponent in your window.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
yes mr hanlon..
i m calling this method at the end of my constructor, in which the first step of my constructor is that initialize component
|
|
|
|
|
You are doing it too soon. As a test, add a button to your form, add a click event handler and add the call to TraverseVisualTree to the click handler.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
i m using one wpf window.. in that i have some number of canvas,..
i have to do some functions dynamically for all the canvas..
for that i have to take all the canvas together in loop..
for that in windows we will use like
foreach(Canvas cv in this.controls)
cv.visiblity = hidden..
like this we wil do..
but in WPF
i m unable to take the this.controls..
how to take that one???
|
|
|
|
|
If you have the name of the Canvas elements then you can do a FindName[^] using the the window object
else you would have to use VisualTreeHelper[^] [^]
|
|
|
|
|
The controls are laid out using a Visual Tree, so you walk the tree to find children. To do this, you use the VisualTreeHelper class to get the children. Something like this will do it:
internal static void TraverseVisualTree(object current)
{
DependencyObject ob = current as DependencyObject;
int counter = VisualTreeHelper.GetChildrenCount(ob);
for (int i = 0; i < counter; i++)
{
object depObj = VisualTreeHelper.GetChild(ob, i);
TraverseVisualTree(depObj);
}
}
} All you do then is call:
TraverseVisualTree(this);
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
yes mr, hanlon..
but u have given the object current as paramater...
that is it expects an object as parameter..
what is that object ?? what i have to send there
|
|
|
|
|
I already answered that, when I told you how to call it. You can use the this parameter in your Window/UserControl class.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
sorry..
i as it was seperated i dont read that one
|
|
|
|
|
Mr hanlon..
DependencyObject ob = current as DependencyObject;
int counter = VisualTreeHelper.GetChildrenCount(ob);
in this i m getting the counter as 0.. but i have more number childrens in the window
|
|
|
|
|
Hi i create my own Grid using ListView Control in WPF
There are couple of think in which i am facing problem.
1. In Column i use a Toggle button which is used to select the listViewItem. but when i press the Toggle button click event occur at that time how i can get the object of listViewItem. Note i use the GetFocus event for the ListViewItem but it fire at first time when i click the button. i just want that when button isChecked the the listViewItem Opacity should 1.0 and if not Checked then it should 0.4.
2. When i select any listView item the selection colour is Blue how can i chage that color.
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
|
hello this is my first animation practice in WPF
so I considered it a very big achievment !!
but I want to animate the item like carasoul panel (control of Infaragistics) :
- how can I animate the buttons that contain advertisement image and when the user
hover on button the all buttons stop not only the button
- how can I make the same animation for all buttons but not in the same time
this is my Powerfull user control code :
<UserControl x:Class="AdvertisementsPanel.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Loaded="UserControl_Loaded">
<UserControl.Resources>
<Style x:Key="AdvertisementItem" TargetType="{x:Type Button}">
<Setter Property="MaxHeight" Value="75" />
<Setter Property="MinHeight" Value="75" />
<Setter Property="MaxWidth" Value="110" />
<Setter Property="MinWidth" Value="110" />
<Setter Property="Opacity" Value=".5" />
<Style.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetProperty="MaxHeight"
To="90" />
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetProperty="MaxWidth"
To="140" />
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetProperty="Opacity"
To="1.0" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Mouse.MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:1"
Storyboard.TargetProperty="MaxHeight" />
<DoubleAnimation
Duration="0:0:1"
Storyboard.TargetProperty="MaxWidth" />
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetProperty="Opacity" />
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="Loaded" >
<BeginStoryboard Name="MyBeginStoryBoard" >
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(Canvas.Top)"
To="250" Duration="0:0:7" RepeatBehavior="Forever"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseMove">
<PauseStoryboard BeginStoryboardName="MyBeginStoryBoard" />
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<ResumeStoryboard BeginStoryboardName="MyBeginStoryBoard" />
</EventTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Grid>
<Canvas ClipToBounds="True" Name="maincanvas" >
<Button Canvas.Left="10" Canvas.Top="10" Style="{StaticResource AdvertisementItem}" Height="110" Width="130" Name="button1" >Advertisement</Button>
</Canvas>
</Grid>
</UserControl>
thanks a lot
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
Feras Mazen Taleb wrote: how can I make the same animation for all buttons but not in the same time
I don't understand this statement.
Take a look at this list of crazy WPF layout panels.[^].
|
|
|
|
|
ABitSmart wrote: Take a look at this list of crazy WPF layout panels.
thanks for that
I will try to clear my idea
I need to make a vertical list of photos that animate from up to down this is my simple idea
in the previous xaml code you will notice that I put one button that animate from up to down repeatedly
I want to put many photos but each photo has its own start and end point
and when the photo reach the down I want to push it in the first (ie return it to the top)
I hope that i cleared my idea
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
I'm waiting my friend I just need the starting point
to know how to build this control
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
this is the last thing I Achieved :
I added the animation to the buttons programmatically
this is the code behind file :
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;
using System.Windows.Media.Animation;
namespace practiceOnAnimationClasses
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
DoubleAnimationUsingPath Animation1 = new DoubleAnimationUsingPath();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<Button> buttons = new List<Button>(5);
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 1" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 2" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 3" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 4" });
buttons.Add(new Button() { Width = 120d, Height = 75d, Content = "Advertisement 5" });
int count = 0;
foreach (var item in buttons)
{
MainCanvas.Children.Add(item);
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 75 + (count * item.Width);
myDoubleAnimation.To = 800;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(15));
myDoubleAnimation.AutoReverse = false;
myDoubleAnimation.RepeatBehavior = RepeatBehavior.Forever;
item.BeginAnimation(Canvas.LeftProperty, myDoubleAnimation);
count++;
}
}
}
}
Xaml File it only contains the mainCanvas that I will Add
Buttons to It
the movement is very creasy and wrong How Can I make the movement
like photo gallery
<Window x:Class="practiceOnAnimationClasses.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="563" Loaded="Window_Loaded">
<Window.Resources>
<!--<Storyboard x:Key="StoryboardPath">
<DoubleAnimationUsingPath BeginTime="00:00:00" Duration="00:00:02" Storyboard.TargetName="button" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Source="X">
<DoubleAnimationUsingPath.PathGeometry>
<PathGeometry Figures="M-3,2 L363,2 L363,83 L-3,83 z"/>
</DoubleAnimationUsingPath.PathGeometry>
</DoubleAnimationUsingPath>
<DoubleAnimationUsingPath BeginTime="00:00:00" Duration="00:00:02" Storyboard.TargetName="button" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Source="Y">
<DoubleAnimationUsingPath.PathGeometry>
<PathGeometry Figures="M-3,2 L363,2 L363,83 L-3,83 z"/>
</DoubleAnimationUsingPath.PathGeometry>
</DoubleAnimationUsingPath>
</Storyboard>-->
</Window.Resources>
<Canvas Name="MainCanvas"></Canvas>
</Window>
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
I would create a bool property called IsSelected, and use a datatrigger to fire the animation when IsSelected is true - then all you need do is loop round in your code setting this value when you need it.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
could you explain more !
I will try to explain what I understood
I will make A dependency property IsSelected in My UserControl
THis Property will e true when Any of the buttons are hovered on mouse
All animations will paused when the property is True
is this right ? ??? ?? ?
second could you see my third replay that I inserted my code
that i try to make the movement programmatically
thanks a lot MR.O'Hanlon
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
hello this what achieved until now
1- I decided to make the animation programmatically
because I thing even if I used blend to design the animation
I need to control it programmatically because I will set the same
animation to many controls but with deffirent start and end point
2- I will use [DoubleAnimationUsingPath] class to design the animation path
3- Now I'm trying to look for answers for these two questions
- How can I make the animation continuos
of course (Forever) But What I mean Exactly is :
when the control reaches the end point it will return to the start
- How can I pause the the animation Programmatically
thanks a lot for every one sharing me with his/her ideas
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
thanks a lot I got it
Now ,
I have gallery control that can display images or videos
the animation starts from the left to the right Forever
Paused when mouseover any item and resume when mouseLeave the Item
I hope to have enough time to make my first article in CodeProject
about my control
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|