|
Prajeesh wrote:
What is Image.Thumbnail ?
Do you think the information you have provided is sufficient for someone to understand your issue ?
|
|
|
|
|
I'm a bit confused as to what you want to do here. Do you expect this to show
a thumbnail of all of the images
multiple thumbnails - one per image
multiple thumbnails - one image
If you expect multiple thumbnails, then you need to wrap this up into a ListBox (or similar).
|
|
|
|
|
In some PC games, such as Civilization, the world map appear as a whole undeveloped territory with black mask. Along with your movement, the world map reveal itself gradually.
Now I'm trying to make the same effect using wpf. To predigest the question I use a Canvas(Background = Black) instead of the world map, a Small Rectangle with a storyboard to move itself along Canvas.LeftProperty and Canvas.TopProerty. How could I make the Canvas reveal itself along the track of the rectangle???
|
|
|
|
|
The Clip and OpacityMask properties allow you to mask areas. The OpacityMask is the most powerful you could set it to a VisualBrush which animates.
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Background = Brushes.Black;
var content = new Canvas() { Background = Brushes.Orange };
var mask = new Canvas() { Width = 300, Height = 300,Background = Brushes.Transparent};
var rectangle = new Rectangle() { Width = 0, Height = 300, Fill = Brushes.White };
mask.Children.Add(rectangle);
var brush = new VisualBrush(mask) { AutoLayoutContent = true };
var anim = new DoubleAnimation(300, TimeSpan.FromSeconds(3));
rectangle.BeginAnimation(Rectangle.WidthProperty, anim);
content.OpacityMask = brush;
Content = content;
}
}
|
|
|
|
|
Hello everyone,
I created a DragCanvas (based on DraggingElementsInCanvas[^]) and I use to display ObservableCollection of items (like this msdn forums[^]).
However I have two ObservableCollection's which I want to display:
- collection of network nodes
- collection of connections/links between this nodes (each connection has DataBinding to two Nodes{.Left,.Top})
It is possible to have two ItemSources for such a control? What would be the best solution to display these two collections?
Thanks in advance.
|
|
|
|
|
For me, the links are also nodes of a certain type. If you have them all in one collection then, you can use the DataTemplateSelector. Take a look here[^] and here[^] and see if I make sense.
|
|
|
|
|
Thanks for your answer. The DataTemplateSelector is great. However in my data model, the links and nodes are seperated in two ObservableCollections because later on I want to filter them using ICollectionView. The user can choose that for example only blue nodes and red links should be displayed. Perhaps this can be also solved using DataTemplateSelector as you recommended but I have some difficulties to put it all together. Can you give me another hint where to look? Thank you.
|
|
|
|
|
You could still use the ICollectionView on the observable collection. MSDN and the link I gave you had good samples, you can google out for more.
|
|
|
|
|
How can i dynamically add images in wpf ? i suppose it should be simple , but i just can't find the answer..
Thank you !
|
|
|
|
|
Image myImage = new Image();
myImage.Width = 200;
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg");
myBitmapImage.DecodePixelWidth = 200;
myBitmapImage.EndInit();
myImage.Source = myBitmapImage;
From here[^]
You would then add myImage to the container where you want to show it.
|
|
|
|
|
Hello,
I am trying to trap the click event for a button that is in the resourcedictionary,
I get a error
WpfApplication1.MyResourceDictionary' does not contain a definition for 'GetTemplateChild' and no extension method 'GetTemplateChild' accepting a first argument of type 'WpfApplication1.MyResourceDictionary' could be found (are you missing a using directive or an assembly reference?)
MyResourceDictionay.xaml.cs looks like this
namespace WindowsApplication1
{
partial class MyResourceDictionary
{
public virtual void OnApplyTemplate()
{
Button myButton = this.GetTemplateChild("Crap") as Button;
}
}
}
MyResourceDictionay.xaml looks like this
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="MyResourceDictionary"
x:ClassModifier="public">
<ControlTemplate x:Key="ExpandablePropertyEditorTemplate">
<Button x:Name="Crap" Foreground="White" Background="White">
<Image Source="Controls\check.png"/>
</Button>
</ControlTemplate>
</ResourceDictionary>
Any help?
|
|
|
|
|
|
Hello,
it is possible to make something like a MDI-Application in WPF? Or run a process and get the WPF-Controls of the main window in a control?
I want to make a "plug-in-based" application, and it shouldn't everytime show a new window, i want to have them in my main-application. How is something to do?
|
|
|
|
|
You could have each one open in a new tab. While it is possible to write MDI in WPF, it's a nasty hack because WPF wasn't designed this way.
|
|
|
|
|
Yes in a tab is ok, but how can i do this?
|
|
|
|
|
You'd create these "applications" as plug-ins that your application would use. Have a look at the Managed Extensibility Framework to get some ideas.
|
|
|
|
|
Good People,
I have an object that will hold data and bind to some controls. Sometimes it will just need to exist as one object, other times it will need to exist in a collection. In your opinion, what strategy should/can I use:
1) implement INotifyPropertyChanged on the object, and when needed, place it in the observable collection.
2) simply implement the object normally - without INotifyPropertyChanged - and then place it in the observable collection which will update any properties
By the way, is it possible to use INotifyPropertyChanged and place such objects in an ObservableCollection?
Thank's so much for any help or information you can provide.
Blitz
|
|
|
|
|
Use strategy 1. The ObservableCollection tells you when the collection has changed not when a property of an object inside it has changed.
|
|
|
|
|
Awesome! Thanks Pete. Appreciate you sharing your insight.
|
|
|
|
|
No problem mate. Always glad to help.
|
|
|
|
|
I want to set the default styling in some controls and want to set all properties in generic.xaml.
I am looking at folowing link
http://www.codeproject.com/KB/silverlight/mediabutton.aspx[^]
but if change some property for example
<Setter property="Cursor" Value="Arrow" />
to
<Setter property="Cursor" Value="Hand" />
Its not getting reflected when I run the application.
No idea why? Does anybody have any idea? I have done a lot of brainstorming but not able to find........
Thanks in advance,
|
|
|
|
|
In the constructor for the control(s), try adding
DefaultStyleKey = typeof(MyCustomControlClass);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have done that also but not able to achieve to get the default value....
|
|
|
|
|
What does the style look like? Can you show the code?
It can't have a Name/Key and it needs to have the correct TargetType.
The Build Action property for the generic.xaml file should be set to resource.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My CS file is like this:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace MyCustomControls
{
public class MyControl: ContentControl
{
public string Content1
{
get { return (string)GetValue(ContentProperty1); }
set { SetValue(ContentProperty1, value); }
}
public static readonly DependencyProperty ContentProperty1 =
DependencyProperty.RegisterAttached("Content", typeof(string), typeof(MyControl),
new PropertyMetadata("a"));
public MyControl()
{
this.DefaultStyleKey = typeof(MyControl);
}
}
}
Generic.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyCustomControls;assembly=MyCustomControls">
<Style TargetType="local:MyControl">
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Content" Value="The Code Project"/>
</ResourceDictionary>
and the xaml file of the user control where I want to use the above custom control
<UserControl x:Class="MyPortal.Controls.ctrlLogin"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="140"
xmlns:local="clr-namespace:MyCustomControls;assembly=MyCustomControls">
<Grid x:Name="LayoutRoot" Width="400" Height="500" Background="Gray" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="480"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400" />
</Grid.ColumnDefinitions>
<local:MyControl Grid.Column="0" Grid.Row="0"/>
</Grid>
</UserControl>
None of the default property which is there in the generic.xaml file is reflected in the custom control.
If we put this property in the xaml file of user control itself then it works fine. But our requirement is to put the default value having styles or the content in generic.xaml
|
|
|
|