|
Richard Deeming wrote: Or in a global style within the application:
<Style TargetType="{x:Type uc1:TimePicker}">
<Setter Property="ComboBoxStyle" Value="{StaticResource TimePickerComboStyle}" />
</Style>
Ok, I see where you're going with this....
so the App has a ref to both the shared styles project AND the UC project. Once I drop the control onto a form, I could then use the DP to set its style, assuming TimePickerComboStyle is the shared styles project?
If it's not broken, fix it until it is
|
|
|
|
|
Yes, that's right.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
OK, I get it. I never considered having to use a DP, but I'm not opposed to it.
Thanks for your patience.
If it's not broken, fix it until it is
|
|
|
|
|
i have a control, when i rotate it, some corners out of canvas
i would like to avoid this situation
however i try to get position of 4 corners of canvas and control are fail
who can suggest an idea to me ?
|
|
|
|
|
Hi, I have 3 buttons in a user control, I would like to show and hide one button from the Host application or from the user control. Its not working for me. Please check it.
<UserControl x:Class="WPFUserControl.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
xmlns:vis="clr-namespace:WPFUserControl"
d:DesignHeight="300" d:DesignWidth="300">
<UserControl.Resources>
<vis:BoolToVisibilityConverter x:Key="BoolToVis" ></vis:BoolToVisibilityConverter>
</UserControl.Resources>
<Grid>
<Button Content="Button1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75"/>
<Button Content="Button2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="106,0,0,0"/>
<Button Content="ShowHide" Visibility="{Binding IsShowHideVisible, Converter={StaticResource BoolToVis}, ConverterParameter=False}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="215,0,0,0"/>
</Grid>
</UserControl>
public partial class UserControl1 : UserControl, INotifyPropertyChanged
{
private bool isShowHideVisible;
public bool IsShowHideVisible
{
get { return isShowHideVisible; }
set
{
if(isShowHideVisible!=value)
{
isShowHideVisible = value;
OnPropertyChanged("IsShowHideVisible");
}
}
}
public UserControl1()
{
InitializeComponent();
}
private void OnPropertyChange(string pPropertyName)
{
if(PropertyChanged!=null)
{
PropertyChanged(this, new PropertyChangedEventArgs(pPropertyName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
modified 30-Jun-15 3:32am.
|
|
|
|
|
Since UserControl is a DependencyObjecy , I suspect you'll need to use a dependency property.
You'll also need to set the DataContext to the user control class, so that the binding knows where to find the property.
public partial class UserControl1 : UserControl
{
public static readonly DependencyProperty IsShowHideVisibleProperty = DependencyProperty.Register(
"IsShowHideVisible", typeof(bool), typeof(UserControl1),
new FrameworkPropertyMetaData(false));
public bool IsShowHideVisible
{
get { return (bool)GetValue(IsShowHideVisibleProperty); }
set { SetValue(IsShowHideVisibleProperty, value); }
}
public UserControl1()
{
InitializeComponent();
DataContext = this;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard Deeming, it worked...
|
|
|
|
|
Hi All,
I have one single UserControl library, it has more than 20 of controls. Some of client wants to hide the 2-3 controls. I have to bind the visibility properties of all the controls based on different client types. Which is the best approach to know the which client wants the particular controls.
Thanks
|
|
|
|
|
i want make Online examination system so which module we used help me .and it work flow of the system
|
|
|
|
|
With the demise of Silverlight online and this forum are not compatible, try ASP. You cannot expect a forum to of any use helping you with the minimal information you have supplied.
Look into ASP.net and MVC.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have added an expander[^] vertically down the right side of my app. It looks fine like that.
But when I expand it[^], it appears wrong.
This [^]is how it should look.
Here's my XAML:
<Expander Grid.Row="1"
Grid.Column="2"
BorderThickness="1"
BorderBrush="SteelBlue"
Background="White"
ExpandDirection="Left"
IsExpanded="False"
HorizontalAlignment="Right"
MaxWidth="150"
Margin="0,0,5,5">
<pre>
<Expander.Effect>
<DropShadowEffect/>
</Expander.Effect>
<Expander.Header>
<TextBlock Text="My Stuff">
<TextBlock.LayoutTransform>
<RotateTransform Angle="90"/>
</TextBlock.LayoutTransform>
</TextBlock>
</Expander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<bc:DFTGrid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<bc:DFTComboBox Grid.Column="0"
Style="{StaticResource ComboBoxStyle}"
Margin="2"/>
</bc:DFTGrid>
<bc:DFTListBox Grid.Row="1"
MinWidth="250"
ItemsSource="{Binding Sensors, Mode=TwoWay}"
ScrollViewer.VerticalScrollBarVisibility="Auto">
</bc:DFTListBox>
</Grid>
how do I get the header to go to the top when it's expanded?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
The problem is down to the fact that you have applied a rotation to your Header. It's always going to appear at 90 degrees. You could simply apply a trigger that fires off IsExpanded, and translation at that point.
|
|
|
|
|
I thought the same thing, but removing the rotation simply causes the header text to become horizontal. The header is still down the right side and the content still appears at the top.
See this[^] and this[^].
If it's not broken, fix it until it is
|
|
|
|
|
This is pretty close[^], but there's still a problem:
<Expander Grid.Row="1"
Grid.Column="2"
x:Name="expander"
BorderThickness="1"
BorderBrush="SteelBlue"
Background="White"
ExpandDirection="Down"
IsExpanded="False"
HorizontalAlignment="Right"
Margin="0,0,5,7">
<pre>
<Expander.Effect>
<DropShadowEffect/>
</Expander.Effect>
<Expander.Style>
<Style TargetType="Expander">
<Setter Property="Header" Value="My Stuff"/>
<Style.Triggers>
<Trigger Property="IsExpanded" Value="False">
<Setter Property="Header" Value=""/>
</Trigger>
</Style.Triggers>
</Style>
</Expander.Style>
<Expander.Header>
<TextBlock Text="Sensors">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
Value="False">
<Setter Property="LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90"/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Expander.Header>
<f6cc:FalconSensorList Width="150"/>
Now, the when expanded the header is at the top, and the content is below it. So far so good.
However, when NOT expanded, the header text appears horizontal - the rotate isn't working.
https://onedrive.live.com/redir?resid=F6FBCF1880A16630!238&authkey=!ANQDHrjshc7s5AI&v=3&ithint=photo%2cpng
Any idea what's wrong with the transform?
If it's not broken, fix it until it is
|
|
|
|
|
I made some changes to the given xaml code to make it work...
Hope the code snippet will help
<Expander x:Name="MyExpander" BorderThickness="1" BorderBrush="SteelBlue"
Background="White" IsExpanded="False" HorizontalAlignment="Right" MaxWidth="150" Margin="0,0,5,5">
<Expander.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=MyExpander, Path=IsExpanded}" Value="False">
<Setter Property="Expander.ExpandDirection">
<Setter.Value>
Left
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=MyExpander, Path=IsExpanded}" Value="True">
<Setter Property="Expander.ExpandDirection">
<Setter.Value>
Down
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Expander.Style>
<Expander.Header>
<TextBlock Text="My Stuff">
<TextBlock.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=MyExpander, Path=IsExpanded}" Value="True">
<Setter Property="TextBlock.LayoutTransform">
<Setter.Value>
<RotateTransform Angle="0"></RotateTransform>
</Setter.Value>
</Setter>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=MyExpander, Path=IsExpanded}" Value="False">
<Setter Property="TextBlock.LayoutTransform">
<Setter.Value>
<RotateTransform Angle="90"></RotateTransform>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Expander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ComboBox Grid.Column="0"
Margin="2"/>
</Grid>
<ListBox Grid.Row="1"
MinWidth="250"
ItemsSource="{Binding Sensors, Mode=TwoWay}"
ScrollViewer.VerticalScrollBarVisibility="Auto">
</ListBox>
</Grid>
</Expander>
|
|
|
|
|
I have to following in my App.xaml code behind:
public partial class App : Application
{
public App()
{
}
private void Application_Startup(object sender, StartupEventArgs e)
{
Application.Current.DispatcherUnhandledException += dispatchUnhandled;
AppDomain.CurrentDomain.UnhandledException += applicationUnhandledException;
}
private void dispatchUnhandled(object sender, DispatcherUnhandledExceptionEventArgs e)
{
var errorMessage = getInnerException(e.Exception);
displayErrorMessage(errorMessage, e.Exception);
e.Handled = true;
}
private static void applicationUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var ex = e.ExceptionObject as Exception;
var errorMessage = getInnerException(ex);
displayErrorMessage(errorMessage, ex);
}
private static void displayErrorMessage(string errorMessage, Exception ex)
{
logException(errorMessage, ex);
ErrorHandlerViewModel vm = new ErrorHandlerViewModel();
vm.ErrorMessage = errorMessage;
vm.ErrorText = ex.ToString();
ErrorHandlerView view = new ErrorHandlerView();
view.DataContext = vm;
view.ShowDialog();
Application.Current.Shutdown();
}
private static string getInnerException(Exception e)
{
string msg = e.InnerException == null ? e.Message : getInnerException(e.InnerException);
return msg;
}
private static void logException(string errorMessage, Exception ex)
{
Logger.LogMessage(errorMessage);
Logger.LogMessage(ex.ToString());
}
}
Application_Startup DOES run, but no exceptions are caught. What's wrong here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Are any exceptions thrown? If so, where are they thrown from?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
yes, I added this in the MainWindowViewModel:
int x = 0;
int y = 10;
int z = y / x;
It throws, it doesn't get caught in the global exception handler.
If it's not broken, fix it until it is
|
|
|
|
|
What triggers that code to run?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It's the main window in a WPF app. It's called from App.xaml
If it's not broken, fix it until it is
|
|
|
|
|
When an unhandled exception is thrown Application.Current.DispatcherUnhandledException is invoked. Hence the code written in your handler 'dispatchUnhandled' is executed.
Do i miss your specific question?
Manish Jain (MJ)
|
|
|
|
|
I want to sell a user control I created. I want to provide a registration key.
How do I keep someone from using my control without the key? There has to be something inside the code that checks the key
If it's not broken, fix it until it is
|
|
|
|
|
About
I created this range slider[^] control. It has 2 thumbs, thus allowing for a range,
Functionality
a) Clicking the track bar OUTSIDE the thumbs should center the thumbs on that point.
b) Dragging INSIDE the thumbs should move both thumbs equally.
Issues
When the window isn't too big, it all works OK. But, resize the window really wide and then try A & B above. It doesn't move right.
The code you need to see is in the RangeSlider control, in the Border_MouseDown and Border_MouseMove events.
I would appreciate any help or suggestions you can offer.
If it's not broken, fix it until it is
|
|
|
|
|
I have created a dual thumb slider as shown here[^].
I also added in some mouse events, and I'm close to done.
Now, I'd like to style it like this[^].
But it seems that the control template is preventing the style from showing.
How do I use this style and control together?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
I need to set a ListBox's Items heights so that they fill the entire listbox:
In this window[^], everything below the splitter is my control. On the left is the listbox.
You can see there's open space below the last list item. It's ever more evident here[^]
Here's my XAML:
<ListBox Grid.Column="0"
x:Name="categoryList"
BorderBrush="LightGray"
BorderThickness="0,0,1,0"
ItemsSource="{Binding Categories}"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
IsEnabled="False"
Background="White"
Width="100"
Margin="0,-2,0,0">
<pre>
<ListBox.Style>
<Style TargetType="{x:Type ListBox}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.Style>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Height" Value="{Binding Path=DataContext.ListItemHeight, RelativeSource={RelativeSource AncestorType=Grid}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="LightGray"/>
<Setter Property="BorderThickness" Value="0,0,0,1"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="SteelBlue"/>
<Setter Property="Background" Value="White"/>
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding CategoryName}"
VerticalAlignment="Center"
FontSize="16"
Margin="10,0,0,0"/>
</DataTemplate>
</ListBox.ItemTemplate>
and the control's SizeChanged event:
private void sizeChanged(object sender, SizeChangedEventArgs e)
{
ListItemHeight = Math.Floor(this.ActualHeight / (Categories.Count + 1));
}
What am I doing wrong here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|