|
Sure, but I want the standard behavior which displays the "no drop" icon (like a stop sign or something) when drop isn't allowed (meaning DragEffect is set to None). This works fine in windows forms and is even documented in WPF but for some reason doesn't work. It's not something I have to implement myself, it's internal Windows behavior, try to drag something somewhere and you'll see for yourself).
|
|
|
|
|
Hi,
the user control that is displayed within the ContentControl is coming as left justified. Is there any way that I can keep HorizontalContentAlignment="Stretch", HorizontalAlignment="Stretch" and still make the user control left justifiable. Because if I set any of the above values to "Left", it is effecting other User Controls, specially the user control is not stretching to max width of the browser.
Is there any property in content control to stretch to the max width of the browser and still, the user control within the content control be left justifiable,
<UserControl x:Class="Huron.UI.Healthcare.Configuration.Common.TaskWorkContainerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:regions="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism"
xmlns:local="clr-namespace:Huron.UI.Healthcare.Configuration.Common"
DataContext="{Binding TaskWorkContainer,Source={StaticResource ConfigSupportViewModelLocator}}">
<Grid ScrollViewer.HorizontalScrollBarVisibility="Auto">
<Grid.RowDefinitions>
<RowDefinition Height="24" />
<RowDefinition Height="*" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<ColumnDefinition MinWidth="744" Width="*" />
<ColumnDefinition Width="10" />
</Grid.ColumnDefinitions>
<Canvas Grid.Row="0" Grid.Column="1" >
<local:TaskWorkContainerHeaderView
Grid.Row="0" Grid.Column="1"
DataContext="{Binding Path=FormHeader}"
VerticalAlignment="Top" />
</Canvas>
<ContentControl
Margin="0,15,0,0"
Grid.Row="1" Grid.Column="1"
regions:RegionManager.RegionName="{Binding FormData.FormBodyRegionName}"
regions:RegionManager.RegionContext="{Binding FormData}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
HorizontalAlignment="Stretch"/>
<Canvas Grid.Row="2" Grid.Column="1" >
<local:TaskWorkContainerFooterView
Grid.Row="2" Grid.Column="1"
DataContext="{Binding Path=FormFooter}"
Visibility="{Binding Path=FooterVisibility}"
VerticalAlignment="Bottom" />
</Canvas>
</Grid>
</UserControl>
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Your content control is in a grid cell that is star sized, so can you just set the Horizontalalignment of the contentcontrol to left?
Mark Salsbery
|
|
|
|
|
Hi,
No, when I set the HorizontalContentAlignment="Left", HorizontalAlignment="Left", the user control in the content control is shrinking towrds left. There are some borders in the user control that are coming as left side shrinked, and the user control is looking not good.
When I make HorizontalContentAlignment="Stretch", HorizontalAlignment="Stretch", the user control is displayed as center aligned and looking more ugly.
Is there any way that I can keep HorizontalContentAlignment="Stretch", HorizontalAlignment="Stretch" and still make the user control in the content control left justifiable, and stretch to the remaining width of the browser and looks beautifull.
Because if I set any of the above values to "Left", it is effecting other User Controls, specially the user control is not stretching to max width of the browser.
Thanks,
Abdul
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I have a WPF application created that during development lives as an EXE application. All works without issue as an EXE. I wish to convert that to a DLL and to call it from a mixed-mode EXE written in C++/CLI. I want to create an inherited class that inherits from the WPF class (MainWindow). I changed the target of the WPF app to that of a library. I removed the App.xml from the solution and changed the Output type to class library.
In the CLR app I create the following class:
public ref class MyInheritedForm : public WPFNameSpace::MainWindow
{
public:
MyInheritedForm ()
{
}
};
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
MyInheritedForm^ test = gcnew MyInheritedForm;
test->Show();
return 0;
}
The problem occurs in the constructor of the base class (MainWindow) in the InitializeComponent() call. The error is:
An unhandled exception of type 'System.Exception' occurred in PresentationFramework.dll
Additional information: The component 'MyInheritedForm' does not have a resource identified by the URI '/WPFNameSpce;component/mainwindow.xaml'.
I think this "MAY" be possible but clearly there are fundamental problems. Additionally, in Nishant Sivakumar's book there is an example (FirstAvalonDerived) that crashed with the same error, at the same location. Perhaps it's a VS2010 problem as I would assume the example was tested.
Can someone write back if there is a workaround solution to this. This is a huge problem for any systems that were written in WinForms and now dead-ended due to this bug in WPF.
Thanks for any help.
modified 11-Nov-11 8:17am.
|
|
|
|
|
Hello,
Im creating MdiChild window and i add to MdiChilds content user control so far so good.
But when i take another Mdichild window and i sweep it over the first one the window that i sweep with enters between the mdichild and the user control.
thanks
|
|
|
|
|
In Silverlight/WPF?
Mark Salsbery
|
|
|
|
|
Hey,
Im using WPF
This is the piece of code that initiates the MDI child:
MdiChild child = new MdiChild();
child.Title = "AddIn";
child.Content = addin.GetVisual();//returns FrameworkElement
child.Height = 200;
child.Width = 240;
child.MaximizeBox = false;
child.Resizable = true;
child.Visibility = winVis;
child.WindowState = winState;
MDIchildren.Children.Add(child);//Add MDI child to a window
Thanks.
|
|
|
|
|
I didn't know WPF had an MdiChild class...
Mark Salsbery
|
|
|
|
|
There's a reason you don't know this. It doesn't.
|
|
|
|
|
Hi
I want to add hyperlink to a Textblock from model. Here is my code...
XAML:
<ItemsControl x:Name="Items" Style="{DynamicResource ItemsControlStyle}" />
<Style x:Key="ItemsControlStyle" TargetType="{x:Type ItemsControl}">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<Grid x:Name="grid">
-----------
<TextBlock Text="{Binding Text}" />
-----------
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
In xaml.cs:
Items.ItemsSource = ItemsData;
In Model
ItemsData.Add(Text = <some Value>);
This works fine and display the normal text. But I want to add hyperlink to the text from the model class. I dont want to change the xaml. So how could I add hyperlink to text from Model class?
Thanks in Advance,
|
|
|
|
|
Same reply as here...[^]
To put a hyperlink (which is formatted text) as the textblock content you'll need to use formatted text added to th TextBlock.Inlines property instead of the Text property (which is for plain text).
Maybe something like this (I'll let you work it into your model)...
Run r = new Run("link");
mytextblock.Inlines.Add(new Hyperlink(r));
Mark Salsbery
|
|
|
|
|
Mark,
I can't access the textblock in model and also the same textblock is used to show other data and for other data I don't want to show the hyperlink.
I want to show hyperlink for some of the data. So I have to add hyperlink in Model to the text but not for the textblock. How could I do this?
Thanks,
|
|
|
|
|
TextBlocks only support text unless you add a hyperlink run. They don't know how to render hyperlinks by themselves. Unfortunately, the Inlines collection is not bindable. If you *really* want to do this in a MVVM way, you'd need to derive a class from TextBlock, i.e. TextBlockEx and add a bindable version of the Inlines property (i.e.) InlinesEx or whatever and every time Inlines or InlinesEx changes, you sync up the other one. I've done something similiar with ListView.SelectedItems, so I know the "theory" works . This IMO, is the method to keep everything as legit MVVM as possible.
|
|
|
|
|
Hi All,
I have following code in silverlight, I want to set max width for the StackPanel dynamically in xaml, but its not showing anything, means the width or max width value it is getting is "0". Basically I want to set the maxwidth of xaml to wrap the text inside the textblock
Foloowing is the Silverlight user control xaml:
<UserControl x:Class="TextBlockLayoutTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converters="clr-namespace:ConvertersSilverlightClassLibrary;assembly=ConvertersSilverlightClassLibrary"
mc:Ignorable="d" x:Name="testUC">
<UserControl.Resources>
<converters:PercentageConverter x:Key="PercentageConverter"/>
</UserControl.Resources>
<Grid x:Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="gridCol1" Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0"
MaxWidth="{Binding ElementName=grid, Path=ActualWidth}">
<TextBlock TextWrapping="Wrap" >
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
</TextBlock>
</StackPanel>
</Grid>
</UserControl>
public class PercentageConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double d = System.Convert.ToDouble(value);
d = System.Convert.ToDouble(parameter);
return System.Convert.ToDouble(value) * System.Convert.ToDouble(parameter);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
I tried to do the same using converters too, I binded my TextBlock width property with this PercentageConverter class still, the convert method is returning 0 so the textblock is becoming invisible. I tried in all the ways to wrap the text in side the textblock and show it accordning to the maxwidth of stack panel. In anyways its not becoming possible to wrap the text. We are implementing MVVM and Prism so we dont to implement code behind.
Can anybody please help me achieving this without using the code behind.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Your XAML shows no place you are actually trying to constrain the size to, so I assume you want the StackPanel constrained to the size of the UserControl. If that's the case then just the grid with the stackpanel in it will do that without your binding attempt...
<Grid x:Name="grid">
<StackPanel Orientation="Vertical" >
<TextBlock TextWrapping="Wrap" >
test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test test
</TextBlock>
</StackPanel>
</Grid>
What do you really want to constrain the stackpanel size to?
Mark Salsbery
|
|
|
|
|
I think everything is working "as expected" . You just expected the wrong outcome . I suspect the layout cycle is resulting in your TextBlock wrapping to a width of 0.
I'd get rid of the column definition, get rid of MaxWidth on StackPanel and add something like this to TextBlock:
Width={Binding ElementName=grid, Path=ActualWidth}
That way you are sizing the TextBlock to the width of the grid and it'll wrap to that width.
|
|
|
|
|
Hi,
No use, its not working still. Why MS has created this binding IDK but that never ever works for me at all.
Why did MS has created this complex I dont know.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I have an application which, while displaying a splash screen, checks for the presence of several files required for the proper running of the main window. If a file is not found the filename is passed to a method and the following should happen:
> progressbar colour changed to indicate an error
> status message(normally used to tell the user what the app is doing) tells the user that something has gone wrong
> a messagebox is displayed, giving the user the exact name of the required file that is missing.
The problem I'm having is that if a file is found to be missing, the messagebox displays but the splash never does. Is there a way to do it so that the messagebox appears over the top of the window ?
modified 4-Nov-11 13:47pm.
|
|
|
|
|
I think what is happening is that everything is running on the UI thread, and so locking up the splash screen. You should try running the file search on a separate thread(BackgroundWorker) or in a new task if you are using .Net 4.0.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Hmm haven't used either options before, guess I've got some googling to do.
|
|
|
|
|
Sacha Barber wrote an excellent series of articles on the Task Parallel Library . Here[^] is the first one to start you off. Have fun!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I've got my task set up, now to stop it complaining that the progressbar is owned by another thread :/
*Edit* Looks like I'm going to half to split my foreach which goes through a string array and checks each required file into seperate tasks for each one. All this effort for something that should be so simple
modified 4-Nov-11 13:15pm.
|
|
|
|
|
All UI objects are owned by the UI thread. You can't access them from another thread. This is by design. You need to use the thread dispatcher. Something like:
Dispatcher.Invoke(DispatcherPriority.Input, new Action(() =>
{
// do stuff in here
}));
|
|
|
|
|
Thanks, got it sorted. Now to figure out why the whole app dies if fluent.dll (from http://fluent.codeplex.com) isn't there when only the main window needs it and isn't run until the splash screen tells it to.
*Edit* Was setting default theme in app.xaml, moved that and everthings fine. Thanks guys !
modified 4-Nov-11 13:46pm.
|
|
|
|