|
Hi,
I have created a WPF IpAddressTextBox that inherits from System.Windows.Controls.Textbox. I want to initialize the textbox with the string " . . . " when the application starts.
Everything works fine if I add the textbox to a testproject with the .xaml file with
<local:IpNumberTextbox Width="200" Margin="5"/>
But in the real project I add the textBox with
<controls:IpNumberTextbox Width="100" Text="{Binding SelectedItem.DNS1, ElementName = profilList }" />
In this project I have a Binding and when the dialogs shows up the textBox contains "" instead of
" . . . ". In the debugger I can see that the TextBox Text property contains
" . . . ", but the GUI is not updated. Why?
Regards
Marcus
|
|
|
|
|
I would like to accept what is dropped from a drag operation of a selection of paths from Windows Explorer into a ListBox. I would think this would be pretty simple to do, but I can't find any examples that show how to do it. In my Drop event in the ListBox I have this line:
object text = e.Data.GetData(DataFormats.Text);
text comes back as null. How would I get at the list of files and folders dragged from Windows Explorer?
|
|
|
|
|
Try DataFormats.FileDrop, which will yield a string array of file names.
|
|
|
|
|
Thanks. After making my original post, shortly thereafter I did one more Google search and found the answer, but was still curious whether anyone would answer me so didn't mention it.
I was specifically interested in getting an array of file folders, since I can already get an array of file names with the normal WPF file browser, but can't get an array of file folders with the Shell's Folder Browser. Drag and Drop (and probably copy and paste) are the only ways to do that.
|
|
|
|
|
We have a wpf app developed under windows XP SP2. When this app runs under Vista, the text gets clipped in many places - it is as though a different font is used which is slightly larger.
I have seen this with both Tahoma and Arial.
I could go through and add padding or miniumum height to solve the, but it seems as though that should not be necessary (and may lead to other problems).
Has anyone else experienced this? Can anyone provide some advice or pointers?
A sample style is as follows:
<Style x:Key="Heading3" TargetType="{x:Type TextBlock}">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="{DynamicResource textDimmedForegroundBrush}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="FontFamily" Value="Arial"/>
</Style>
Thanks for any help,
Tim
|
|
|
|
|
I've had this happen, it's a real PITA. i suspect you can get around it by making sure you set the font size explicitly, but even then, I think the best thing to do is to make sure you test on both and that you provide space for both.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello
I am having difficulty finding an article / tutorial on how to create a custom control that derives from System.Windows.Controls.Control class using a ControlTemplate to display visuals.
I find most of my search queries just return results for UserControl or deriving from another class (TextBox etc).
Could someone please provide me a link if they know of one.
Thank you.
-Mike
|
|
|
|
|
This[^] may go some way towards what you are looking for. I would also suggest any other articles by the author, Sacha Barber, or alternatively, Josh Smith. Further, both these legends provide links to other authors who they recommend, which is in itself the best recommendation you are likely to see.
|
|
|
|
|
Thanks Richard, but not quite what I am looking for.
The control I am currently working on originated as a derived class of System.Windows.Controls.Panel. I got this to a point where I was happy with measure and arrange overrides of child objects. I wanted this container/panel to have a visual style to be applied to it, as well as the option to create alternate control templates. I changed the derived class from System.Windows.Controls.Panel to System.Windows.Controls.Control . At this point I lost the rendering of my control.
I am looking for some information on how to get the rendering of this object back, also how to set a control template for it.
Do I need to override any rendering code when working with a base class of System.Windows.Controls.Control?
I have tried to use a control template in the way I would have used it for a control derived off another base class eg.
SearchTextBox : TextBox
DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchTextBox), new FrameworkPropertyMetadata(typeof(SearchTextBox)));
CustomControl : Control
DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl), new FrameworkPropertyMetadata(typeof(CustomControl)));
When I try to view this template in Blend I get the following error.
Unable to cast object of type 'Microsoft.Expression.DesignSurface.ArtboardBorder' to type 'ParentOfCustomControl'
(The custom control has a fixed Parent type which is derived from System.Windows.Controls.Grid)
|
|
|
|
|
Sorry Mikey, but you have me there. I only posted the link to you because it was something I had previously used and thought it fitted what you were looking for. As for Blend, it's not a product I have had experience of.
|
|
|
|
|
Hi.
I have the following code in a WPF Application :
<br />
<br />
<Window x:Class="WpfApplication1.Window1"<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
Title="Window1" Height="300" Width="300"><br />
<Grid><br />
<ListView Name="listView1" Margin="11.5,7,10.5,19.5"><br />
<ListView.View><br />
<GridView ><br />
<GridViewColumn Header="1"/><br />
<GridViewColumn Header="2"/><br />
</GridView><br />
</ListView.View><br />
<br />
</ListView><br />
</Grid><br />
</Window><br />
<br />
But in designer i see the listview empty and i dont see the 2 columns. I only see them on runtime.
|
|
|
|
|
I copied your code as it is in to a new WPF Project and I had no problems at all i.e. the columns were visible in designer.
I use VS2008(SP1).
|
|
|
|
|
Ok.
It seems that an update to sp1 was required.
Thanks.
|
|
|
|
|
Dear,
Anyone knows how i can create a clock timepicker in silverlight 2.0 (or 3.0)
thanks in advance
|
|
|
|
|
|
Hi,
I'm using a Grid with a TextBlock as a Y Axis Label so I need to rotate the text 90 (or 270) degrees, problem is that when you use a RotateTransform or PlaneProjection RotationZ="90" the text rotates but does not go beyond what the width of the label is so you get a chopped off piece of text running vertically, but only as high as the TextBlock is wide, am I doing something wrong?
Here's the XAML (using projection):
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="23"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="Test Vertical text" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<TextBlock.Projection>
<PlaneProjection RotationZ="90"/>
</TextBlock.Projection>
</TextBlock>
</Grid>
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
|
Yep, tried it, as soon as you limit the width of the textbox the text gets truncated to that...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
A RotateTransform doesn't change the dimensions of your textbox.
Text truncation is a separate issue.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Not sure what you mean, could you maybe send me a snippet for this with a TextBlock of 90 Height and 23 Width (for example) with Vertical Text?
If tried using the RotateTransform and it still gives me the truncation, maybe I'm doing something else wrong...
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Adriaan Davel wrote: a snippet for this with a TextBlock of 90 Height and 23 Width
If that's the dimensions you're using then I can see why text gets clipped.
A RotateTransform applied to a textblock will rotate the textblock, not just the text.
So you don't want to swap the width and height values.
You'll also need to be mindful of the element the textblock is contained in,
which depending on its type, could cause additional layout on the textblock.
Here's an example:
<Border BorderBrush="SteelBlue" BorderThickness="2" Width="300" Height="200" >
<Grid Background="LightSteelBlue" >
<TextBlock Text="Rotated Text" FontSize="12" FontWeight="Bold" Width="90" Height="23" HorizontalAlignment="Center" VerticalAlignment="Center" >
<TextBlock.RenderTransform>
<RotateTransform Angle="270" CenterX="45" CenterY="11" />
</TextBlock.RenderTransform>
</TextBlock>
</Grid>
</Border>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks for the Snippet, if I use this the text displays vertically but I have whitespace on either sides of the text to the full width of the text, which means my entire Grid Column need to be the width of the text even though there is only a little bit of text in the middle of it, is there a way to avoid the white space? (Other than calculating negative borders...)
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Maybe try the LayoutTransformer in the Silverlight Toolkit[^]
...
xmlns:layout="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
...
<Border BorderBrush="SteelBlue" BorderThickness="2" Width="300" Height="200" >
<Grid Background="LightSteelBlue" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border Grid.Column="0" BorderBrush="SteelBlue" BorderThickness="2" Background="AntiqueWhite" Margin="4" >
<layout:LayoutTransformer>
<layout:LayoutTransformer.LayoutTransform>
<RotateTransform Angle="270" />
</layout:LayoutTransformer.LayoutTransform>
<TextBlock Text="Rotated Text" FontSize="12" FontWeight="Bold" HorizontalAlignment="Center" />
</layout:LayoutTransformer>
</Border>
<Border Grid.Column="1" BorderBrush="SteelBlue" BorderThickness="2" Background="AntiqueWhite" Margin="4" >
</Border>
</Grid>
</Border>
Easier than trying to manually adjust margins/offsets.
Mark Salsbery
Microsoft MVP - Visual C++
modified on Thursday, October 1, 2009 1:07 PM
|
|
|
|
|
Mark Salsbery wrote: Steel
mmm, I like Steel!
Thanks Mark, I'll give it a try and let you know!
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
This is a brilliant solution, works 100%!
Thanks for the help!
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|