|
New threads are MTA by default, but if you need STA you can
specify STA.
On your custom entry point function you can use
STAThreadAttribute:
[STAThread]
Main()
{
DerivedAppClass app = new DerivedAppClass();
app.Run();
}
On dynamically created threads you can use the SetApartmentState()
method:
mynewthread.SetApartmentState(ApartmentState.STA);
mynewthread.Start(...);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Oh, excellent remark. LoadComponent() is working flawlessly from now on.
Thank you for your help and time.
|
|
|
|
|
I am really new for WPF, I am trying to create Radiobuttons,checkbox and textbox control at run time.
Is it possible to create controls at runtime in WPF,if yes then please let me know good link or sample code.
Thanks for taking your time!
I am using C# and VisualStudio2008.
|
|
|
|
|
Sr...Frank wrote: Is it possible to create controls at runtime in WPF
Of course. Elements declared in markup (XAML) are created
just like any other CLR objects.
Sr...Frank wrote: ,if yes then please let me know good link or sample code
using System.Windows.Controls;
...
RadioButton radiobutton = new RadioButton();
CheckBox checkbox = new CheckBox();
TextBox textbox = new TextBox();
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
How to bound them with windows form in WPF?
|
|
|
|
|
Sr...Frank wrote: How to bound them with windows form in WPF?
I'm not sure what you're asking here...
If you're using Windows Forms, why use WPF controls?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
Any trick to select multiple items in WPF listbox without holding shift key? Multiple items should be selected on holding and dragging just left mouse button.
Thanks
|
|
|
|
|
I'm learning that WPF is all about laying out your controls in a non-fixed fashion to be able to accomodate dynamic content. All well and good.
The application I need to write, however needs to display objects on a map in their precise locations. Does WPF provide enough support for fixed layout of objects so that I can implement my mapping application?
|
|
|
|
|
You can layout anything in a 'fixed' way by using a combination of the HorizontalAlighment VerticalAlignment and Margin properties, when used inside a Grid or a Canvas panel.
|
|
|
|
|
Hi..
I created a WPF C# application.
I deployed it to an computer with the .Net 3.5 framework.
When I double-click on the EXE nothing happens.. ANd i have got this error:
EventType : clr20r3 P1 : firstc1.exe P2 : 1.0.0.0
P3 : 4b2f37b0 P4 : presentationframework P5 : 3.0.0.0 P6 : 488f142e
P7 : 6259 P8 : e1 P9 : system.windows.markup.xamlparse.
And i have defined in App.xaml thsi resource for my Main Windows:
<Application x:Class="FirstC1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
<SolidColorBrush x:Key="base_color" Color="#FF007D5A" />
<SolidColorBrush x:Key="selection" Color="#FF00422F" />
<Style x:Key="chart_border" TargetType="{x:Type Border}">
<Setter Property="BorderBrush" Value="{StaticResource base_color}"/>
<Setter Property="CornerRadius" Value="5"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush Opacity="0.25" StartPoint="0,0" EndPoint="1,1">
<GradientStop Color="Transparent" Offset="0"/>
<GradientStop Color="{Binding Source={StaticResource base_color},Path=Color}" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>
<!-- samples that can not be shown in XBAP -->
<Visibility x:Key="uiVisibilty">
Visible
</Visibility>
<Style TargetType="{x:Type TabItem}" x:Key="tree">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border
Name="Border"
BorderBrush="Black"
Background="Gold"
BorderThickness="1,1,1,1"
CornerRadius="25,5,0,0">
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="12,0,12,0" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background" Value="White" />
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background" Value="LightGray" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="FirstCell">
<StackPanel Orientation="Horizontal">
<CheckBox Name="chk1" IsChecked="{Binding Path=IsSelected,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListViewItem}}}"/>
</StackPanel>
</DataTemplate>
</Application.Resources>
</Application>
Thanks in advance.
|
|
|
|
|
And what have Visifire said?
"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
|
|
|
|
|
To use visifire, it's important to create a chart in a constructor or windows before use it in other function in a csharp code. I have so many errors in deploymnt of my application in WPF. Do you think in this case that it's an error in my app.xaml, specifically in a gradientbrush?
|
|
|
|
|
I am building a Silverlight 3 application using MSBuild. I am attempting to POST data in a HttpWebRequest, and I get error CS1061:
'System.Net.HttpWebRequest' does not contain a definition for 'ContentLength'. Here is a code snippet:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "&amp;items=7";
postData += "&amp;data="+String.Format("{0}", recnbr);
postData += "&amp;delay=false";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentLength = byteArray.Length; [ERROR HERE]
request.ContentType = "application/x-www-form-urlencoded";
I also get the same error for 'GetRequestStream'.
Searching the Internet, I found no answers. Can anyone help?
|
|
|
|
|
Siberz wrote: 'System.Net.HttpWebRequest' does not contain a definition for 'ContentLength'.
Correct. This property is not available in the
Silverlight .NET Framework. I believe the system sets
this for you based on how much data is written to the
request stream. See the "Remarks" section here:
HttpWebRequest.Headers Property[^]
Siberz wrote: I also get the same error for 'GetRequestStream'.
You'll need to use BeginGetRequestStream() and EndGetRequestStream()
in Silverlight.
Siberz wrote: Searching the Internet, I found no answers.
Silverlight Documentation[^]
HttpWebRequest Members[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have a class which builds cubes.One of its properties is to translate to diffrent part of the screen.
testCube is object of that class.
testCube.Translate = new TranslateTransform3D(0, -1, 1);
I would like to set binding for Translation, but I am having hard time.
Looking the book WPF in Action I found this code for Rotation.
AxisAngleRotation3D angleRot = new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0);
RotateTransform3D rot = new RotateTransform3D(angleRot,new Point3D(-spaceToUseX + (spaceToUseX / 2), 0, -(barWidth / 2)));
Binding rotBind = new Binding("Value");
rotBind.Source = rotateSlider;
BindingOperations.SetBinding(angleRot,
AxisAngleRotation3D.AngleProperty, rotBind);
model.Transform = rot;
I wrote this code, but nothing happends.It runs, with no errors
Binding TransformBindingX = new Binding("CubeUnit");
TransformBindingX.Path = new PropertyPath("Translate.OffsetX");
Binding TransformBindingY = new Binding("CubeUnit");
TransformBindingY.Path = new PropertyPath("Translate.OffsetY");
Binding TransformBindingZ = new Binding("CubeUnit");
TransformBindingZ.Path = new PropertyPath("Translate.OffsetZ");
TranslateTransform3D translateTransform3D = new TranslateTransform3D();
BindingOperations.SetBinding(translateTransform3D, TranslateTransform3D.OffsetXProperty, TransformBindingX);
BindingOperations.SetBinding(translateTransform3D, TranslateTransform3D.OffsetYProperty, TransformBindingY);
BindingOperations.SetBinding(translateTransform3D, TranslateTransform3D.OffsetZProperty, TransformBindingZ);
Any Idea?
Best regards
Agha
|
|
|
|
|
Hai to all,
I am developing a sample animation application. while i run this application it shows the following errors. I don't know why this error was occured. The application usage memory was increases simultaneously while running the application. How to solve this error. If anybody had the solution for this error please reply this post.
System.Windows.Media.Imaging.BitmapSourceSafeMILHandle.ComputeEstimatedSize(IntPtr bitmapObject)
at System.Windows.Media.Imaging.BitmapSourceSafeMILHandle.CalculateSize()
at System.Windows.Media.Imaging.UnmanagedBitmapWrapper..ctor(BitmapSourceSafeMILHandle bitmapSource)
at System.Windows.Media.Effects.BitmapEffect.GetOutput(SafeHandle unmanagedEffect, Int32 index, BitmapEffectRenderContext context)
at System.Windows.Media.Effects.BitmapEffect.GetOutput(BitmapEffectInput input)
at System.Windows.Media.Effects.BitmapEffectState.GetEffectOutput(Visual visual, RenderTargetBitmap& renderBitmap, Matrix worldTransform, Rect windowClip, Matrix& finalTransform)
at System.Windows.Media.Effects.BitmapEffectVisualState.RenderBitmapEffect(Visual visual, Channel channel)
at System.Windows.Media.Effects.BitmapEffectContent.ExecuteRealizationsUpdate()
at System.Windows.Media.RealizationContext.RealizationUpdateSchedule.Execute()
at System.Windows.Media.MediaContext.Render(ICompositionTarget resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at AnimateApplication.App.Main()
damodharan
|
|
|
|
|
There are so many types of animations and without more information it looks no one able to help you.
Best regards
Agha
|
|
|
|
|
when i try to run my silver light 3 application i m getting the following message
"The Silverlight managed debugging package isn't installed"
pls help me to get out of this mess
|
|
|
|
|
Have you installed the Silverlight Tools for
Visual Studio?
Silverlight: Get Started[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No you need the Developer runtime
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
i have same error ,i installed MS silverlight,MS Silverlight SDK 3 ,MS Silverlight tools for VS 2008......
any help
|
|
|
|
|
Hello.
What is the XAML code of a WPF's TreeView Separator ?
I've been using <Separator /> , But this one is selectable ! I'm looking for a non-selectable Separator Tag !
Could you please guide me ?
Thanks in advance.
|
|
|
|
|
You can add a IsSeparatorBefore property to your view model objects, and have your DataTemplate draw the separator above the item if the property is true. You can use a negative top margin to have it appear above the selection.
Alternatively you can implement an attached property called IsSelectable that you can attach to your separator element. In the behavior of the property catch the PreviewMouseDown event and mark it as handled.
Also you can try to set IsEnabled to false on the separator, not sure that property is available on it.
|
|
|
|
|
Aviad P. wrote: You can add a IsSeparatorBefore property to your view model objects, and have your DataTemplate draw the separator above the item if the property is true. You can use a negative top margin to have it appear above the selection.
Unfortunately I couldn't understand the concept of view model objects.
Aviad P. wrote: Also you can try to set IsEnabled to false on the separator, not sure that property is available on it.
I tried it, when I set IsEnabled property to false , it's selectable again.
|
|
|
|
|
|