|
|
I'm trying to set up a toggle button that changes the image when the button is checked/no checked. Consider the following XAML:
<style targettype="ToggleButton" x:key="PushPinButton" mode="hold" xmlns:x="#unknown" /> <Setter Property="Template" />
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Image Source="/CometWPF2;component/Icons/blue_pushpin.png" Margin="0"
VerticalAlignment="Center" HorizontalAlignment="Center" />
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Template" />
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Image Source="/CometWPF2;component/Icons/red_pushpin.png" Margin="0"
VerticalAlignment="Center" HorizontalAlignment="Center" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
The IDE is telling me that the Setter.Value attachable property doesn't exist. I have no idea if I'm doing this anywhere close to correctly...
I did this and it works:
<Image Source="/CometWPF2;component/Icons/blue_pushpin.png" x:Key="PinUp" />
<Image Source="/CometWPF2;component/Icons/red_pushpin.png" x:Key="PinDown" />
<Style TargetType="ToggleButton" x:Key="UDPPushPinButton">
<Setter Property="Content" Value="{DynamicResource PinUp}" />
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content" Value="{DynamicResource PinDown}" />
</Trigger>
</Style.Triggers>
</Style>
Now I want to get rid of the border that shows up (and remains displayed) when it's clicked.
"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
modified on Tuesday, April 14, 2009 5:11 PM
|
|
|
|
|
The Setter tag is closed. <Setter Property="Template" /> should be <Setter Property="Template" > . The Style tag too.
XAML is well-formed XML.
Eslam Afifi
|
|
|
|
|
Add:
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
So it will be something like:
<Image Source="/CometWPF2;component/Icons/blue_pushpin.png" x:Key="PinUp" />
<Image Source="/CometWPF2;component/Icons/red_pushpin.png" x:Key="PinDown" />
<Style TargetType="ToggleButton" x:Key="UDPPushPinButton">
<Setter Property="Content" Value="{DynamicResource PinUp}" />
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Content" Value="{DynamicResource PinDown}" />
</Trigger>
</Style.Triggers>
</Style>
|
|
|
|
|
Good People,
So I have been developing my application fine now (for about 3 months) then out of the blue, Visual Studio will not show any of the user controls I have created and Expression Blend will crash when I try to show any data template.
Back in Visual Studio, it's telling me that it can't find a static resource referenced in my resource dictionary and then it notifies me that in App.xaml the Source property of resource dictionary cannot be set to my resource dictionary. I am puzzled. It builds fine and executes fine. The xaml files all have their appropriate namespaces and scope.
I checked online and someone, in 2008, said this was a bug. Of course, I tried to download visual studio 2008 service pack 1 but that installation always hangs, never downloads and doesn't install any files. I have .net 3.5 sp1.
Any thoughts or ideas would be deeply appreciated.
Thanks,
Blitz
So, the problem was that I had to move the resources to the top of the resource dictionary file so it could find them.
#$%%^$#@@#$$ you WPF!
Anyway, I'm happy again
modified on Tuesday, April 14, 2009 5:49 PM
|
|
|
|
|
By the way, these resources are defined in the Resource Dictionary using the right key - e.g. "StringToBoolConverter", but it is still unable to find them.
In addition, I wonder why these problems would start now and not earlier.
|
|
|
|
|
Hello.
Is it possible to place a Canvas or Grid inside a Viewport3D, to enable a flip or skew animation? Simply adding a canvas as a child doesn't work, so I'm wondering if there is another way?
Regards, E.
|
|
|
|
|
You're right, I don't think that you can just stick UIElements into ViewPort3D.
One option is to try to simulate your desired 3D animation with the regular 2D system. For example, check out this blog post by Tess Ferrandez which shows how to do a flip between 2 UI elements:
Silverlight/WPF FlipImage Animation[^]
If you are using these animations as transitions and don't need to have active UI elements during those transitions, you may be able to persist your UI elements to an image and have that applied to a 3D element which you can add to your ViewPort3D.
|
|
|
|
|
Hi.
I'm reading a XML file that has been stored in IsolatedStorage .
But this Exception was occurring Root element is missing .
I'm dead sure that there isn't any troubles in the XML file, So I don't the know the result of the Exception
Could you guide me ?
Thank you.
This is my snippet code :
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
.
.
.
string SettingFilePath = "CodeColorizer\\setting.xml";
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(SettingFilePath, FileMode.Create, isoStore))
{
isoStream.Position = 0;
XmlReader xmlReader;
xmlReader = XmlReader.Create(isoStream);
<code>xmlReader.MoveToContent();</code>
string value;
while (xmlReader.Read())
{
switch (xmlReader.NodeType)
{
case XmlNodeType.Element:
{
if (xmlReader.Name == "IsVB")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
if (value == "True") { this.IsVB.IsChecked = true; this.IsCsharp.IsChecked = false; }
else if (value == "False") { this.IsVB.IsChecked = false; this.IsCsharp.IsChecked = true; }
}
else if (xmlReader.Name == "IsCsharp")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
if (value == "True") { this.IsVB.IsChecked = false; this.IsCsharp.IsChecked = true; }
else if (value == "False") { this.IsVB.IsChecked = true; this.IsCsharp.IsChecked = false; }
}
else if (xmlReader.Name == "IsStriped")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
if (value == "True") { this.IsStriped.IsChecked = true; }
else if (value == "False") { this.IsStriped.IsChecked = false; }
}
else if (xmlReader.Name == "HasLineNumber")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
if (value == "True") { this.HasLineNumber.IsChecked = true; }
else if (value == "False") { this.HasLineNumber.IsChecked = false; }
}
else if (xmlReader.Name == "AddDefaultStylesWithinPreTags")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
if (value == "True") { this.addDefaultStylesWithinPreTags.IsChecked = true; }
else if (value == "False") { this.addDefaultStylesWithinPreTags.IsChecked = false; }
}
else if (xmlReader.Name == "CssClassName")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
this.cssClassName.Text = value;
}
else if (xmlReader.Name == "AddPreTag")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
if (value == "True") { this.AddPreTag.IsChecked = true; }
else if (value == "False") { this.AddPreTag.IsChecked = false; }
}
else if (xmlReader.Name == "AddBGColor")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
if (value == "True") { this.AddBGColor.IsChecked = true; }
else if (value == "False") { this.AddBGColor.IsChecked = false; }
}
else if (xmlReader.Name == "TextBoxColor")
{
value = (string)xmlReader.ReadContentAs(Type.GetType("String"), null);
this.TextBoxColor.Text = value;
}
break;
}
}
}
}
}
modified on Tuesday, April 14, 2009 12:08 AM
|
|
|
|
|
Is FileMode.Create really the mode you want to open the file in?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark.
I've altered it to FileMode.Open , but the Exception has occurred again
|
|
|
|
|
I've done it :
using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication())
{
.
.
.
string SettingFilePath = "CodeColorizer\\setting.xml";
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(SettingFilePath, FileMode.Open, isoStore))
{
isoStream.Position = 0;
XmlReader xmlReader;
xmlReader = XmlReader.Create(isoStream);
Debug.WriteLine("\r\n" + isoStream);
xmlReader.MoveToContent();
string value;
while (xmlReader.Read())
{
switch (xmlReader.NodeType)
{
case XmlNodeType.Element:
{
if (xmlReader.Name == "IsVB")
{
value = xmlReader.ReadElementContentAsString();
if (value == "True") { this.IsVB.IsChecked = true; this.IsCsharp.IsChecked = false; }
else if (value == "False") { this.IsVB.IsChecked = false; this.IsCsharp.IsChecked = true; }
}
else if (xmlReader.Name == "IsCsharp")
{
value = xmlReader.ReadElementContentAsString();
if (value == "True") { this.IsVB.IsChecked = false; this.IsCsharp.IsChecked = true; }
else if (value == "False") { this.IsVB.IsChecked = true; this.IsCsharp.IsChecked = false; }
}
else if (xmlReader.Name == "IsStriped")
{
value = xmlReader.ReadElementContentAsString();
if (value == "True") { this.IsStriped.IsChecked = true; }
else if (value == "False") { this.IsStriped.IsChecked = false; }
}
else if (xmlReader.Name == "HasLineNumber")
{
value = xmlReader.ReadElementContentAsString();
if (value == "True") { this.HasLineNumber.IsChecked = true; }
else if (value == "False") { this.HasLineNumber.IsChecked = false; }
}
else if (xmlReader.Name == "AddDefaultStylesWithinPreTags")
{
value = xmlReader.ReadElementContentAsString();
if (value == "True") { this.addDefaultStylesWithinPreTags.IsChecked = true; }
else if (value == "False") { this.addDefaultStylesWithinPreTags.IsChecked = false; }
}
else if (xmlReader.Name == "CssClassName")
{
value = xmlReader.ReadElementContentAsString();
this.cssClassName.Text = value;
}
else if (xmlReader.Name == "AddPreTag")
{
value = xmlReader.ReadElementContentAsString();
if (value == "True") { this.AddPreTag.IsChecked = true; }
else if (value == "False") { this.AddPreTag.IsChecked = false; }
}
else if (xmlReader.Name == "AddBGColor")
{
value = xmlReader.ReadElementContentAsString();
if (value == "True") { this.AddBGColor.IsChecked = true; }
else if (value == "False") { this.AddBGColor.IsChecked = false; }
}
else if (xmlReader.Name == "TextBoxColor")
{
value = xmlReader.ReadElementContentAsString();
this.TextBoxColor.Text = value;
}
break;
}
}
}
}
}
|
|
|
|
|
Is it working now?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
|
|
I have the following code
<Border Margin="3,4,0,0" Height="205" VerticalAlignment="Top" BorderBrush="Black"
BorderThickness="2" HorizontalAlignment="Left" Width="891" CornerRadius="8,8,8,8">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<StackPanel.Clip>
<RectangleGeometry Rect="0,0,891,205" RadiusX="8" RadiusY="8"></RectangleGeometry>
</StackPanel.Clip>
<Label Height="26" Name="label1" Width="205" HorizontalAlignment="Left" VerticalAlignment="Top"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Arial" FontSize="14"
FontStyle="Italic" FontWeight="Bold" Content="Contacts" Background="Black" Foreground="LightSteelBlue"
ClipToBounds="True">
<Label.LayoutTransform>
<RotateTransform Angle="270" />
</Label.LayoutTransform>
</Label>
<telerik:RadGridView Name="gridviewContacts" AllowDrop="False" Height="203" VerticalAlignment="Top"
Margin="0,0,0,0" AutoGenerateColumns="False" FontFamily="Arial" ClipToBounds="False"
Width="863">
<telerik:Theming.Theme>
<telerik:VistaTheme />
</telerik:Theming.Theme>
</telerik:RadGridView>
</StackPanel>
</Border>
Essentially, I have a Border that contains a horizontally oriented StackPanel that contains a Label and a Telerik RadGridView . I want to put rounded corners on the Border element, and clip all of the other elements within the Border to not render outside the rounded corners.
The code above contains my latest non-working attempt. I tried to use the ClipToBounds property, but that doesn't seem to do anything.
"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
|
|
|
|
|
I found this, Clipping of child elements[^].
<local:ClippingBorder Margin="3,4,0,0" Height="205" VerticalAlignment="Top" BorderBrush="Black" BorderThickness="4" HorizontalAlignment="Left"
Width="891" CornerRadius="80">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Label Height="26" Name="label1" Width="205" HorizontalAlignment="Left" VerticalAlignment="Top"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Arial" FontSize="14"
FontStyle="Italic" FontWeight="Bold" Content="Contacts" Background="Black" Foreground="LightSteelBlue">
<Label.LayoutTransform>
<RotateTransform Angle="270" />
</Label.LayoutTransform>
</Label>
<Rectangle Fill="Blue" Width="1000" Height="500" Opacity="0.4" />
</StackPanel>
</local:ClippingBorder>
Eslam Afifi
modified on Monday, April 13, 2009 2:12 PM
|
|
|
|
|
It tries to clip - just in a braindead way.
For example:
<Border Height="100" VerticalAlignment="Top" BorderBrush="Black"
BorderThickness="2" HorizontalAlignment="Left" Width="300" CornerRadius="20">
<StackPanel Orientation="Horizontal" Background="SteelBlue" >
<StackPanel.Clip>
<RectangleGeometry Rect="0,0,300,100" RadiusX="20" RadiusY="20" />
</StackPanel.Clip>
<Label Height="26" Name="label1" Width="100" HorizontalAlignment="Left" VerticalAlignment="Top"
HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontFamily="Arial" FontSize="14"
FontStyle="Italic" FontWeight="Bold" Content="Contacts" Background="Black" Foreground="LightSteelBlue" >
<Label.LayoutTransform>
<RotateTransform Angle="270" />
</Label.LayoutTransform>
</Label>
</StackPanel>
</Border>
Monkeying with the radius values, sometimes it does ok, sometimes it doesn't.
No bueno.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi,
I want to do some processing after knowing that a control has finished rendering. In windows forms we usually had events like OnRenderComplete with all the controls. But in WPF I found events like Loaded, Initialized, OnLayoutUpdated etc.. which do not inform you that the control has actually finished rendering on the UI.
Is there a way to identify this?
Pankaj Chamria,
Software Developer.
|
|
|
|
|
Next problem....
Here's some code
<DataTemplate x:Key="TestDataListTemplate">
<Border Margin="5" BorderThickness="1" BorderBrush="Black" CornerRadius="4">
<Grid Margin="5,2">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="{Binding Path=Usage}" Foreground="Black" FontWeight="Bold" FontFamily="Courier" FontSize="12"></TextBlock>
<TextBlock Grid.Row="1" FontFamily="Arial" Foreground="DarkBlue" Text="{Binding Path=Path, UpdateSourceTrigger=PropertyChanged}" FontSize="12"></TextBlock>
</Grid>
</Border>
</DataTemplate>
...which I use as a ListBoxItem.
If I want a context menu for each item like this, I manage to get the menu, editing the code to...
...<Grid Margin="5,2">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Delete" />
</ContextMenu>
</Grid.ContextMenu>...
But how do I implement the click event???
|
|
|
|
|
mikla521 wrote: But how do I implement the click event???
Which click event?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Sorry....like this then...
<DataTemplate x:Key="TestDataListTemplate" >
...
<Grid Margin="5,2">
<Grid.ContextMenu>
<ContextMenu>
<MenuItem Header="Delete" Click="MenuItem_Click_DeleteProduct" />
</ContextMenu>
</Grid.ContextMenu>...
Error:ResourceDictionary root element requires a x:Class attribute...
If I add x:class="MyProgram.Window1" to <ResourceDictionary the i get this instead, among a few others...
Error: Partial declarations of MyProgram.Window1 must not specify different base classes....don't get it.
Well, it seems like I have more problems. The goal is to have ListBox with DataTemplate items, then I want a ContextMenu where I can choose to delete an item... Maybe I have to think in another way.
modified on Sunday, April 12, 2009 2:41 AM
|
|
|
|
|
Where is this DataTemplate resource located?
It looks like there's no problem with the template but there's a problem with where
the template an/or the click handler code is located...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|