|
thanks for your reply. I forgot to mention that I want to limit myself to the WPF API. Nevermind, your answer helped me figure out the WPF-way of doing it.
I am using now an instance of FormattedText und ask its Width and Height properties.
Interestingly there exists a method GetMaxLineWidths() in this class but it doesn't work as I expected. It always returns {null}.
Regards,
Lars
#pragma error( disable : * )
|
|
|
|
|
I'm looking at this problem again, and I still haven't been able to figure out why it's not working. I have a number of XAML files in a WPF UserControl library that contain various elements.
In Resources.XAML:
<ImageBrush x:Key="ImgBrushQuickLaunch" Stretch="Fill"
ImageSource="/MyResourcesLib;component/Images/GlassQuickLaunch64.png" />
In Styles.XAML:
<Style TargetType="{x:Type Button}" x:Key="StyleUDPButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" Value="0.40" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="StyleButtonQuickLaunch" TargetType="{x:Type Button}"
BasedOn="{StaticResource StyleUDPButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border CornerRadius="18" Background="{DynamicResource UDPQuickLaunch}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Finally, in the main application Window (in the main application), I'm doing this:
<Window x:Class="TestingPlatform.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">
<Grid>
<Button Name="button1" Style="{DynamicResource StyleButtonQuickLaunch}"
Margin="60,58,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
Height="37" Width="37"
BorderThickness="0" BorderBrush="Transparent" />
</Grid>
</Window>
My problem is that despite there being no errors or warnings, the button does not show up in either the designer, nor the running application. In fact, I can't get the button to show up at all unless the custom style isn't attached, even if I take off the BasedOn property.
"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
|
|
|
|
|
John - this should fix it. In your App.xaml, you need to add these resource dictionaries to the global resources using:
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources.xaml" />
<ResourceDictionary Source="Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
"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'd already done 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
|
|
|
|
|
As I mentioned in your previous post on this, you don't have anything visible in your
button template, so you won't see anything.
For example, if I change your template to...
<Style x:Key="StyleButtonQuickLaunch" TargetType="{x:Type Button}"
BasedOn="{StaticResource StyleUDPButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border CornerRadius="18" <code>BorderBrush="DarkGreen" BorderThickness="2" Background="LightGreen"</code>>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
...then use the style on a button something like this...
<StackPanel>
<Button Name="button1" Style="{DynamicResource StyleButtonQuickLaunch}" Height="50" />
</StackPanel>
...then it works great.
That's why I asked you before if re-templating controls all the time is really what you want,
or do you just want to just modify certain properties of existing controls using style setters....
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Need a sample video Conferencing application using wpf
|
|
|
|
|
Jeena S wrote: Need a sample video Conferencing application using wpf
Try rentacoder then; or search google for 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'll give you mine but it's pretty expensive
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Is there a way I can create forms dynamically(not load, but create), and get the XAML of the form as the output. Is there a tool that can do it? In which I could specify the location and type of control I want to put on the form?
Thanks
|
|
|
|
|
As XAML is just XML, you could write it out using the XML features of .NET and then compile it/load it using the XamlReader class.
"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 want to create datetime, time and duration control...
I have created the datecontrol by using datepicker available in Silverlight....
Do we have any existing controls available in Silverlight 2.0 so that I can make datetime, time and duration controls...?
Or have to extend some controls to get above controls?
Can anybody have some code / hyperlinks from where I can get the idea?
|
|
|
|
|
How to write a type-ahead (suggests) control in WPF.
thanks
Ganesh
|
|
|
|
|
|
I have ListBox in test.xaml:
<grid>
<listbox margin="12,28,0,0" name="ListBox1" horizontalalignment="Left" width="77" height="100" verticalalignment="Top">;
;
And in the test.xaml.cs file, I initialized the ListBox as
for (int i=1; i<=50; i++)
{
ListBox1.Items.Add("Item" + i);
}
Now I want to set a "HelpText" AutomationProperty to each of the ListItems. How do I do it?
I heard it could be done through Binding? Can some one provide me the required info?
Thanks.
|
|
|
|
|
[Reposting; Some problem in text display]
I have a test.xaml:
<Grid>
<ListBox Margin="12,28,0,0" Name="ListBox1" HorizontalAlignment="Left" Width="77" Height="100" VerticalAlignment="Top" />;
</Grid>;
And in the test.xaml.cs file, I initiatilize the ListBox
for (int i=1; i<=50; i++)
{
ListBox1.Items.Add("Item" + i);
}
Now I want to set a HelpText AutomationProperty to each of the ListItems. i.e. HelpText1 to Item1, HelpText2 to Item2 and likewise. How do I exactly do it?
Thanks
|
|
|
|
|
Hello..
I want some help from you guys in my wpf project.
I prepared my project using MVVM pattern.
I am using HeaderedContentControl and in content presenter of that i am using tab control.
MyControl.xaml
<Window.Resources>
<Style x:Key="HeaderStyle" TargetType="{x:Type HeaderedContentControl}">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="5" Margin="4" Padding="4" SnapsToDevicePixels="True">
<TextBlock FontSize="14" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" Text="{TemplateBinding Content}" />
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type HeaderedContentControl}">
<DockPanel>
<ContentPresenter
DockPanel.Dock="Top"
ContentSource="Header"
ContentTemplate="{TemplateBinding HeaderTemplate}"
/>
<ContentPresenter
ContentSource="Content"
ContentTemplate="{TemplateBinding ContentTemplate}"
/>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="MyWorkingTemplate">
<TabControl
IsSynchronizedWithCurrentItem="True"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource ClosableTabItemTemplate}"
Margin="4"
/>
</DataTemplate>
</Window.Resources>
<HeaderedContentControl
Content="{Binding Path=Workspaces}"
ContentTemplate="{StaticResource MyWorkingTemplate}"
Header="My Tabs"
Style="{StaticResource HeaderStyle}"
/>
In Content template my all bindings working fine with viewmodel..But my problem is,in my header template here i have textblock and now i want here some content control and binding two different views here and show it according to requirement..
Any help??
|
|
|
|
|
|
|
Hi,
I have a word file. I want to save the first page as a picture. How can I do it using C# code?
Thanks,
Prajeesh
|
|
|
|
|
Please pick a more appropriate forum.
"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 a RadialGradiantBrush in the app.xaml
<Application.Resources>
<RadialGradientBrush x:Name="RGB1">
<GradientStop Color="AntiqueWhite" Offset="0.0" />
<GradientStop Color="LightSalmon" Offset="0.25" />
<GradientStop Color="LightBlue" Offset="0.75" />
<GradientStop Color="Wheat" Offset="1.0" />
</RadialGradientBrush>
</Application.Resources>
I assign it to a background in the generic.xaml
<Canvas x:Name="RightCanvas" Grid.Column="2" Background = "{StaticResource RGB1}"/>
How can i do this in the .cs file
RightCanvas.Background = "{StaticResource RGB1}" as RadialGradiantBrush
?
Thank you .
|
|
|
|
|
RightCanvas.Background = Application.Current.Resources["RGB1"] as RadialGradientBrush;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks
Great, I have my brushes in app.xaml
and now can access them from xaml or cs !
But now the designer doesnt work
Error HRESULT E_FAIL has been returned from a call to a COM component.
vs2008
|
|
|
|
|
daveyerwin wrote: But now the designer doesnt work
Since the Silverlight XAML designer is only partially implemented in VS,
it can be "challenging" to find the offending code or markup
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi.
I have a big image ( like a map ).
I wanna show it in an image (in WPF) as when user do MouseDown on it , it can move map coordinates .
Something like Google map.
Could you guide me how I can do it ?
Thanks
|
|
|
|