|
Eslam,
Glad to help out. Have a great day!
modified 27-Feb-21 21:01pm.
|
|
|
|
|
|
I have a custom control which dynamically add texboxes...This control is inherited from StackPanel....
Now I have a collection of textboxes which will dynamically added to the StackPanel.
I want to add a message control below each text box and manually hide and show that...which will have hanging kind of look...
My question is that, how can I add the message control dynamically below each textbox control?
I think I am trying to get the X, Y coordinates of the textbox on mousemove event and trying to place the message control but not able to get any result...
Can anybody help me?
Thanks in advance,
|
|
|
|
|
Not tried it yet, but I think if you just add controls to a stack panel that has its orientation set of vertical, they get added in first-in order. This should just keep putting then one under the next.
As far as I know the insert method of the stack panels children collection allows for an index number to be given though, so you could do it that way also I guess.
|
|
|
|
|
salon wrote: Now I have a collection of textboxes which will dynamically added to the StackPanel.
An alternative to doing all this manually from code would be to
use a collection of a data type that has the required properties
for each item. Then using an ItemsControl (or derived) you can use a data
template for the items, so each time you add an item to the collection, all
the UI elements for the item will be magically created using the template.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I have Inkcanvas on which i am trying to place images. now i m trying to rotate the image from the centre intead of top left position so after creating the image i have passed 0.5 value to the image property. the transformation does not happen... i have tried passing imagewidth/2 and imagehieght/2 but both fails..
Can any one suggest me a way to solve this... i have alse made the canvas width and height to constant values.
Thanking in advance
Samir
|
|
|
|
|
Hi there, excuse my bad english
I wrote a Style on my dictionary that change the border's borderbrush (to pink). I ran the program and everything look great. (I'm running Vista).
Well, I send it to my girlfriend and she has XP. In XP the program show double borders everywhere, tabs names with double pink border, the border with another border (¿Usercontrol border?)...
I remember the lesson about Visual trees, and I think that these items have and implicit border and the style applies to they too.
The question is, why I saw the changes only in the borders that I explicit put and not the others?
I hope you can understand me.
Long live to codeproject 
|
|
|
|
|
You have to force the app to use the vista aero theme.
<application x:class="WPFApplication1.App" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="WindowMain.xaml">
<application.resources>
<resourcedictionary source="/PresentationFramework.Aero;V3.0.0.0;31bf3856ad364e35;component/themes/aero.normalcolor.xaml" />
</application.resources>
</application>
Don't forget to add a reference to PresentationFrameworkAero . When you do this, even XP will show Aero-style control appearance.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
You have learned well young Padawan. The force is strong in this one.
"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 used the Google Force to find the answer for myself.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks you very much.
It's work perfectly and I have not to worry with this weird behavior in XP thanks to this little black magic :P
Thanks you again. 
|
|
|
|
|
WPF is only half finished. When VS2010 is released, we'll get a little more of it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The Codeplex WPF site[^] is a good place to get your hands on controls
before they are rolled into the framework.
The WPF Toolkit has had a date/calendar control for a while - not sure
about a time picker...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
So all of those were fixed? If not, how many apply to your potential
usage of the control?
I've personally used the control, including in data grids, with no
issues. As with everything else in Windows, your results may vary.
Have you googled for other controls? There's tons of companies providing
WPF components - many with their own issues
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That is the list of fixes.
As it's always been with Windows programming - if there isn't a
system-provided control that suits your needs, you write your own.
At least WPF makes it easier than ever.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello.
I have several hundred buttons that need the same animation applied on mouse enter, in AS3 I'd do this with a tween and apply that tween using e.currentTarget, probably inside a for loop. Is there a way to do this in WPF, have a storyboard for no specific object be applied to an array of items?
Regards.
E.
|
|
|
|
|
This is trivial in WPF. All you need do is declare a storyboard inside a trigger that applys to the button type. Here's a simple example:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.20" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>
</Page.Resources>
<StackPanel>
<Button Content="Hello" />
<Button Content="Hello 2" />
</StackPanel>
</Page>
"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
|
|
|
|
|
Hello.
Thank you for that, it makes sense. Can that method be used for DoubleAnimationUsingKeyframes however, as the animations need to be more complex than I'd be happy to try and code so will create them in Blend on a proxy object. When attempting this I get:
[unknown]property does not point to a dependency object in path"(0).(1).[2].(2);"
|
|
|
|
|
Certainly. Here's this sample modified:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity">
<LinearDoubleKeyFrame Value="0.6" KeyTime="0:0:0.5" />
<DiscreteDoubleKeyFrame Value="0.2" KeyTime="0:0:1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="Opacity" To="1"/>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>
</Page.Resources>
<StackPanel>
<Button Content="Hello"/>
<Button Content="Hello 2"/>
</StackPanel>
</Page>
"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 have the following collection:
public class WorkTrayItem
{
public TabItem WindowAccountTab { get; set; }
public string WindowSource { get; set; }
public Window WindowObject { get; set; }
public Image WindowIcon { get; set; }
public int WindowType { get; set; }
public string WindowName { get; set; }
public WorkTrayItem(TabItem tab, Window window, string source, int windowType, Image icon)
{
WindowObject = window;
WindowSource = source;
WindowAccountTab = tab;
WindowType = windowType;
WindowIcon = icon;
switch (windowType)
{
case 0 : WindowName = "Service Order"; break;
case 1 : WindowName = "Trouble Ticket"; break;
}
}
}
public class WorkTrayItems : ObservableCollection<worktrayitem>
{
public WorkTrayItems()
{
this.Clear();
}
}
I'm trying to bind it to a list view:
<UserControl.Resources>
<controls:WorkTrayItems x:Key="WorkTrayData" />
<Style TargetType="{x:Type ListView}" BasedOn="{StaticResource {x:Type ListBox}}">
<Setter Property="ItemsSource" Value="{Binding Source={StaticResource WorkTrayData}}">
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Name="bd" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Margin="{TemplateBinding Margin}">
<ScrollViewer Margin="{TemplateBinding Padding}">
<WrapPanel ItemWidth="150" IsItemsHost="True" Name="wrapPanel1" MinWidth="100"
Width="{Binding ActualWidth,
RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=ScrollContentPresenter}}">
</WrapPanel>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType='{x:Type ListViewItem}' BasedOn='{StaticResource {x:Type ListBoxItem}}'>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel Orientation="Vertical">
<StackPanel.DataContext>
<Binding Source="{StaticResource WorkTrayData}" />
</StackPanel.DataContext>
<Image Margin="3" Source="{Binding WindowImage}"/>
<Label Height="21" HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
Content="{Binding WindowTitle}"/>
<Label Height="21" HorizontalContentAlignment="Center"
VerticalContentAlignment="Top"
Content="{Binding WindowSource}"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type controls:ImageView},ResourceId=ImageView}">
</Style>
<Style x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type controls:ImageView},ResourceId=ImageViewItem}">
</Style>
</UserControl.Resources>
<Grid>
<ListView Name="listViewWorkTray"
Margin="8,0,7,-116" BorderThickness="0" Background="Transparent"
SelectionMode="Single" FontFamily="Arial" Height="109"
VerticalAlignment="Bottom">
<ListView.View>
<controls:ImageView />
</ListView.View>
</ListView>
</Grid>
When a user opens a window, I add a WorkTrayItem object to the collection, but it doesn't show up in the ListView. What am I missing? Somehow, I feel like I need to tell the XAML what the variable name is of the list in the parent control (m_workTrayData), but how/where should I do that?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Friday, April 24, 2009 8:05 AM
|
|
|
|
|
So who voted my message a 1, and why? Was it too close to actual programming?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
If you're setting the binding context of the window, or the control, then you don't need to tell anything the variable name, it's already there in the binding context. I am surprised that you can create an observable collection with so little code, all the examples I have seen, use more. Does the base class provide the rest ? I assume it's not strongly typed then, strong typing is, I am pretty sure, what the extra code I've seen adds to the equation.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: I am surprised that you can create an observable collection with so little code, all the examples I have seen, use more.
I'm a minimalist by nature. Remember - I started programming when having 4K of RAM was considered "downtown".
Christian Graus wrote: If you're setting the binding context of the window, or the control, then you don't need to tell anything the variable name, it's already there in the binding context.
But how can it know if I don't tell it what data member to use?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
OK, then I guess this is the issue. You have to set the DataContext of the control or the page ( depending on the XAML, I believe ) to be that list. I am not sure, but I think if you set the data context of the page ( which can be done in the XAML ) then the control will 'inherit' it.
I've just checked my code, and I tend to do it in the code, not the XAML.
playlists.DataContext = Playlists.GetFilesNotIn(list);
sets the data context of a control to a list of objects. I use an observable collection elsewhere, but the code is the same.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: strong typing is, I am pretty sure, what the extra code I've seen adds to the equation
What advantage does that have over ObservableCollection<T> ?
This seems pretty simple to me:
public class MyItemCollection : ObservableCollection<Item>
{
}
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|