|
Hi Experts,
I am unable to locate a property similar to WindowsForm "DropDownWidth" Property for the Combo Box in WPF. Is there a work around to achieve this functionality?
Please help!
Thanks in advance.
Regards,
Samar
P.S.: Just FYI for those who are not aware, "DropDownWidth" Property changes the width of the drop down area. The area when the Combo Box is clicked to show its master contents.
modified on Friday, July 30, 2010 2:40 AM
|
|
|
|
|
Dear friends,
I am new to WPF and I have to design pages, and I do not know how to design pages that fits for many screen size
Is it possible to design screen that fits in all the screen size? Then how?
If not all the screen size I need to fix it for 4/3 screen resolution like
800 600
1024 768
1280 960
1600 1200
1792 1344
Any idea? Link?
Thanks
|
|
|
|
|
The layout system in UI is designed to be resolution independent. Rather than positioning things absolutely, you can lay things out in any one of a number of panels (such as a Grid), and use margins and padding to achieve whatever effects you want.
"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 for reply,
My problem like these ..
i have button and i specified size for the button in One screen size... when i change to other screen size ..the button size same
i tried to by removing button size and just to specify the margin ...if i set margin the (then the margin space remains same)
i do not know what to do?
thanks
|
|
|
|
|
I have a list of data item objects (ObservableCollection<MyDataItem> ) bound to a line series, and I need to change the symbol's visibility based on the value of a boolean property (ShowSymbol )in a given data item object. In other words, for a given LineSeries, each datapoint could potentially be represented by a different/unique symbol.
I've written a converter (VisConverter ) that is supposed to set the visibility of the symbol based on the value of the ShowSymbol property, and I've added the converter to the UserControl.Resources, but I'm not sure how I specify the property in the xaml.
Can anyone help?
SOLUTION ===================
Visibility="{Binding ShowSymbol, Converter={StaticResource VisConverter}}"
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
modified on Wednesday, July 28, 2010 3:54 PM
|
|
|
|
|
I have a collection of classes together that are formed together like tree. The whole collection is bound to a TreeView. One of the classes has a bool property called IsChanged:
public class ReportColumn
{
public string ColumnName { get; set; }
public object OriginalValue { get; set; }
public object ChangedValue { get; set; }
public bool IsChanged { get; set; }
}
In my XAML I created a DataTemplate for it:
<DataTemplate DataType="{x:Type local:ReportColumn}">
<StackPanel Orientation="Horizontal">
<!-- Column Name -->
<TextBlock Margin="0,0,5,0"
FontWeight="Bold">Name:</TextBlock>
<TextBlock Text="{Binding Path=ColumnName}"></TextBlock>
<!-- Original Value -->
<TextBlock Margin="20,0,5,0"
FontWeight="Bold">Original:</TextBlock>
<TextBlock Text="{Binding Path=OriginalValue}"></TextBlock>
<!-- Changed Value -->
<TextBlock Margin="20,0,5,0"
FontWeight="Bold">Change:</TextBlock>
<TextBlock Text="{Binding Path=ChangedValue}"></TextBlock>
</StackPanel>
</DataTemplate>
Then the whole thing is bound to the treeview. What I'd like is to make this node's foreground red when IsChanged is true. Can someone explain how to do this?
Everything makes sense in someone's mind
|
|
|
|
|
I'm almost bald from pulling my hair out over this bug.
I have a WPF window which as a section defined as follows:
<StackPanel Name="stackPaneln" Orientation="Horizontal" Margin="-1,29,0,54">
<DockPanel Name="navigation" >
<StackPanel Name="stackPanel1" Width="162" HorizontalAlignment="Left" Height="486">
<Button Height="103" Name="configurationViewerRequest" Width="120" Margin="0,5" Click="configurationViewerRequest_Click">
<StackPanel Orientation="Vertical">
<Image Source="Configuration_icon_by_obsilion.png" Height="73" />
<TextBlock Text="Configuration" TextAlignment="Center" Margin="0,5,0,0" />
</StackPanel>
</Button>
<Button Height="100" Name="systemStatus" Width="120" Margin="0,5" Click="systemStatus_Click">
<StackPanel Orientation="Vertical">
<Image Source="SystemMonitor.png" Height="73" />
<TextBlock Text="System Status" TextAlignment="Center" Margin="0,5,0,0" />
</StackPanel>
</Button>
<Button Height="103" Name="systemMonitor" Width="120" Margin="0,5" Click="systemMonitor_Click">
<StackPanel Orientation="Vertical">
<Image Source="ViewInfo.png" Height="73" />
<TextBlock Text="System Monitor" TextAlignment="Center" Margin="0,5,0,0" />
</StackPanel>
</Button>
</StackPanel>
</DockPanel>
<DockPanel Name="destination" Margin="10,0,0,0" Width="608">
</DockPanel>
</StackPanel>
The problem:
When one of the buttons in the Navigation panel is clicked, the user control that provides the functionality is loaded into the 'destination' dock panel. So I have a user control which has a treeview and an editor window. In the editor window I put a label with content = '<----the navigation of over there'
When the configuration button is clicked I create an instance of the editor, and do destination.Children.Add(controlEditor);
Problem: the control is shifted all the way to the right of the window (aligned with x=0 of the Window!!! instead of the DockPanel!!!!
Here is the xaml of the control I'm loading in case I screwed up there....
<UserControl x:Class="SnmpBrowser.ConfigurationManager"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" xmlns:ig="http://schemas.infragistics.com/xaml" d:DesignHeight="612" d:DesignWidth="800">
<Grid>
<DockPanel VerticalAlignment="Top" Height="536" Margin="12,12,640,64" >
<TreeView >
<TreeView.ContextMenu x:Uid="addItemContext">
<ContextMenu Name="context" Opened= "context_Opened" >
<MenuItem Name="header" Header="populated programmatically" >
<MenuItem Name="newItem" Header="Add New " Click="newItem_Click" />
<MenuItem Name="edit" Header="Edit....">
</MenuItem>
</MenuItem>
</ContextMenu>
</TreeView.ContextMenu>
<TreeViewItem Header="Agent" MouseRightButtonDown="ContextMenuHandler" Uid="agent" MouseEnter="SetSelected" />
<TreeViewItem Header="Devices" MouseRightButtonDown="ContextMenuHandler" Uid="device" MouseEnter="SetSelected" />
<TreeViewItem Header="Mother" IsSelected="True" MouseRightButtonDown="ContextMenuHandler" Uid="mother" MouseEnter="SetSelected"></TreeViewItem>
<TreeViewItem Header="System" MouseRightButtonDown="ContextMenuHandler" Uid="system" MouseEnter="SetSelected" />
</TreeView>
</DockPanel>
<DockPanel Margin="0,12,12,0" Name="destination" VerticalAlignment="Top" Height="536" HorizontalAlignment="Right" Width="622">
<Label Content="<-------- the menu is over there!" Height="28" Name="label1" />
</DockPanel>
<ListBox Height="Auto" HorizontalAlignment="Stretch" Margin="12,552,0,0" Name="messages" VerticalAlignment="Stretch" Width="Auto" />
</Grid>
</UserControl>
|
|
|
|
|
After doing a few more tests it turns out that the work area was 600x400 but the user control was 600x800.
After resizing the user control to the area of the dock panel, everything displays properly.
|
|
|
|
|
Hey All,
Hope we're well. I'm just trying to bind the IsEnabled property of a button to an IsValid property on my IWizardPage. Can I work it out?
The IWizardPage is implemented on a UserControl that is hosted in a ContentControl on the same control as the button. I've tried various thing including AncestorType things ... I'm trying this at the moment with no luck:
IsEnabled="{Binding ElementName=WizardHost, Path=Content.IsValid, Converter={StaticResource textBoolConverter}}"
The converter is there just for a breakpoint opportunity at the moment ...
|
|
|
|
|
Try something like this..
IsEnabled="{Binding Content.IsValid, ElementName=WizardHost, Converter={StaticResource textBoolConverter}}"
|
|
|
|
|
I rather suspect that you don't need a converter in there mate - both of them should be boolean values.
"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 4 images of same object.
I want to write small WPF application that show that object in 3D - using the those images.
How can i do it ?
I don't find any example that teach how to do it
Thanks for any help
|
|
|
|
|
See here. Maybe this[^] can help.
|
|
|
|
|
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>
|
|
|
|