|
Hi, guys!
I'm having a bit of a trouble with my columns' headers in WPF Datagrid. Some of them are too long, and horizontal stratching is not an option: there are too many of columns, and user will not be able to see full text in headers.
Here is what I'd like to do
I want header "Word1 word2 word3 word4 word5 word6"
to look like
"Word1 word2 word3
word4 word5 word6" - so it srteches vertically.
Thanks in advance
|
|
|
|
|
I haven't tried it, but I should imagine that all you need to do is set a style with a TargetType of tk:DataGridColumnHeader , and set the TextWrapping in there.
"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
|
|
|
|
|
Hi ,
In WPF, am trying to create ListView, Which binds with list of class KPI objects. Where the KPI class contains Name(string), StackPanel(which contains TextBlock + Image).
I want to show only the StackPanel into the list , not the Name property. How do we bind the stack panel object alone .
<listview name="lvKPI" grid.row="1" margin="5,5,5,78"
="" selectionmode="Single" itemssource="{Binding KPICollection}" itemcontainerstyle="{StaticResource alternatingListViewItemStyle}" alternationcount="2">
<listview.view>
<gridview.columns>
|
|
|
|
|
you need to define the stackpanel in a column template.
|
|
|
|
|
Hi,
thanks. Can u pl help me here giving me example for this ?
thanks
|
|
|
|
|
|
I figured out how to see if an object within a container is a specific object, but how to translate it to another container? The following doesn' t work.
foreach (UIElement el in LayoutRoot.Children)
{
if (el is Button)
{
LayoutRoot.Children.Remove(el);
StackPanel1.Children.Add(el);
}
}
|
|
|
|
|
As per my understadning, it is containing reference of button so it may be the cause.
Try with following DeepCopy approach:
foreach (UIElement el in LayoutRoot.Children)
{
if (el is Button)
{
string shapestring = XamlWriter.Save(el);
StringReader stringReader = new StringReader(shapestring);
XmlTextReader xmlTextReader = new XmlTextReader(stringReader);
UIElement DeepCopyobject = (UIElement)XamlReader.Load(xmlTextReader);
StackPanel1.Children.Add(DeepCopyobject);
LayoutRoot.Children.Remove(el);
}
}
If it is not working or if you have any other approach then please let me know.
Thanks,
Parwej Ahamad
ahamad.parwej@gmail.com
|
|
|
|
|
If you run that code in debug mode you WILL experience an exception.
You cannot remove an item from a collection that is being enumerated. So what I do in that case is this:
List<int> itemsToRemove = new List<int>();
for ( int index = 0; index<LayoutRood.Children.Count; index++ )
{
if ( LayoutRoot.Children[index] is Button )
itemsToRemove.Add(index);
}
foreach ( int element in itemsToRemove )
{
Button oldElement = LayoutRoot.Children[element] as Button;
LayoutRood.Children.RemoveAt(element);
StackPanel1.Children.Add(oldElement);
}
Take this one warning into account: you MIGHT get an exception that the element is already a member of another collection. The exception will point at your StackPanel1 add to the elements. If that happens then do the following:
Button newElement = new Button;
newElement.Name = oldElement.Name;
.
.
.
|
|
|
|
|
Hi,
I'm following a Data Binding example from: microsoft[^] which displays the expected result in the VS2008 design window on XP but not when I run it. The XML looks OK to me with the XMLDataProver in a Resource :
<XmlDataProvider x:Key="MoreColors" XPath="/colors">
and the ListBox attribute :
ItemsSource="{Binding Source={StaticResource MoreColors}, XPath=color/@name}">
, any ideas why it displays data in the ListBox in design mode in VS2008 but doesn't display any data in the ListBox when its run?
<Window x:Class="WpfText2LableBinding.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<StackPanel>
<StackPanel.Resources>
<XmlDataProvider x:Key="MoreColors" XPath="/colors">
<x:XData>
<colors >
<color name="pink"/>
<color name="white"/>
<color name="black"/>
<color name="cyan"/>
<color name="gray"/>
<color name="magenta"/>
</colors>
</x:XData>
</XmlDataProvider>
</StackPanel.Resources>
<TextBlock Width="248" Height="24" Text="Colors:" TextWrapping="Wrap"/>
<ListBox x:Name="lbColor" Width="248" Height="56" IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding Source={StaticResource MoreColors}, XPath=color/@name}">
</ListBox>
</StackPanel>
</Window>
|
|
|
|
|
I answered this here[^]. Add the namespace I mention in the answer and you are good to go.
"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
|
|
|
|
|
Thanks, you identified the cause though I think your linked solution is wrong (in this case anyway). It's now working but I had to use:
<br />
<x:XData><br />
<colors xmlns=""><br />
rather then the
<br />
<x:XData xmlns=""><br />
<colors ><br />
in your link. I found another MS example which uses xmlns in this manner:
<StackPanel.Resources>
<XmlDataProvider x:Key="InventoryData" XPath="Inventory/Books">
<x:XData>
<Inventory xmlns="">
<Books>
<Book ISBN="0-7356-0562-9" Stock="in" Number="9">
<Title>XML in Action</Title>
<Summary>XML Web Technology</Summary>
</Book>
|
|
|
|
|
Hey Guys,
I am drawing custom user controls onto a Canvas using a placement algorithm, the problem is that when the placement algorithm runs the controls Height has not yet been calculated and is 0 causing other object around it to be placed invalidly, how can I get it so that the height is set before I run my placement algorithm?
Cheers,
Ian
|
|
|
|
|
Hi Ian,
You can set a fixed height and width to your UserControl and then you will have the ActualHeight property set to it before drawing it to the screen.
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
Do you mean that I set the User Controls .Width and .Height properties?
|
|
|
|
|
Yes, you have to set the height & width of the UserControl in the XAML itself, else it will set after rendering.
Have a look into the following code snippet for setting the dimension of the control:
<UserControl ...
...
Height="200" Width="400">
</UserControl>
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
But the control is created programmatically in code.
|
|
|
|
|
If you created it programmatically, then use the following way to set the height & width of the usercontrol:
MyUserControl uc = new MyUserControl();
uc.Height = 200.0;
uc.Width = 400.0;
...
...
...
LayoutRoot.Children.Add(uc);
Let me know, if you have any queries.
Don't forget to Click on [Vote] and [Good Answer] on the posts that helped you.
Regards - Kunal Chowdhury | Software Developer | Chennai | India | My Blog | My Tweets | Silverlight Tutorial
|
|
|
|
|
I've developed several WPF controls and themes, and would like to showcase them. I've created another WPF application which contains them all, which works fine. Now, I want to put those controls onto web. Is it possible without re-writing the whole code for Silverlight? I've few problems due to Silverlight restrictions. I am using 3.5 framework.
Also, can we edit/create a Silverlight project in Visual C# 2008 express edition?
modified on Friday, July 23, 2010 5:13 AM
|
|
|
|
|
WPF != Silverlight ... ish!
You need Web Developer Express to do Silverlight ...
|
|
|
|
|
You can create a WPF Bowser application an XBAP
http://www.xbap.org/tutorial.html
Every one among us was a beginner once
|
|
|
|
|
That's not, actually, a good suggestion - while you can create a WPF browser app, it's not going to run on certain browsers, and not on a Mac or Linux box. This limits the target audience who can view what he's done.
"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
|
|
|
|
|
Hi,
Looking for a bit of help. I have two listboxes and a calender control.
One listbox contains different years (2010,2011,2012 etc) and my other listbox contains the months of the year. What I'm trying to do is bind what is selected in the listboxes and then display the correct month and year. I have the binding setup for one direction.
My calender xaml looks as follows
<calender>
<calender.displaydate>
<multibinding converter="{StaticResource myConverter}">
<binding elementname="lstYears" path="SelectedItem">
<binding elementname="lstMonths Path=" selecteditem"="">
My converter class is as follows
Public Class ListBoxToDateConverter
Implements IMultiValueConverter
Public Function Convert(ByVal values() ....etc
Dim year As ListBoxItem = CType(values(0), ListBoxItem)
Dim month As ListBoxItem = Ctype(values(1), ListBoxItem)
' Create my date object from the data and return it ....
.
.
.
return date
End Function
Anyways I dont know how to do the ConvertBack() function. Kinda lost as what to do. Any help would be appreciated
|
|
|
|
|
I have a xaml file, which has a codeline, something like.
xmlns:a="http://schemas.someadress.com/bla/bla/bla" - the name is defined in an assembly which contains that desired namespace.
Above mentioned namespace contains a class, that I'd like to use in my xaml. But I cannot build the project with this file, bc Visual Studio throws me an error
"The tag '<my class="" name="">' doesn't exist in a namespace "http://schemas.someadress.com/bla/bla/bla" Line A Position B"
Interesting enough, that the intellisence can see that class in "a:" - when I start typing it pops up the class that I need. Adress "http://schemas.someadress.com/bla/bla/bla" is correct - I've copypasted it from an assemblyinfo. Besides, other xaml files in a project can perfectly use that specific class from that assembly.
Note, that this question comes from a WPF noobie, and can sound dumb. Still, I've spent more than an hour and ran out of ideas.
Any help will be greatly appreciated.
Thanks in advance
------------
UPDATE: I got this one figured. The problem was that the project's compilation settings were set for .NET Framework 4.0 Client Profile. Once I switched to a regular 4.0, everything got fixed
modified on Friday, July 23, 2010 9:12 AM
|
|
|
|
|
<br />
BitmapImage imageSource = new BitmapImage();<br />
Stream stream = fu.File.OpenRead();<br />
BinaryReader binaryReader = new BinaryReader(stream);<br />
byte[] currentImageInBytes = binaryReader.ReadBytes((int)stream.Length);<br />
stream.Position = 0;<br />
imageSource.SetSource(stream);<br />
imagePreview.Source = imageSource;<br />
<br />
catastrophic failure error occoured,Plz help
HI after a lot of RND i got something like imagetool on codeplex did anyone has some idea how to use the same.
HI All its done, my problem is been resolved now, I used imagetool classes to convert gif and bmp files, but still looking for TIFF decoder, did any one have teh solution for the same????
Thanks
modified on Friday, July 23, 2010 12:13 AM
|
|
|
|