|
Oh dear have I offended your sensibilities, tough. For a start I did not call the OP a bloody idiot as he deserved, I discussed the quality of his question with ThatsAlok.
The original question was dumb, which I happily implied. I also pointed him to the most probable areas causing the unspecified problem.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This may sound a bit Armature but here it is.
What is the Form_load equivalent for a C#-Silverlight.
I have to Add shapes based on the available data.
1. I tried Putting the code in the MainPage() that does not work as the canvas actual height is NAN.
2. UserControl_Load() doesn't Work too.
I have to add any number of shapes so I can't add add them on design time.
Please Help
Thanks
|
|
|
|
|
|
It's the "Loaded" event.
void MyUserControl_Loaded(object sender, RoutedEventArgs e)
{
}
To set up the event handler, you can use
this.Loaded += MyUserControl_Loaded in code behind, or
Loaded="MyUserControl_Loaded" in XAML
|
|
|
|
|
I'm using the WPF Extended Toolkit PropertyGrid (v1.7), and I'm trying to setup a custom editor to display a dialog box when the user clicks a button. My problem is that I can't get the property grid to display the editor panel at all.
I tried doing it this way, but it wouldn't display, and after some investigation in the debugger, I noticed that the template's VisualTree was null:
public class CDSceneSelectorEditor : DialogPropertyValueEditor
{
public CDSceneSelectorEditor()
{
string template =
@"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
// xmlns:pe='clr-namespace:System.Activities.Presentation.PropertyEditing;assembly=System.Activities.Presentation'>
<DockPanel LastChildFill='True'>
<pe:EditModeSwitchButton TargetEditMode='Dialog' Name='EditButton'
DockPanel.Dock='Right' Content='...' />
<TextBlock Text='Picture' Margin='2,0,0,0'
VerticalAlignment='Center'/>
</DockPanel>
</DataTemplate>";
try
{
using (var sr = new MemoryStream(Encoding.UTF8.GetBytes(template)))
{
this.InlineEditorTemplate = (DataTemplate)(XamlReader.Load(sr));
}
}
catch (Exception ex)
{
if (ex != null) {}
}
}
}
So, I figured that the visual tree must be the issue, so I tried it this way, which gave me a VistalTree , but didn't change the outcome:
public class CDSceneSelectorEditor : DialogPropertyValueEditor
{
public CDSceneSelectorEditor()
{
var button = new FrameworkElementFactory(typeof(EditModeSwitchButton))
{ Name = "EditButton" };
button.SetValue(DockPanel.DockProperty, Dock.Right);
button.SetValue(EditModeSwitchButton.TargetEditModeProperty,
PropertyContainerEditMode.Dialog);
button.SetValue(EditModeSwitchButton.ContentProperty, " ... ");
button.SetValue(TextBlock.MarginProperty, new Thickness(0,0,3,0));
var image = new FrameworkElementFactory(typeof(Image))
{ Name = "ThumbnailImage" };
image.SetValue(Image.StretchProperty,
System.Windows.Media.Stretch.Uniform);
var panel = new FrameworkElementFactory(typeof(DockPanel));
panel.AppendChild(button);
panel.AppendChild(image);
DataTemplate template = new DataTemplate();
template.VisualTree = panel;
this.InlineEditorTemplate = template;
}
}
I am out of ideas, and google has been no help at all.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
Hi,
0 down vote favorite
I am learning to draw a line graph inside my WPF. i found a tutorial of a horizontal line graph at this side: http://www.c-sharpcorner.com/uploadfile/mahesh/line-chart-in-wpf/ and i manage to plot it. But my question is how to draw a vertical graph?
I taking the example of the graph from the website i provided, if transform the graph to the vertical graph. The X-axis will be the int(on the top) and the Y-axis will be the Date(at the left hand side). Anyone can help me out?
The graph i want should be like this: http://imageshack.us/photo/my-images/202/capturegfj.jpg/
Thanks.
|
|
|
|
|
I have this data:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfFolderEntity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FolderEntity Id="0" FolderName="Projects" Description="">
<Folders>
<FolderEntity Id="3" FolderName="Folder 1" Description="Folder 1 Desc ">
<Folders />
<Files>
<FileEntity Id="1" FileName="File A" Description="File A Desc " />
<FileEntity Id="2" FileName="File B" Description="File B Desc " />
</Files>
</FolderEntity>
<FolderEntity Id="6" FolderName="Folder 2" Description="Folder 2 Desc ">
<Folders />
<Files>
<FileEntity Id="4" FileName="File C" Description="File C Desc " />
<FileEntity Id="2" FileName="File B" Description="File B Desc " />
</Files>
</FolderEntity>
</Folders>
<Files />
</FolderEntity>
</ArrayOfFolderEntity>
and after it's deserialized it populated a list if Folders and Files:
Then in the view I have TreeView:
<TreeView x:Name="tvwItems"
BorderThickness="0"
Background="Transparent"
Grid.Row="1"
Grid.Column="0"
Margin="0,2,0,2"
ItemsSource="{Binding Folders}">
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type entities:FolderEntity}"
ItemsSource="{Binding Folders}">
<TextBlock Text="{Binding Path=FolderName}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type entities:FileEntity}" >
<TextBlock Text="{Binding Path=FileName}" />
</DataTemplate>
</TreeView.Resources>
</TreeView>
The data is being loaded correctly, but when It runs all I see is
Projects
Folder 1
Folder 2
... no files.
What am I doing wrong?
If it's not broken, fix it until it is
|
|
|
|
|
I always create a child collection eg folder object has an observablecollection of Files. Bind the tree to Folders and your Hierarchical template should bind to the child items (Files).
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
To add to Mycroft's answer, you need to call the collection of files property "Children". Then the tree will simply populate itself when you bind the tree to the folders collection.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
Not sure I understand. You're saying by simply calling it 'Children', it will update itself??
If it's not broken, fix it until it is
|
|
|
|
|
Yes, it should.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
Ok, I see. Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Did you get it to work?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "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
|
|
|
|
|
Yes, last night I refactored it, and now it works.
Many thanks
If it's not broken, fix it until it is
|
|
|
|
|
I have a wpf datagrid which I am using with the grouping feature. Is there any way to show different columns within the grid based on the grouping property. So if I have groups A and B, can i show columns 1,2,3 for group A and columns 4,5,6 for group B?
modified 10-Oct-12 4:13am.
|
|
|
|
|
I would be surprised if this is possible, you may be able to kludge it using visibility based on group but I doubt it. I'd look into sub grids or two collections, one for groups and another for the sub elements and maybe template based on the group type!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Greetings,
I created a control template inside of the xaml file where the control was. It worked. When I moved the control template and styles to the generic.xaml, they stopped working and I get an error "key attribute can be used only on a tag contained in an idictionary type property". I am fairly new to WPF and the code I am posting was modified from something that Blend created.
I'd appreciate some help getting it to work. Specifically, how do I add it to the generic.xaml and then how do I reference it in another file.
<LinearGradientBrush x:Key="MenuItemSelectionFill" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#34C5EBFF" Offset="0"/>
<GradientStop Color="#3481D8FF" Offset="1"/>
</LinearGradientBrush>
<Style>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Grid>
<Rectangle x:Name="Bg" Fill="{TemplateBinding Background}" RadiusY="2" RadiusX="2" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="1"/>
<Rectangle x:Name="InnerBorder" Margin="5" RadiusY="2" RadiusX="2"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32" SharedSizeGroup="MenuItemIconColumnGroup"/>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentPresenter Grid.Column="0" x:Name="Icon" Margin="0" VerticalAlignment="Center" ContentSource="Icon"/>
<ContentPresenter Grid.Column="1" Margin="10" ContentSource="Header" VerticalAlignment="Center" RecognizesAccessKey="True"/>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter Property="Visibility" TargetName="Icon" Value="Collapsed"/>
</Trigger>
<Trigger Property="IsHighlighted" Value="true">
<Setter Property="Fill" TargetName="Bg" Value="{StaticResource MenuItemSelectionFill}"/>
<Setter Property="Stroke" TargetName="Bg" Value="#8071CBF1"/>
<Setter Property="Stroke" TargetName="InnerBorder" Value="#40FFFFFF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="{x:Type MenuItem}" TargetType="MenuItem" BasedOn="{StaticResource BaseControlStyle}">
<Style.Triggers>
<Trigger Property="Role" Value="SubmenuItem">
<Setter Property="Padding" Value="5"/>
<Setter Property="Background" Value="#F0F0F0"/>
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}"/>
</Trigger>
</Style.Triggers>
</Style>
Thanks,
Wade
|
|
|
|
|
Silvelight : Canvas with checkbox create in dynamically like theater sit booking
if i give colm=1- and row =10 , ist become Canvas row 10 checkbox come and col = 10
|
|
|
|
|
|
Hi,
I need to convert a byte[] array generated from PDF into image and show it in the UI. I dnt want to store the image file anywhere in the disk.Conversion should be using in-built memory. I tried to convert byte into bitmap image using the following code. But image is not rendered in the UI.
using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length))
{
BitmapImage im = new BitmapImage();
im.SetSource(ms);
this.pdfImage.Source = im;
}
Is there anyother way to do this? Tools are also acceptable.
Gomathi R
|
|
|
|
|
You can't convert a PDF into an image simply by converting it into a byte array. Without the conversion to an image, the BitmapImage identifies that it cannot display the byte array, so it doesn't attempt to display it. You might want to try this[^] library for the actual conversion (there's even a small sample on saving a PDF to a png file).
|
|
|
|
|
Hi Pete,
I have tried this. But i am unable to add the dll in my Silverlight Application.
Gomathi R
|
|
|
|
|
You don't add it to the Silverlight side - you add it to the ASP.NET side, and send the byte array to the Silverlight app. That is, after all, where you are getting the PDF from isn't it?
|
|
|
|
|
Even in asp .net i am unable to add the dlls. I have added libpdf dll and tried to run the code. I got the following error. Could not load file or assembly 'libpdf.DLL' or one of its dependencies. The specified module could not be found.
Gomathi R
|
|
|
|
|
I am trying to create a basic Silverlight application that user can access via IE. The SL application will read some local registry settings (e.g. OS installed, ). Any direction/example will be greatly appreciated.
|
|
|
|