2
我有一個自定義用戶控件。在那個用戶控件中,我有一些按鈕,組合框,文本框。當我在wpf應用程序中使用它時,我希望能夠更改按鈕的背景和大小...我有所有控件的名稱,但是當我嘗試在wpf應用程序中訪問它們時,我甚至看不到它們。訪問按鈕在用戶控件中的屬性wpf
這裏是用戶控件 -
<UserControl x:Class="MyUserControl.UserControl"
Name="MyCustomUSerControl"
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"
d:DesignHeight="600" d:DesignWidth="620" Width="Auto" Height="Auto">
<Grid Width="Auto" Height="Auto" Background="LavenderBlush" x:Name="Grid_MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Expander Height="Auto" Width="Auto" Header="Filter" FontFamily="Arial Rounded MT">
<Border CornerRadius="12" BorderThickness="2" Margin="5" BorderBrush="CornflowerBlue" Height="Auto" Width="Auto">
<StackPanel Orientation="Horizontal" Height="Auto" Width="Auto" x:Name="StackPanel_ManinStackInExpander" >
<StackPanel x:Name="StackPanel_Column" Height="Auto" Width="Auto" Margin="10,10,0,10">
<Label x:Name="Label_Column" Content="Column" Height="22" Width="70" Margin="0,0,0,0" HorizontalAlignment="Left" FontFamily="Rockwell" FontWeight="Normal"/>
<ComboBox x:Name="ComboBox_Columns" Background="Transparent" Height="Auto" Width="Auto" MinWidth="100" FontFamily="Bernard MT"/>
<Label x:Name="Label_Like" Content="Like" Height="22" Width="70" Margin="0,0,0,0" HorizontalAlignment="Left" FontFamily="Rockwell" FontWeight="Normal"/>
<TextBox Background="Transparent" Height="Auto" Width="Auto" FontFamily="Bernard MT" MinWidth="100" x:Name="TextBox_Like"/>
<StackPanel Orientation="Horizontal">
<StackPanel>
<Label x:Name="Label_Operation" Content="Operation" FontFamily="Rockwell"/>
<ComboBox x:Name="ComboBox_Operation" Background="Transparent" Width="50" HorizontalAlignment="Left" Margin="5,0,0,0">
<ComboBoxItem Content="<"> </ComboBoxItem>
<ComboBoxItem Content=">"></ComboBoxItem>
<ComboBoxItem Content="="></ComboBoxItem>
<ComboBoxItem Content=">="></ComboBoxItem>
<ComboBoxItem Content="<="></ComboBoxItem>
<ComboBoxItem Content="<>"></ComboBoxItem>
</ComboBox>
</StackPanel>
<StackPanel Margin="10,0,0,0">
<Label Content="Value" x:Name="Label_Value" FontFamily="Rockwell"/>
<TextBox Background="Transparent" Width="Auto" Height="Auto"/>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel Height="Auto" Width="Auto" Margin="10,10,0,10">
<Button x:Name="Button_AND" Background="LightGoldenrodYellow" Content="AND" Height="20" Width="70" Margin="10" FontFamily="Californian FB" FontWeight="Bold"/>
<Button x:Name="Button_OR" Background="LightGoldenrodYellow" Content="OR" Height="20" Width="70" Margin="10,0,10,10" FontFamily="Californian FB" FontWeight="Bold"/>
</StackPanel>
<ListView Margin="10" MinWidth="200" Background="Transparent" BorderThickness="1"></ListView>
<StackPanel Margin="0,10,10,10">
<Button x:Name="Button_Enclose" Background="LightGoldenrodYellow" Width="120" Height="25" Margin="10" Content="()" FontFamily="Californian FB" FontWeight="Bold" FontSize="14"/>
<Button x:Name="Button_Filter" Background="LightGoldenrodYellow" Width="120" Height="25" Margin="10,45,10,0" Content="FIlter" FontFamily="Californian FB" FontWeight="Bold" FontSize="14"/>
</StackPanel>
</StackPanel>
</Border>
</Expander>
</Grid>
@艾爾諾,謝謝 – 2011-05-12 09:00:45
沒問題!別客氣。 – 2011-05-12 09:08:12